From f945e19efb2c6bd4a951a23b7f93005c719fa3f5 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Fri, 22 Feb 2019 17:05:11 +0100 Subject: [PATCH 1/2] copie de la bonne clef sur les noeuds --- scripts/onehost_create_all | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/onehost_create_all b/scripts/onehost_create_all index a06fa83..35fe5db 100755 --- a/scripts/onehost_create_all +++ b/scripts/onehost_create_all @@ -7,23 +7,23 @@ . /usr/lib/eole/ihm.sh # -# NAME: copy_ssh_id +# NAME: copy_ssh_id # AIM: Copy the ssh key on the host -# PARAM: the hostname of the node +# PARAM: the hostname of the node # function copy_ssh_id() { - local ip=${1} + local host=${1} - ssh ${ip} bash -s < /tmp/one-master.key.pub -if ! grep -qs /tmp/one-master.key.pub ~oneadmin/.ssh/authorized_keys + CLEF=$(cat ~oneadmin/.ssh/id_rsa.pub) + ssh ${host} bash -s <> ~oneadmin/.ssh/authorized_keys + echo $CLEF >> ~oneadmin/.ssh/authorized_keys chown oneadmin:oneadmin ~oneadmin/.ssh/authorized_keys fi -rm -f /tmp/one-master.key.pub EOF + su - oneadmin -c "ssh-keyscan $host" return ${?} } @@ -42,7 +42,7 @@ function register_node() # # NAME: wait_node_ok # AIM: Wait until the node is OK or ERROR -# PARAM: The node name +# PARAM: The node name # function wait_node_ok() { From 41d45ed2a2c2c67b121fcfafd1ba1e4940f9d160 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Fri, 22 Feb 2019 17:16:04 +0100 Subject: [PATCH 2/2] gestion de la copie des clefs pour les followers --- postservice/30-one-mng | 13 +++++++++---- postservice/99-z-ha | 4 ++-- scripts/onehost_create_all | 28 ++++++++++++++++++---------- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/postservice/30-one-mng b/postservice/30-one-mng index 77585ab..8a4bef8 100755 --- a/postservice/30-one-mng +++ b/postservice/30-one-mng @@ -447,6 +447,7 @@ function main() wait_true_retcode "Wait for oned to be started" "onecluster show 0 > /dev/null" if [ "$(CreoleGet activer_one_ha)" = "oui" ]; then if [ "$(CreoleGet one_ha_server_index)" != "0" ]; then + # ne pas faire sur les followers return fi fi @@ -461,10 +462,14 @@ function main() # # Creating Host # - if [[ $(CreoleGet eole_module non) != 'hapy-master' ]] - then - host=$(CreoleGet nom_machine) - manage_host ${host} + if [ "$(CreoleGet activer_one_ha)" = "oui" ]; then + /usr/share/eole/sbin/onehost_create_all + else + if [[ $(CreoleGet eole_module non) != 'hapy-master' ]] + then + host=$(CreoleGet nom_machine) + manage_host ${host} + fi fi # diff --git a/postservice/99-z-ha b/postservice/99-z-ha index 4a9c898..fcf1278 100755 --- a/postservice/99-z-ha +++ b/postservice/99-z-ha @@ -1,6 +1,6 @@ #!/usr/bin/env bash -function init_ha() { +function init_ha_leader() { # server with index 1 exists if already instanciate onezone show 0 | grep -A 3 ^"HA & FEDERATION SYNC STATUS" | tail -n 1 | grep -q ^" 1 " if [ ! $? = 0 ]; then @@ -13,7 +13,7 @@ function init_ha() { if [ "$(CreoleGet activer_one_ha)" = "oui" ]; then if [ "$(CreoleGet one_ha_server_index)" = "0" ]; then - init_ha + init_ha_leader fi fi diff --git a/scripts/onehost_create_all b/scripts/onehost_create_all index 35fe5db..7f8b379 100755 --- a/scripts/onehost_create_all +++ b/scripts/onehost_create_all @@ -19,12 +19,12 @@ function copy_ssh_id() ssh ${host} bash -s <> ~oneadmin/.ssh/authorized_keys - chown oneadmin:oneadmin ~oneadmin/.ssh/authorized_keys + echo $CLEF >> ~oneadmin/.ssh/authorized_keys + chown oneadmin:oneadmin ~oneadmin/.ssh/authorized_keys fi EOF su - oneadmin -c "ssh-keyscan $host" - return ${?} + return ${?} } # @@ -79,15 +79,15 @@ function wait_node_ok() HAPY_ACTIF=$(echo $(CreoleGet activer_onesinglenode)) if [[ $HAPY_ACTIF == "non" ]] then - EchoRouge "Le serveur de virtualisation n'est pas activé dans l'interface de configuration du module" - exit 1 + EchoRouge "Le serveur de virtualisation n'est pas activé dans l'interface de configuration du module" + exit 1 fi HAPY_NODE_SUPPORT=$(echo $(CreoleGet activer_multinode)) if [[ $HAPY_NODE_SUPPORT == "non" ]] then - EchoRouge "Le mode multi-noeuds n'est pas activé dans l'interface de configuration du module" - exit 1 + EchoRouge "Le mode multi-noeuds n'est pas activé dans l'interface de configuration du module" + exit 1 fi declare -a HAPY_SLV=('') ONEUSER=$(CreoleGet virt_user) @@ -99,10 +99,15 @@ EchoBleu "Pour ce faire vous devez vous munir du mot de passe de l'utilisateur ' Question_ouinon "Voulez-vous commencer ?" 'True' "oui" if [[ $? -ne 0 ]] then - EchoOrange "Abandon de l'enregistrement" - exit 1 + EchoOrange "Abandon de l'enregistrement" + exit 1 fi +if [ "$(CreoleGet activer_one_ha)" = "oui" ] && [ "$(CreoleGet one_ha_server_index)" != "0" ]; then + follower=0 +else + follower=1 +fi for ((i = 0; i < ${#HAPY_SLV[*]}; i +=1)) do echo -e "\n" @@ -111,7 +116,10 @@ do EchoVert " * Gestion des clés SSH" echo copy_ssh_id ${HAPY_SLV[${i}]} - [[ ${?} -ne 0 ]] && EchoRouge "Erreur lors de l'échange de clés SSH avec le noeud ${HAPY_SLV[${i}]}}" + [[ ${?} -ne 0 ]] && EchoRouge "Erreur lors de l'échange de clés SSH avec le noeud ${HAPY_SLV[${i}]}}" + if [ $follower = 0 ]; then + continue + fi EchoVert " * Enregistrement du noeud" register_node ${HAPY_SLV[${i}]}