]> Frank Brehm's Git Trees - pixelpark/create-terraform.git/commitdiff
Evaluate the puppet_initial_install flag for each VM
authorFrank Brehm <frank@brehm-online.com>
Tue, 19 Jul 2022 12:26:09 +0000 (14:26 +0200)
committerFrank Brehm <frank@brehm-online.com>
Tue, 19 Jul 2022 12:26:09 +0000 (14:26 +0200)
lib/cr_tf/handler.py
lib/cr_tf/terraform/vm.py
postinstall-scripts/init-puppet

index fa7631598e76519b15c10a33c3329ce272f2b3ec..f2e16f802017227421adab95611badb59632a774 100644 (file)
@@ -64,7 +64,7 @@ from .terraform.disk import TerraformDisk
 
 from .xlate import XLATOR
 
-__version__ = '3.7.2'
+__version__ = '3.7.3'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -2778,6 +2778,8 @@ class CreateTerraformHandler(BaseHandler):
                 cmd += "--project '{pr}' "
             cmd += "--role '{r}' --owner '{o}' --tier '{t}' --purpose '{p}' --email '{m}'"
             cmd += " --zone '{z}'"
+            if vm.puppet_initial_install:
+                cmd += " --initial-install"
             cmd = cmd.format(
                 p=purpose, t=vm.puppet_tier, o=vm.customer, c=vm.puppet_customer, z=zone,
                 pr=vm.puppet_project, m=vm.puppet_contact, e=vm.puppet_env, r=vm.puppet_role)
index efb831ad69e6b87d388435aa5482578bd0aeb4d1..2a0c6d6e55d2ed4816fd7519f90d18c2b37c6ffb 100644 (file)
@@ -37,7 +37,7 @@ from .disk import TerraformDisk, TerraformDiskDict
 
 from .interface import TerraformInterface
 
-__version__ = '1.6.0'
+__version__ = '1.6.1'
 
 LOG = logging.getLogger(__name__)
 
@@ -154,7 +154,7 @@ class TerraformVm(HandlingObject):
             cluster=None, boot_delay=None, ds_cluster=None, datastore=None, ds_type=None,
             customer=None, rootdisk_size=None, purpose=None, puppet_contact=None, puppet_role=None,
             puppet_customer=None, puppet_project=None, puppet_tier=None, puppet_env=None,
-            puppet_initial_install=False, vm_template=None, nameservers=None, searchdomains=None,
+            puppet_initial_install=True, vm_template=None, nameservers=None, searchdomains=None,
             dns_options=None, has_backup=True, has_puppet=True, already_existing=None,
             vsphere=None):
 
index 788e3071b3112b944b50fa039b408ee11ae4d370..f7aa951f829176bfb1f053da0434024404563317 100755 (executable)
@@ -21,7 +21,7 @@ NORMAL=""
 HAS_TTY='y'
 HAS_COLORS="n"
 
-VERSION="1.4"
+VERSION="1.5"
 
 BASENAME="$(basename ${0})"
 BASE_DIR="$(dirname ${0})"
@@ -42,6 +42,7 @@ PUPPET_BIN="/opt/puppetlabs/bin/puppet"
 PKG_INSTALLED="n"
 ROLE="base_oel7"
 PROJECT=
+INITIAL_INSTALL="n"
 
 PUPPET_SERVER="puppetmaster.pixelpark.com"
 PUPPET_CA_SERVER="puppetca01.pixelpark.com"
@@ -162,7 +163,7 @@ RM() {
 #------------------------------------------------------------------------------
 description() {
     cat <<-EOF
-       Initialize a Puppet5 agent and start it.
+       Initialize a Puppet agent and start it.
 
        This script works only for Red Hat Linux and its derivates.
 
@@ -194,6 +195,9 @@ usage() {
                -T|--tier TIER  The tier of the production state. If not given,
                                the Puppet environment will be used.
                -R|--role ROLE  The Puppet role of the host,  Default: '${ROLE}'.
+               -I|--initial-install
+                               Set the custom fact initial_install for the first execution
+                               of a Puppet agent run after deploying the VM.
                -P|--purpose PURPOSE
                                The purpose of the host, Default: '${PURPOSE}'.
                -M|--email MAIL_ADDRESS
@@ -242,9 +246,9 @@ get_options() {
 
     local tmp=
     local base_dir=
-    local short_options="E:C:p:O:T:R:P:M:l:z:dvqhV"
+    local short_options="E:C:p:O:T:R:IP:M:l:z:dvqhV"
     local long_options="env:,environment:,customer:,hiera-customer:,project:,owner:,tier:,role:,"
-    long_options+="purpose:,server:,ca-server:,email:,location:,zone:,"
+    long_options+="initial-install,purpose:,server:,ca-server:,email:,location:,zone:,"
     long_options+="debug,verbose,quiet,help,version"
 
     set +e
@@ -293,6 +297,10 @@ get_options() {
                 shift
                 shift
                 ;;
+            -I|--initial-install)
+                INITIAL_INSTALL="y"
+                shift
+                ;;
             -P|--purpose)
                 PURPOSE="$2"
                 shift
@@ -726,15 +734,17 @@ generate_facts() {
     debug "Generatet content of '${yfile}':\n${content}"
     echo "${content}" > "${yfile}"
 
-    yfile="${facts_dir}/initial_install.yaml"
-    info "Generating '${GREEN}${yfile}${NORMAL}' ..."
-    content=$( cat <<-EOF
-               ---
-               initial_install: true
-               EOF
-    )
-    debug "Generatet content of '${yfile}':\n${content}"
-    echo "${content}" > "${yfile}"
+    if [[ "${INITIAL_INSTALL}" ]] ; then
+        yfile="${facts_dir}/initial_install.yaml"
+        info "Generating '${GREEN}${yfile}${NORMAL}' ..."
+        content=$( cat <<-EOF
+                       ---
+                       initial_install: true
+                       EOF
+        )
+        debug "Generatet content of '${yfile}':\n${content}"
+        echo "${content}" > "${yfile}"
+    fi
 
     wrong_file="${facts_dir}/host"
     if [[ -r "${wrong_file}" ]] ; then