enable galera clustercheck by default

Depends on:
- https://github.com/salt-formulas/salt-formula-galera/pull/30
- https://github.com/salt-formulas/salt-formula-haproxy/pull/36
- https://github.com/epcim/percona-clustercheck

Note: Haproxy clustercheck option is not enabled/forced by default,
to enable load haproxy.proxy.listen.openstack.galera.clustercheck

To release/upgrade notes:
- require corresponding reclass system-level and salt-formula-galera
- available_when_donor clustercheck option might be required to be
  - set to 1 during deployment
  - set to 1 during manual cluster bootstrap
- deploy first galera state w/clustercheck service, then haproxy state

Change-Id: I1f0bf89714297f528e597b08498df386dade6843
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 4fd75aa..35dcda3 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,6 +1,8 @@
 Changelog
 ==========
 
+* 2017-05-22 Petr Michalec <pmichalec@mirantis.com}
+- enable galera cluster check script for haproxy, require salt-formula-galera >= MCP 1.1
 
 * 2017-03-03 Tomáš Kukrál <tkukral@mirantis.com}
 - change default Salt-API port to 6969
diff --git a/galera/server/cluster.yml b/galera/server/cluster.yml
index f1c3a48..1ab0aae 100644
--- a/galera/server/cluster.yml
+++ b/galera/server/cluster.yml
@@ -1,4 +1,20 @@
 classes:
 - service.keepalived.cluster.single
 - service.haproxy.proxy.single
-- system.haproxy.proxy.listen.openstack.galera
\ No newline at end of file
+- system.haproxy.proxy.listen.openstack.galera
+parameters:
+  galera:
+    clustercheck:
+      enabled: True
+      user: clustercheck
+      password: clustercheck
+      port: 9200
+      available_when_donor: 0
+      available_when_readonly: 0
+  mysql:
+    server:
+      users:
+      - name: clustercheck
+        password: clustercheck
+        database: '*.*'
+        grants: PROCESS
diff --git a/haproxy/proxy/listen/openstack/galera/clustercheck.yml b/haproxy/proxy/listen/openstack/galera/clustercheck.yml
new file mode 100644
index 0000000..f09e404
--- /dev/null
+++ b/haproxy/proxy/listen/openstack/galera/clustercheck.yml
@@ -0,0 +1,12 @@
+parameters:
+  _param:
+    haproxy_params_check: 'check port 9200'
+  haproxy:
+    proxy:
+      listen:
+        mysql_cluster:
+          # mysql clustercheck service at port 9200 is in conflict
+          # with regular haproxy mysql-check option on port 3306
+          health-check:
+            mysql:
+              enabled: False
diff --git a/haproxy/proxy/listen/openstack/galera.yml b/haproxy/proxy/listen/openstack/galera/init.yml
similarity index 67%
rename from haproxy/proxy/listen/openstack/galera.yml
rename to haproxy/proxy/listen/openstack/galera/init.yml
index 7298cfc..c9bd41c 100644
--- a/haproxy/proxy/listen/openstack/galera.yml
+++ b/haproxy/proxy/listen/openstack/galera/init.yml
@@ -1,4 +1,6 @@
 parameters:
+  _param:
+    haproxy_params_check: 'check'
   haproxy:
     proxy:
       timeout:
@@ -19,12 +21,12 @@
           - name: ${_param:cluster_node01_hostname}
             host: ${_param:cluster_node01_address}
             port: 3306
-            params: check inter 20s fastinter 2s downinter 2s rise 3 fall 3
+            params: ${_param:haproxy_params_check} inter 20s fastinter 2s downinter 2s rise 3 fall 3
           - name: ${_param:cluster_node02_hostname}
             host: ${_param:cluster_node02_address}
             port: 3306
-            params: backup check inter 20s fastinter 2s downinter 2s rise 3 fall 3
+            params: backup ${_param:haproxy_params_check} inter 20s fastinter 2s downinter 2s rise 3 fall 3
           - name: ${_param:cluster_node03_hostname}
             host: ${_param:cluster_node03_address}
             port: 3306
-            params: backup check inter 20s fastinter 2s downinter 2s rise 3 fall 3
+            params: backup ${_param:haproxy_params_check} inter 20s fastinter 2s downinter 2s rise 3 fall 3