From 045a6456372ed09d1ab4681421f2bf65628e3207 Mon Sep 17 00:00:00 2001 From: Arthur Lutz Date: Fri, 8 Sep 2017 12:14:53 +0200 Subject: [PATCH 1/7] [sensu/client/server] add flag not disable rabbitmq configuration enable transport configuration when pillar is available --- pillar.example | 3 +++ sensu/client.sls | 10 ++++++++++ sensu/server.sls | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/pillar.example b/pillar.example index 82c897e..8c449b8 100644 --- a/pillar.example +++ b/pillar.example @@ -9,12 +9,15 @@ sensu: - timeout - name: aws-sdk version: 2.2.6 + configure_rabbitmq: true client: embedded_ruby: true nagios_plugins: true redact: - password gem_proxy: http://192.168.1.1:3128/ + configure_rabbitmq: true + configure_transport: true rabbitmq: host: 10.0.0.1 user: sensu diff --git a/sensu/client.sls b/sensu/client.sls index 2cfbe7e..475c26a 100644 --- a/sensu/client.sls +++ b/sensu/client.sls @@ -4,7 +4,12 @@ include: - sensu +{% if salt['pillar.get']('sensu:server:configure_rabbitmq', True) %} - sensu.rabbitmq_conf +{% endif %} +{% if salt['pillar.get']('sensu:transport:name') %} + - sensu.transport_conf +{% endif %} {% if grains['os_family'] == 'Windows' %} /opt/sensu/bin/sensu-client.xml: @@ -133,6 +138,11 @@ sensu-client: - enable: True - require: - file: /etc/sensu/conf.d/client.json +{% if salt['pillar.get']('sensu:server:configure_rabbitmq', True) %} - file: /etc/sensu/conf.d/rabbitmq.json +{% endif %} +{% if salt['pillar.get']('sensu:transport:name') %} + - file: /etc/sensu/conf.d/transport.json +{% endif %} - watch: - file: /etc/sensu/conf.d/* diff --git a/sensu/server.sls b/sensu/server.sls index 606c6c6..7eaee03 100644 --- a/sensu/server.sls +++ b/sensu/server.sls @@ -3,7 +3,9 @@ include: - sensu - sensu.api_conf # Some handlers need to access the API server +{% if salt['pillar.get']('sensu:server:configure_rabbitmq', True) %} - sensu.rabbitmq_conf +{% endif %} - sensu.redis_conf /etc/sensu/conf.d: @@ -102,4 +104,6 @@ sensu-server: - enable: True - require: - file: /etc/sensu/conf.d/redis.json +{% if salt['pillar.get']('sensu:server:configure_rabbitmq', True) %} - file: /etc/sensu/conf.d/rabbitmq.json +{% endif %} From c3240fc281fc0b09c800b48e891d62bf1b371b78 Mon Sep 17 00:00:00 2001 From: Arthur Lutz Date: Fri, 8 Sep 2017 12:16:35 +0200 Subject: [PATCH 2/7] [pillar.example] typo, remove unused config --- pillar.example | 1 - 1 file changed, 1 deletion(-) diff --git a/pillar.example b/pillar.example index 8c449b8..f00d9c4 100644 --- a/pillar.example +++ b/pillar.example @@ -17,7 +17,6 @@ sensu: - password gem_proxy: http://192.168.1.1:3128/ configure_rabbitmq: true - configure_transport: true rabbitmq: host: 10.0.0.1 user: sensu From 714bc774db2d83c0fb4329a4eef78965fbd76323 Mon Sep 17 00:00:00 2001 From: Arthur Lutz Date: Fri, 8 Sep 2017 13:06:16 +0200 Subject: [PATCH 3/7] [api] add switch to disable rabbitmq configuration --- sensu/api.sls | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sensu/api.sls b/sensu/api.sls index 2eecf20..5f3e8d0 100644 --- a/sensu/api.sls +++ b/sensu/api.sls @@ -1,7 +1,9 @@ include: - sensu - sensu.api_conf +{% if salt['pillar.get']('sensu:server:configure_rabbitmq', True) %} - sensu.rabbitmq_conf +{% endif %} - sensu.redis_conf sensu-api: @@ -9,9 +11,13 @@ sensu-api: - enable: True - require: - file: /etc/sensu/conf.d/api.json +{% if salt['pillar.get']('sensu:server:configure_rabbitmq', True) %} - file: /etc/sensu/conf.d/rabbitmq.json +{% endif %} - file: /etc/sensu/conf.d/redis.json - watch: - file: /etc/sensu/conf.d/api.json +{% if salt['pillar.get']('sensu:server:configure_rabbitmq', True) %} - file: /etc/sensu/conf.d/rabbitmq.json +{% endif %} - file: /etc/sensu/conf.d/redis.json From dc47d7d78288fcd0f29859263263c9b6ccce14cc Mon Sep 17 00:00:00 2001 From: Arthur Lutz Date: Fri, 8 Sep 2017 13:08:11 +0200 Subject: [PATCH 4/7] [init.sls] remove rabbitmq.json file when configure_rabbitmq is False --- sensu/init.sls | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sensu/init.sls b/sensu/init.sls index 02b0db0..19c9fd9 100644 --- a/sensu/init.sls +++ b/sensu/init.sls @@ -52,3 +52,9 @@ old sensu repository: - require_in: - pkg: sensu {% endif %} + + +{% if not salt['pillar.get']('sensu:server:configure_rabbitmq', True) %} +/etc/sensu/conf.d/rabbitmq.json: + file.absent +{% endif %} From 790297b1d4ba450d12d0248695fe1003c2663515 Mon Sep 17 00:00:00 2001 From: Arthur Lutz Date: Fri, 8 Sep 2017 15:26:29 +0200 Subject: [PATCH 5/7] [sensu/client] ship redis configuration when sensu:transport:name is redis --- sensu/client.sls | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sensu/client.sls b/sensu/client.sls index 475c26a..6c5c6fe 100644 --- a/sensu/client.sls +++ b/sensu/client.sls @@ -10,6 +10,9 @@ include: {% if salt['pillar.get']('sensu:transport:name') %} - sensu.transport_conf {% endif %} +{% if salt['pillar.get']('sensu:transport:name') == 'redis' %} + - sensu.redis_conf +{% endif %} {% if grains['os_family'] == 'Windows' %} /opt/sensu/bin/sensu-client.xml: From b0c6b77649cbd5806b135edc2f383994600a40a4 Mon Sep 17 00:00:00 2001 From: Arthur Lutz Date: Wed, 18 Oct 2017 17:51:38 +0200 Subject: [PATCH 6/7] [sensu/redis] add ability to configure redis sentinels --- pillar.example | 7 +++++++ sensu/redis_conf.sls | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pillar.example b/pillar.example index f00d9c4..6a618d8 100644 --- a/pillar.example +++ b/pillar.example @@ -21,6 +21,13 @@ sensu: host: 10.0.0.1 user: sensu password: secret + redis: + host: 10.0.0.1 + port: 6379 + reconnect_on_error: True + sentinels: + - host: localhost + port: 26379 api: password: secret ssl: diff --git a/sensu/redis_conf.sls b/sensu/redis_conf.sls index 5d0b252..e6fb078 100644 --- a/sensu/redis_conf.sls +++ b/sensu/redis_conf.sls @@ -13,4 +13,4 @@ host: {{ sensu.redis.host }} {% if sensu.redis.password is defined and sensu.redis.password is not none %}password: {{ sensu.redis.password }}{% endif %} port: {{ sensu.redis.port }} - + {% if sensu.redis.sentinels is defined and sensu.redis.sentinels is not none %}sentinels: {{ sensu.redis.sentinels }}{% endif %} From 7e9fe0564d049a16adfdca5957e8f2cc066c8801 Mon Sep 17 00:00:00 2001 From: Arthur Lutz Date: Tue, 31 Oct 2017 18:17:41 +0100 Subject: [PATCH 7/7] Add pillar roles as subscriptions --- sensu/client.sls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensu/client.sls b/sensu/client.sls index 6c5c6fe..efe1212 100644 --- a/sensu/client.sls +++ b/sensu/client.sls @@ -60,7 +60,7 @@ sensu_standalone_checks_file: client: name: {{ sensu.client.name }} address: {{ sensu.client.address }} - subscriptions: {{ sensu.client.subscriptions }} + subscriptions: {{ sensu.client.subscriptions + pillar.get('role', []) }} safe_mode: {{ sensu.client.safe_mode }} {% if sensu.client.get('keepalive') %} keepalive: {{ sensu.client.keepalive }}