Merge pull request #92 from thouveng/add-sensu-clustering

Add sensu clustering
diff --git a/haproxy/proxy/listen/stacklight/redis.yml b/haproxy/proxy/listen/stacklight/redis.yml
new file mode 100644
index 0000000..bd36cb4
--- /dev/null
+++ b/haproxy/proxy/listen/stacklight/redis.yml
@@ -0,0 +1,31 @@
+parameters:
+  haproxy:
+    proxy:
+      listen:
+        redis:
+          mode: tcp
+          check:
+            tcp:
+              options:
+                - send PING\r\n
+                - expect string +PONG
+                - send info\ replication\r\n
+                - expect string role:master
+                - send QUIT\r\n
+                - expect string +OK
+          binds:
+            - address: ${_param:cluster_vip_address}
+              port: ${_param:cluster_redis_port}
+          servers:
+            - name: ${_param:cluster_node01_hostname}
+              host: ${_param:cluster_node01_address}
+              port: 6379
+              params: 'check'
+            - name: ${_param:cluster_node02_hostname}
+              host: ${_param:cluster_node02_address}
+              port: 6379
+              params: 'check'
+            - name: ${_param:cluster_node03_hostname}
+              host: ${_param:cluster_node03_address}
+              port: 6379
+              params: 'check'
diff --git a/haproxy/proxy/listen/stacklight/sensu.yml b/haproxy/proxy/listen/stacklight/sensu.yml
new file mode 100644
index 0000000..33ab5bc
--- /dev/null
+++ b/haproxy/proxy/listen/stacklight/sensu.yml
@@ -0,0 +1,28 @@
+parameters:
+  haproxy:
+    proxy:
+      listen:
+        sensu:
+          mode: http
+          options:
+            - forwardfor
+            - httpchk
+            - httpclose
+            - httplog
+          balance: source
+          binds:
+            - address: ${_param:cluster_vip_address}
+              port: 4567
+          servers:
+            - name: ${_param:cluster_node01_hostname}
+              host: ${_param:cluster_node01_address}
+              port: 4567
+              params: check
+            - name: ${_param:cluster_node02_hostname}
+              host: ${_param:cluster_node02_address}
+              port: 4567
+              params: check
+            - name: ${_param:cluster_node03_hostname}
+              host: ${_param:cluster_node03_address}
+              port: 4567
+              params: check
diff --git a/heka/aggregator/output/nagios.yml b/heka/aggregator/output/nagios.yml
new file mode 100644
index 0000000..cbf7654
--- /dev/null
+++ b/heka/aggregator/output/nagios.yml
@@ -0,0 +1,2 @@
+classes:
+- service.heka.aggregator.output.nagios
diff --git a/heka/aggregator/output/sensu.yml b/heka/aggregator/output/sensu.yml
new file mode 100644
index 0000000..58a14a5
--- /dev/null
+++ b/heka/aggregator/output/sensu.yml
@@ -0,0 +1,2 @@
+classes:
+- service.heka.aggregator.output.sensu
diff --git a/rabbitmq/server/vhost/monitoring.yml b/rabbitmq/server/vhost/monitoring.yml
index 84bff97..af272b9 100644
--- a/rabbitmq/server/vhost/monitoring.yml
+++ b/rabbitmq/server/vhost/monitoring.yml
@@ -5,4 +5,4 @@
         '/monitor':
           enabled: true
           user: monitor
-          password: ${_param:rabbitmq_monitoring_password}
+          password: ${_param:rabbitmq_monitor_password}
diff --git a/reclass/storage/system/stacklight_monitor_cluster.yml b/reclass/storage/system/stacklight_monitor_cluster.yml
index 9df1a69..f95cf81 100644
--- a/reclass/storage/system/stacklight_monitor_cluster.yml
+++ b/reclass/storage/system/stacklight_monitor_cluster.yml
@@ -12,6 +12,8 @@
           classes:
           - cluster.${_param:cluster_name}.stacklight.monitor
           params:
+            redis_cluster_role: 'master'
+            rabbitmq_cluster_role: 'master'
             salt_master_host: ${_param:reclass_config_master}
             linux_system_codename: xenial
             single_address: ${_param:stacklight_monitor_node01_address}
@@ -22,6 +24,8 @@
           classes:
           - cluster.${_param:cluster_name}.stacklight.monitor
           params:
+            redis_cluster_role: 'slave'
+            rabbitmq_cluster_role: 'slave'
             salt_master_host: ${_param:reclass_config_master}
             linux_system_codename: xenial
             single_address: ${_param:stacklight_monitor_node02_address}
@@ -32,6 +36,8 @@
           classes:
           - cluster.${_param:cluster_name}.stacklight.monitor
           params:
+            redis_cluster_role: 'slave'
+            rabbitmq_cluster_role: 'slave'
             salt_master_host: ${_param:reclass_config_master}
             linux_system_codename: xenial
             single_address: ${_param:stacklight_monitor_node03_address}
diff --git a/reclass/storage/system/stacklight_server_cluster.yml b/reclass/storage/system/stacklight_server_cluster.yml
index edb7a94..e6bccec 100644
--- a/reclass/storage/system/stacklight_server_cluster.yml
+++ b/reclass/storage/system/stacklight_server_cluster.yml
@@ -15,6 +15,8 @@
           - system.grafana.client.single
           - system.kibana.client.single
           params:
+            redis_cluster_role: 'master'
+            rabbitmq_cluster_role: 'master'
             salt_master_host: ${_param:reclass_config_master}
             linux_system_codename: xenial
             single_address: ${_param:stacklight_monitor_node01_address}
@@ -25,6 +27,8 @@
           classes:
           - cluster.${_param:cluster_name}.stacklight.server
           params:
+            redis_cluster_role: 'slave'
+            rabbitmq_cluster_role: 'slave'
             salt_master_host: ${_param:reclass_config_master}
             linux_system_codename: xenial
             single_address: ${_param:stacklight_monitor_node02_address}
@@ -35,6 +39,8 @@
           classes:
           - cluster.${_param:cluster_name}.stacklight.server
           params:
+            redis_cluster_role: 'slave'
+            rabbitmq_cluster_role: 'slave'
             salt_master_host: ${_param:reclass_config_master}
             linux_system_codename: xenial
             single_address: ${_param:stacklight_monitor_node03_address}
diff --git a/sensu/client/stacklight.yml b/sensu/client/stacklight.yml
new file mode 100644
index 0000000..b41ee77
--- /dev/null
+++ b/sensu/client/stacklight.yml
@@ -0,0 +1,8 @@
+classes:
+- service.sensu.client
+parameters:
+  _param:
+    sensu_message_queue_host: ${_param:stacklight_monitor_address}
+  sensu:
+    client:
+      metric_handlers: []
diff --git a/sensu/server/cluster.yml b/sensu/server/cluster.yml
new file mode 100644
index 0000000..28eb78b
--- /dev/null
+++ b/sensu/server/cluster.yml
@@ -0,0 +1,31 @@
+classes:
+- service.git.client
+- service.redis.server.single
+- service.rabbitmq.server.cluster
+- system.rabbitmq.server.vhost.monitoring
+- service.sensu.server.single
+parameters:
+  _param:
+    rabbitmq_secret_key: secret
+    rabbitmq_admin_password: password
+    rabbitmq_cold_password: password
+    rabbitmq_monitor_password: password
+    sensu_message_queue_host: ${_param:cluster_vip_address}
+  rabbitmq:
+    cluster:
+      name: 'monitoring'
+  redis:
+    server:
+      version: 3.0
+      bind:
+        address: ${_param:single_address}
+    cluster:
+      enabled: True
+      mode: sentinel
+      role: ${_param:redis_cluster_role}
+      quorum: 2
+      master:
+        host: ${_param:cluster_node01_address}
+        port: 6379
+      sentinel:
+        address: ${_param:single_address}