Restart haproxy after configuring SSL certs
authorBen Nemec <bnemec@redhat.com>
Thu, 31 Mar 2016 21:42:11 +0000 (16:42 -0500)
committerJames Slagle <jslagle@redhat.com>
Fri, 1 Apr 2016 16:42:02 +0000 (12:42 -0400)
If a certificate expires, the user will need to update it.  However,
because we only restart services at the end of a stack-update the
new certificate doesn't take effect until after puppet has run.
This is a problem because puppet makes OpenStack calls, which will
fail if the certificate is expired.  In that case we never get to
the service restart so the stack is wedged until the user manually
restart haproxy.

This patch addresses the problem by reloading haproxy before puppet
runs.  This is done in a pre-puppet script for pacemaker after pacemaker
is maintenance mode because we need to make sure it happens after all of
the certs have been installed on the controllers, but before puppet
runs.

For non-pacemaker, haproxy is simply reloaded.

Change-Id: Id5ed05b3a20d06af8ae7a3d6f859b03399b0d77d

extraconfig/tasks/pacemaker_maintenance_mode.sh [new file with mode: 0755]
extraconfig/tasks/pre_puppet_pacemaker.yaml

diff --git a/extraconfig/tasks/pacemaker_maintenance_mode.sh b/extraconfig/tasks/pacemaker_maintenance_mode.sh
new file mode 100755 (executable)
index 0000000..ddc84ad
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash
+set -x
+
+# On initial deployment, the pacemaker service is disabled and is-active exits
+# 3 in that case, so allow this to fail gracefully.
+pacemaker_status=$(systemctl is-active pacemaker || :)
+
+if [ "$pacemaker_status" = "active" ]; then
+    pcs property set maintenance-mode=true
+fi
+
+# We need to reload haproxy in case the certificate changed because
+# puppet doesn't know the contents of the cert file.  We shouldn't
+# reload it if it wasn't already active (such as if using external
+# loadbalancer or on initial deployment).
+haproxy_status=$(systemctl is-active haproxy || :)
+if [ "$haproxy_status" = "active" ]; then
+    systemctl reload haproxy
+fi
index 2cfe92a..8254658 100644 (file)
@@ -14,13 +14,8 @@ resources:
     type: OS::Heat::SoftwareConfig
     properties:
       group: script
-      config: |
-        #!/bin/bash
-        pacemaker_status=$(systemctl is-active pacemaker)
-
-        if [ "$pacemaker_status" = "active" ]; then
-            pcs property set maintenance-mode=true
-        fi
+      config:
+        get_file: pacemaker_maintenance_mode.sh
 
   ControllerPrePuppetMaintenanceModeDeployment:
     type: OS::Heat::SoftwareDeployments