Skip to content
This repository has been archived by the owner on Oct 12, 2019. It is now read-only.

Commit

Permalink
Rework configuration validation step
Browse files Browse the repository at this point in the history
As suspected the handler can only run one task. To resolve that I have created
a new handler which is notified in all the same places as the other
configuration change handlers but run first to validate before a restart is
performed.
  • Loading branch information
goetzk committed Apr 16, 2017
1 parent b2385cb commit 7fd24de
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
---
- name: restart shinken arbiter
- name: Validate configuration
# Service command can't be used as it doesn't support 'check'
command: service shinken check

- name: restart shinken arbiter
service: name=shinken-arbiter state=restarted

- name: restart shinken broker
command: service shinken check
service: name=shinken-broker state=restarted

2 changes: 2 additions & 0 deletions tasks/configure-shinken-webui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# template: src=webui-module.cfg.tmpl dest=/etc/shinken/modules/broker-webui.cfg
# owner=root group=root mode=444
# notify:
# - Validate configuration
# - restart shinken broker
# - restart shinken arbiter

Expand Down Expand Up @@ -41,6 +42,7 @@
regexp='.*[^#] modules.*'
line=" modules {{ shinken_broker_modules }}"
notify:
- Validate configuration
- restart shinken broker
- restart shinken arbiter

6 changes: 6 additions & 0 deletions tasks/configure-shinken.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
dest={{ shinken_config_contacts }}/{{ item.contact_name |mandatory }}.cfg
mode=640
notify:
- Validate configuration
- restart shinken arbiter

- name: Create configuration for services to monitor
Expand All @@ -15,6 +16,7 @@
dest={{ shinken_config_services }}/{{ item.service_description|replace(' ', '_') }}.cfg
src=services.cfg.tmpl
notify:
- Validate configuration
- restart shinken arbiter

- name: Create configuration for hosts to monitor (without services)
Expand All @@ -23,6 +25,7 @@
dest={{ shinken_config_hosts }}/{{ item.host_name }}.cfg
src=hosts.cfg.tmpl
notify:
- Validate configuration
- restart shinken arbiter

# Following Jinja magic thanks to mikecee
Expand All @@ -36,13 +39,15 @@
dest={{ shinken_config_hostgroups }}/{{ item }}.cfg
src=hostgroups.cfg.tmpl
notify:
- Validate configuration
- restart shinken arbiter

- name: Install 'all' hostgroup
template:
dest={{ shinken_config_hostgroups }}/all.cfg
src=hostgroups-all.cfg.tmpl
notify:
- Validate configuration
- restart shinken arbiter

- name: Fix path to nagios plugins directory on RedHat family
Expand All @@ -53,5 +58,6 @@
line: '$NAGIOSPLUGINSDIR$=/usr/lib64/nagios/plugins'
state: present
notify:
- Validate configuration
- restart shinken arbiter

0 comments on commit 7fd24de

Please sign in to comment.