gestion de la copie des clefs pour les followers

This commit is contained in:
Emmanuel Garette 2019-02-22 17:16:04 +01:00
parent f945e19efb
commit 41d45ed2a2
3 changed files with 29 additions and 16 deletions

View File

@ -447,6 +447,7 @@ function main()
wait_true_retcode "Wait for oned to be started" "onecluster show 0 > /dev/null" wait_true_retcode "Wait for oned to be started" "onecluster show 0 > /dev/null"
if [ "$(CreoleGet activer_one_ha)" = "oui" ]; then if [ "$(CreoleGet activer_one_ha)" = "oui" ]; then
if [ "$(CreoleGet one_ha_server_index)" != "0" ]; then if [ "$(CreoleGet one_ha_server_index)" != "0" ]; then
# ne pas faire sur les followers
return return
fi fi
fi fi
@ -461,10 +462,14 @@ function main()
# #
# Creating Host # Creating Host
# #
if [[ $(CreoleGet eole_module non) != 'hapy-master' ]] if [ "$(CreoleGet activer_one_ha)" = "oui" ]; then
then /usr/share/eole/sbin/onehost_create_all
host=$(CreoleGet nom_machine) else
manage_host ${host} if [[ $(CreoleGet eole_module non) != 'hapy-master' ]]
then
host=$(CreoleGet nom_machine)
manage_host ${host}
fi
fi fi
# #

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
function init_ha() { function init_ha_leader() {
# server with index 1 exists if already instanciate # server with index 1 exists if already instanciate
onezone show 0 | grep -A 3 ^"HA & FEDERATION SYNC STATUS" | tail -n 1 | grep -q ^" 1 " onezone show 0 | grep -A 3 ^"HA & FEDERATION SYNC STATUS" | tail -n 1 | grep -q ^" 1 "
if [ ! $? = 0 ]; then if [ ! $? = 0 ]; then
@ -13,7 +13,7 @@ function init_ha() {
if [ "$(CreoleGet activer_one_ha)" = "oui" ]; then if [ "$(CreoleGet activer_one_ha)" = "oui" ]; then
if [ "$(CreoleGet one_ha_server_index)" = "0" ]; then if [ "$(CreoleGet one_ha_server_index)" = "0" ]; then
init_ha init_ha_leader
fi fi
fi fi

View File

@ -19,12 +19,12 @@ function copy_ssh_id()
ssh ${host} bash -s <<EOF ssh ${host} bash -s <<EOF
if ! grep -qs $CLEF ~oneadmin/.ssh/authorized_keys if ! grep -qs $CLEF ~oneadmin/.ssh/authorized_keys
then then
echo $CLEF >> ~oneadmin/.ssh/authorized_keys echo $CLEF >> ~oneadmin/.ssh/authorized_keys
chown oneadmin:oneadmin ~oneadmin/.ssh/authorized_keys chown oneadmin:oneadmin ~oneadmin/.ssh/authorized_keys
fi fi
EOF EOF
su - oneadmin -c "ssh-keyscan $host" su - oneadmin -c "ssh-keyscan $host"
return ${?} return ${?}
} }
# #
@ -79,15 +79,15 @@ function wait_node_ok()
HAPY_ACTIF=$(echo $(CreoleGet activer_onesinglenode)) HAPY_ACTIF=$(echo $(CreoleGet activer_onesinglenode))
if [[ $HAPY_ACTIF == "non" ]] if [[ $HAPY_ACTIF == "non" ]]
then then
EchoRouge "Le serveur de virtualisation n'est pas activé dans l'interface de configuration du module" EchoRouge "Le serveur de virtualisation n'est pas activé dans l'interface de configuration du module"
exit 1 exit 1
fi fi
HAPY_NODE_SUPPORT=$(echo $(CreoleGet activer_multinode)) HAPY_NODE_SUPPORT=$(echo $(CreoleGet activer_multinode))
if [[ $HAPY_NODE_SUPPORT == "non" ]] if [[ $HAPY_NODE_SUPPORT == "non" ]]
then then
EchoRouge "Le mode multi-noeuds n'est pas activé dans l'interface de configuration du module" EchoRouge "Le mode multi-noeuds n'est pas activé dans l'interface de configuration du module"
exit 1 exit 1
fi fi
declare -a HAPY_SLV=('') declare -a HAPY_SLV=('')
ONEUSER=$(CreoleGet virt_user) 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" Question_ouinon "Voulez-vous commencer ?" 'True' "oui"
if [[ $? -ne 0 ]] if [[ $? -ne 0 ]]
then then
EchoOrange "Abandon de l'enregistrement" EchoOrange "Abandon de l'enregistrement"
exit 1 exit 1
fi 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)) for ((i = 0; i < ${#HAPY_SLV[*]}; i +=1))
do do
echo -e "\n" echo -e "\n"
@ -111,7 +116,10 @@ do
EchoVert " * Gestion des clés SSH" EchoVert " * Gestion des clés SSH"
echo echo
copy_ssh_id ${HAPY_SLV[${i}]} 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" EchoVert " * Enregistrement du noeud"
register_node ${HAPY_SLV[${i}]} register_node ${HAPY_SLV[${i}]}