From d82c908eefe225623755db81f0c9e5f22793a274 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Thu, 12 Dec 2019 13:24:59 +0100 Subject: [PATCH] Adding possibility to leave project empty --- postinstall-scripts/init-puppet | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/postinstall-scripts/init-puppet b/postinstall-scripts/init-puppet index be26765..c3defee 100755 --- a/postinstall-scripts/init-puppet +++ b/postinstall-scripts/init-puppet @@ -21,7 +21,7 @@ NORMAL="" HAS_TTY='y' HAS_COLORS="n" -VERSION="0.9" +VERSION="1.0" BASENAME="$(basename ${0})" BASE_DIR="$(dirname ${0})" @@ -183,7 +183,7 @@ usage() { -p|--project CUSTOMER_PROJECT The customer related name of the project - the next level in the Hiera structure beyond the customer name. - If not given, the Hiera customer name will be used. + If not given, it will not be set. -O|--owner OWNER The owning Customer if this host. If not given, the Hiera customer will be used. @@ -350,10 +350,6 @@ get_options() { ENVIRONMENT=$( autodetect_env ) fi - if [[ -z "${PROJECT}" ]] ; then - PROJECT="${CUSTOMER}" - fi - if [[ -z "${OWNER}" ]] ; then OWNER="${CUSTOMER}" fi @@ -619,12 +615,20 @@ generate_facts() { local yfile="${facts_dir}/customer.yaml" info "Generating '${GREEN}${yfile}${NORMAL}' ..." - local content=$( cat <<-EOF - --- - customer: ${CUSTOMER} - project: ${PROJECT} - EOF - ) + if [[ -z "${PROJECT}" ]] ; then + local content=$( cat <<-EOF + --- + customer: ${CUSTOMER} + EOF + ) + else + local content=$( cat <<-EOF + --- + customer: ${CUSTOMER} + project: ${PROJECT} + EOF + ) + fi debug "Generatet content of '${yfile}':\n${content}" echo "${content}" > "${yfile}" -- 2.39.5