]> Frank Brehm's Git Trees - pixelpark/create-terraform.git/commitdiff
Adding possibility to leave project empty
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 12 Dec 2019 12:24:59 +0000 (13:24 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 12 Dec 2019 12:24:59 +0000 (13:24 +0100)
postinstall-scripts/init-puppet

index be2676552b89e0d9358f3c2a07bd41243ffe0e59..c3defee30ecd72a8c9944fdb720be88264adc0da 100755 (executable)
@@ -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}"