Apply puppet in non-controller script in step.
authorSofer Athlan-Guyot <sathlang@redhat.com>
Tue, 14 Feb 2017 13:20:23 +0000 (14:20 +0100)
committerMarios Andreou <marios@redhat.com>
Fri, 17 Feb 2017 09:39:26 +0000 (09:39 +0000)
We want to apply a puppet manifest for the non-controller role, but we
need to apply it in stages.  By loading the proper hieradata we get the
needed step configuration.

Change-Id: I07bfeee7b7d9a9b8c2c20e5d5c9ed735d0bfc842
Closes-Bug: #1664304
(cherry picked from commit 237cd2004a2c0869d60d0e11e9dccd59e809ff90)

extraconfig/tasks/run_puppet.sh [new file with mode: 0755]
extraconfig/tasks/tripleo_upgrade_node.sh
puppet/major_upgrade_steps.j2.yaml

diff --git a/extraconfig/tasks/run_puppet.sh b/extraconfig/tasks/run_puppet.sh
new file mode 100755 (executable)
index 0000000..b7771e3
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+function run_puppet {
+    set -eux
+    local manifest="$1"
+    local role="$2"
+    local step="$3"
+    local rc=0
+
+    export FACTER_deploy_config_name="${role}Deployment_Step${step}"
+    if [ -e "/etc/puppet/hieradata/heat_config_${FACTER_deploy_config_name}.json" ]; then
+        set +e
+        puppet apply --detailed-exitcodes "${manifest}"
+        rc=$?
+        echo "puppet apply exited with exit code $rc"
+    else
+        echo "Step${step} doesn't exist for ${role}"
+    fi
+    set -e
+
+    if [ $rc -eq 2 -o $rc -eq 0 ]; then
+        set +xu
+        return 0
+    fi
+    set +xu
+    return $rc
+}
index 27ba33a..1658425 100644 (file)
@@ -44,9 +44,14 @@ if [[ -n \$NOVA_COMPUTE ]]; then
     systemctl restart openstack-ceilometer-compute
 fi
 
-# Apply puppet manifest to converge just right after the \$ROLE upgrade
-puppet apply /root/${ROLE}_puppet_config.pp
-
+# Apply puppet manifest to converge just right after the ${ROLE} upgrade
+$(declare -f run_puppet)
+for step in 1 2 3 4 5 6; do
+    if ! run_puppet /root/${ROLE}_puppet_config.pp ${ROLE} \${step}; then
+         echo "Puppet failure at step \${step}"
+         exit 1
+    fi
+done
 ENDOFCAT
 
 # ensure the permissions are OK
index 3362a01..6f2dd68 100644 (file)
@@ -79,6 +79,7 @@ resources:
                 AUTH_URL: { get_param: [EndpointMap, KeystoneAdmin, uri_no_suffix]}
                 ROLE_NAME: {{role.name}}
           - get_file: ../extraconfig/tasks/pacemaker_common_functions.sh
+          - get_file: ../extraconfig/tasks/run_puppet.sh
           - get_file: ../extraconfig/tasks/tripleo_upgrade_node.sh
 
   {{role.name}}DeliverUpgradeScriptDeployment: