_err "No host, user and pass found.. If this is the first time deploying please set PANOS_HOST, PANOS_USER and PANOS_PASS in environment variables. Delete them after you have succesfully deployed certs."
return1
else
_debug "Using saved env variables."
fi
# Environment Checks
# PANOS_HOST
if["$PANOS_HOST"];then
_debug "Detected ENV variable PANOS_HOST. Saving to file."
_savedeployconf PANOS_HOST "$PANOS_HOST"1
else
_debug "Detected ENV variables to be saved to the deploy conf."
# Encrypt and save user
_debug "Attempting to load variable PANOS_HOST from file."
_getdeployconf PANOS_HOST
fi
# PANOS USER
if["$PANOS_USER"];then
_debug "Detected ENV variable PANOS_USER. Saving to file."
_savedeployconf PANOS_USER "$PANOS_USER"1
else
_debug "Attempting to load variable PANOS_USER from file."
_getdeployconf PANOS_USER
fi
# PANOS_KEY
if["$PANOS_PASS"];then
_debug "Detected ENV variable PANOS_PASS. Saving to file."
_savedeployconf PANOS_PASS "$PANOS_PASS"1
_savedeployconf PANOS_HOST "$PANOS_HOST"1
_panos_user="$PANOS_USER"
_panos_pass="$PANOS_PASS"
_panos_host="$PANOS_HOST"
if["$PANOS_KEY"];then
_savedeployconf PANOS_KEY "$PANOS_KEY"1
_panos_key="$PANOS_KEY"
else
_getdeployconf PANOS_KEY
_panos_key=$PANOS_KEY
fi
else
_debug "Attempting to load variable PANOS_PASS from file."
_getdeployconf PANOS_PASS
fi
_debug "Let's use username and pass to generate token."
_err "No user and pass OR valid API key found.. If this is the first time deploying please set PANOS_USER and PANOS_PASS -- AND/OR -- PANOS_KEY in environment variables. Delete them after you have succesfully deployed certs."
return1
else
# Generate a new API key if no valid API key is found
if[ -z "$_panos_key"];then
_debug "**** Generating new PANOS API KEY ****"
deployer keygen
@ -172,7 +208,7 @@ panos_deploy() {
# Confirm that a valid key was generated
if[ -z "$_panos_key"];then
_err "Missing apikey."
_err "Unable to generate an API key. The user and pass may be invalid or not authorized to generate a new key. Please check the credentials and try again"