fix: add msg if verify finishes successfully

Signed-off-by: Devin Buhl <devin.kray@gmail.com>
This commit is contained in:
Devin Buhl committed 2021-09-27 12:54:41 -04:00
1 parent 8d5516a546
commit f41b0d8b1d
1 file changed
+14 -9
+14 -9
View File
@@ -34,6 +34,7 @@ main() {
verify_gpg_fp verify_gpg_fp
verify_git_repository verify_git_repository
verify_cloudflare verify_cloudflare
success
else else
# sops configuration file # sops configuration file
envsubst < "${PROJECT_DIR}/tmpl/.sops.yaml" \ envsubst < "${PROJECT_DIR}/tmpl/.sops.yaml" \
@@ -98,7 +99,7 @@ _has_envar() {
_log "ERROR" "Unset variable ${option}" _log "ERROR" "Unset variable ${option}"
exit 1 exit 1
} || { } || {
_log "DEBUG" "Found variable '${option}' with value '${!option}'" _log "INFO" "Found variable '${option}' with value '${!option}'"
} }
} }
@@ -107,10 +108,10 @@ _has_valid_ip() {
local variable_name="${2}" local variable_name="${2}"
if ! ipcalc "${ip}" | awk 'BEGIN{FS=":"; is_invalid=0} /^INVALID/ {is_invalid=1; print $1} END{exit is_invalid}' >/dev/null 2>&1; then if ! ipcalc "${ip}" | awk 'BEGIN{FS=":"; is_invalid=0} /^INVALID/ {is_invalid=1; print $1} END{exit is_invalid}' >/dev/null 2>&1; then
_log "DEBUG" "Variable '${variable_name}' has an invalid IP address '${ip}'" _log "INFO" "Variable '${variable_name}' has an invalid IP address '${ip}'"
exit 1 exit 1
else else
_log "DEBUG" "Variable '${variable_name}' has a valid IP address '${ip}'" _log "INFO" "Variable '${variable_name}' has a valid IP address '${ip}'"
fi fi
} }
@@ -122,14 +123,14 @@ verify_gpg_fp() {
_log "ERROR" "Invalid Personal GPG FP ${BOOTSTRAP_PERSONAL_KEY_FP}" _log "ERROR" "Invalid Personal GPG FP ${BOOTSTRAP_PERSONAL_KEY_FP}"
exit 1 exit 1
else else
_log "DEBUG" "Found Personal GPG Fingerprint '${BOOTSTRAP_PERSONAL_KEY_FP}'" _log "INFO" "Found Personal GPG Fingerprint '${BOOTSTRAP_PERSONAL_KEY_FP}'"
fi fi
if ! gpg --list-keys "${BOOTSTRAP_FLUX_KEY_FP}" >/dev/null 2>&1; then if ! gpg --list-keys "${BOOTSTRAP_FLUX_KEY_FP}" >/dev/null 2>&1; then
_log "ERROR" "Invalid Flux GPG FP '${BOOTSTRAP_FLUX_KEY_FP}'" _log "ERROR" "Invalid Flux GPG FP '${BOOTSTRAP_FLUX_KEY_FP}'"
exit 1 exit 1
else else
_log "DEBUG" "Found Flux GPG Fingerprint '${BOOTSTRAP_FLUX_KEY_FP}'" _log "INFO" "Found Flux GPG Fingerprint '${BOOTSTRAP_FLUX_KEY_FP}'"
fi fi
} }
@@ -195,8 +196,7 @@ verify_cloudflare() {
) )
if [[ "$(echo "${account_zone}" | jq ".success")" == "true" ]]; then if [[ "$(echo "${account_zone}" | jq ".success")" == "true" ]]; then
_log "DEBUG" "Verified Cloudflare Account and Zone information" _log "INFO" "Verified Cloudflare Account and Zone information"
exit 0
else else
errors=$(echo "${account_zone}" | jq -c ".errors") errors=$(echo "${account_zone}" | jq -c ".errors")
_log "ERROR" "Unable to get Cloudflare Account and Zone information ${errors}" _log "ERROR" "Unable to get Cloudflare Account and Zone information ${errors}"
@@ -228,11 +228,16 @@ verify_ansible_hosts() {
_log "ERROR" "Unable to SSH into host '${!var}' with username '${!node_username}'" _log "ERROR" "Unable to SSH into host '${!var}' with username '${!node_username}'"
exit 1 exit 1
else else
_log "DEBUG" "Successfully SSH'ed into host '${!var}' with username '${!node_username}'" _log "INFO" "Successfully SSH'ed into host '${!var}' with username '${!node_username}'"
fi fi
done done
} }
success() {
printf "\nAll checks pass!"
exit 0
}
generate_ansible_host_secrets() { generate_ansible_host_secrets() {
local node_id= local node_id=
local node_username= local node_username=
@@ -283,7 +288,7 @@ generate_ansible_hosts() {
} > "${PROJECT_DIR}/provision/ansible/inventory/hosts.yml" } > "${PROJECT_DIR}/provision/ansible/inventory/hosts.yml"
} }
function _log() { _log() {
local type="${1}" local type="${1}"
local msg="${2}" local msg="${2}"
printf "[%s] [%s] %s\n" "$(date -u)" "${type}" "${msg}" printf "[%s] [%s] %s\n" "$(date -u)" "${type}" "${msg}"