improved deboco to log some debops controller information on the configured machines' /var/log/ipr/deboco.log file
This will help to know which controller is expected to control a given machine work related to https://bugzilla.ipr.univ-rennes.fr/show_bug.cgi?id=3713 and https://bugzilla.ipr.univ-rennes.fr/show_bug.cgi?id=3726
This commit is contained in:
parent
769c4076e5
commit
a8549fbd60
|
@ -212,6 +212,31 @@ controller__check_integrity()
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
controller__log_message_to_machine()
|
||||||
|
{
|
||||||
|
local configured_machine_fqdn="$1"
|
||||||
|
local message_type="$2" # debug, info, warning, error
|
||||||
|
local message="$3"
|
||||||
|
|
||||||
|
local deboco_log_file_path='/var/log/ipr/deboco.log'
|
||||||
|
local deboco_log_dir_path="$(dirname /var/log/ipr/deboco.log)"
|
||||||
|
local line="$(date --iso=seconds) [${message_type}] ${message}"
|
||||||
|
local commands="mkdir -p ${deboco_log_dir_path} && echo '${line}' >> ${deboco_log_file_path}"
|
||||||
|
ssh root@${configured_machine_fqdn} "$commands"
|
||||||
|
}
|
||||||
|
|
||||||
|
controller__log_controller_state_to_machine()
|
||||||
|
{
|
||||||
|
local debops_controller_path="$1"
|
||||||
|
local configured_machine_fqdn="$2"
|
||||||
|
|
||||||
|
controller__log_message_to_machine "${configured_machine_fqdn}" 'info' "controller : $(whoami)@$(hostname --fqdn):${debops_controller_path}"
|
||||||
|
pushd $(controller__get_local_repos_path "$debops_controller_path") > /dev/null
|
||||||
|
local latest_commit_hash=$(git log -n 1 --pretty=format:"%H")
|
||||||
|
controller__log_message_to_machine "${configured_machine_fqdn}" 'info' "ansible.debops.git version : ${latest_commit_hash}"
|
||||||
|
popd
|
||||||
|
}
|
||||||
|
|
||||||
deboco__init()
|
deboco__init()
|
||||||
{
|
{
|
||||||
local debops_controller_path="$1"
|
local debops_controller_path="$1"
|
||||||
|
@ -372,6 +397,9 @@ deboco__configure_machine()
|
||||||
debops_controller_path=$(realpath $debops_controller_path)
|
debops_controller_path=$(realpath $debops_controller_path)
|
||||||
log 'info' "configuring $target_host_fqdn using debobs controller $debops_controller_path"
|
log 'info' "configuring $target_host_fqdn using debobs controller $debops_controller_path"
|
||||||
|
|
||||||
|
controller__log_message_to_machine "${target_host_fqdn}" 'info' "deboco__configure_machine start"
|
||||||
|
controller__log_controller_state_to_machine "${debops_controller_path}" "${target_host_fqdn}"
|
||||||
|
|
||||||
local error_code=$RETURNCODE_SUCCESS
|
local error_code=$RETURNCODE_SUCCESS
|
||||||
|
|
||||||
deboco__init_machine "$debops_controller_path" "$target_host_fqdn"
|
deboco__init_machine "$debops_controller_path" "$target_host_fqdn"
|
||||||
|
@ -381,13 +409,17 @@ deboco__configure_machine()
|
||||||
if [ $? != 0 ]
|
if [ $? != 0 ]
|
||||||
then
|
then
|
||||||
log 'error' "update_machine failed"
|
log 'error' "update_machine failed"
|
||||||
|
controller__log_message_to_machine "${target_host_fqdn}" 'error' "update_machine failed"
|
||||||
error_code=$RETURNCODE_ERROR
|
error_code=$RETURNCODE_ERROR
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
log 'error' "init_machine failed"
|
log 'error' "init_machine failed"
|
||||||
|
controller__log_message_to_machine "${target_host_fqdn}" 'error' "init_machine failed"
|
||||||
error_code=$RETURNCODE_ERROR
|
error_code=$RETURNCODE_ERROR
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
controller__log_message_to_machine "${target_host_fqdn}" 'info' "deboco__configure_machine end"
|
||||||
|
|
||||||
return "$error_code"
|
return "$error_code"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,6 +431,8 @@ deboco__init_machine()
|
||||||
debops_controller_path=$(realpath $debops_controller_path)
|
debops_controller_path=$(realpath $debops_controller_path)
|
||||||
log 'info' "installing debops bootstrap on $target_host_fqdn using debobs controller $debops_controller_path"
|
log 'info' "installing debops bootstrap on $target_host_fqdn using debobs controller $debops_controller_path"
|
||||||
|
|
||||||
|
controller__log_message_to_machine "${target_host_fqdn}" 'info' "deboco__init_machine start"
|
||||||
|
controller__log_controller_state_to_machine "${debops_controller_path}" "${target_host_fqdn}"
|
||||||
|
|
||||||
controller__check_integrity "$debops_controller_path"
|
controller__check_integrity "$debops_controller_path"
|
||||||
if [ $? != "$RETURNCODE_SUCCESS" ]
|
if [ $? != "$RETURNCODE_SUCCESS" ]
|
||||||
|
@ -432,6 +466,8 @@ deboco__init_machine()
|
||||||
fi
|
fi
|
||||||
deactivate
|
deactivate
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
controller__log_message_to_machine "${target_host_fqdn}" 'info' "deboco__init_machine end"
|
||||||
return "$error_code"
|
return "$error_code"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,6 +478,10 @@ deboco__update_machine()
|
||||||
debops_controller_path=$(realpath $debops_controller_path)
|
debops_controller_path=$(realpath $debops_controller_path)
|
||||||
log 'info' "updating $target_host_fqdn using debobs controller $debops_controller_path"
|
log 'info' "updating $target_host_fqdn using debobs controller $debops_controller_path"
|
||||||
|
|
||||||
|
controller__log_message_to_machine "${target_host_fqdn}" 'info' "deboco__update_machine start"
|
||||||
|
controller__log_controller_state_to_machine "${debops_controller_path}" "${target_host_fqdn}"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
controller__check_integrity "$debops_controller_path"
|
controller__check_integrity "$debops_controller_path"
|
||||||
if [ $? != "$RETURNCODE_SUCCESS" ]
|
if [ $? != "$RETURNCODE_SUCCESS" ]
|
||||||
|
@ -478,6 +518,9 @@ deboco__update_machine()
|
||||||
fi
|
fi
|
||||||
deactivate
|
deactivate
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
controller__log_message_to_machine "${target_host_fqdn}" 'info' "deboco__update_machine end"
|
||||||
|
|
||||||
return "$error_code"
|
return "$error_code"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue