Reload HAProxy on refresh
authorJuan Antonio Osorio Robles <jaosorior@redhat.com>
Tue, 23 Aug 2016 08:37:28 +0000 (11:37 +0300)
committerJuan Antonio Osorio Robles <jaosorior@redhat.com>
Mon, 29 Aug 2016 13:59:18 +0000 (16:59 +0300)
If the configuration for the HAProxy class or any of the frontend
endpoints has changed, we explicitly execute a reload on HA setups.
This is useful since on updates of HA setups we set pacemaker on
maintenance mode, and thus we are unable to refresh HAProxy's
configuration; The aforementioned detail is problematic, since some
puppet configurations rely on HAProxy taking into account the
configuration.  An example of this is changing a port in the endpoint
map or enabling SSL.

Change-Id: I7f26257fb43146afebca928f5498ee2174178063

manifests/profile/base/haproxy.pp

index 4f2f850..68ff3e4 100644 (file)
@@ -82,6 +82,20 @@ class tripleo::profile::base::haproxy (
       }
 
       include ::tripleo::haproxy
+
+      unless hiera('tripleo::haproxy::haproxy_service_manage', true) {
+        # Reload HAProxy configuration if the haproxy class has refreshed or any
+        # HAProxy frontend endpoint has changed.
+        exec { 'haproxy-reload':
+          command     => 'systemctl reload haproxy',
+          path        => ['/usr/bin', '/usr/sbin'],
+          refreshonly => true,
+          onlyif      => 'pcs property | grep -q "maintenance-mode.*true"',
+          subscribe   => Class['::haproxy']
+        }
+        Haproxy::Listen<||> ~> Exec['haproxy-reload']
+        Haproxy::Balancermember<||> ~> Exec['haproxy-reload']
+      }
     }
   }