Restart `xymon` service if configuration change
This commit is contained in:
parent
052c2fd7fe
commit
b5fa9a5d67
|
@ -4,4 +4,5 @@
|
|||
### Features
|
||||
* Install `xymon` packages for Debian based distros.
|
||||
* Manage `xymon` server configuration (/etc).
|
||||
* Ensure to restart `xymon` server service if configuration changed.
|
||||
* Ensure `xymon` server service is enabled and started.
|
||||
|
|
|
@ -18,6 +18,7 @@ Manage Xymon server installation and configuration.
|
|||
* **xymon_server__deploy_state** : The desired state this role should achieve [default : `present`].
|
||||
* **ymon_server__etc_src** : Directory used as source to templating /etc configuration content [default : `etc/xymon`].
|
||||
* **xymon_server__service_manage** : If the Xymon server service should be managed [default : `True`].
|
||||
* **xymon_server__service_name** : The service name to manage [default : `xymon`].
|
||||
|
||||
## Example Playbook
|
||||
|
||||
|
@ -35,6 +36,7 @@ This role will :
|
|||
* Install needed packages to provide `xymon` server.
|
||||
* Manage `xymon` server configuration (/etc).
|
||||
* Ensure `xymon` server service is enabled and started.
|
||||
* Ensure to restart `xymon` server service if configuration changed.
|
||||
|
||||
## Development
|
||||
|
||||
|
|
|
@ -27,6 +27,13 @@ xymon_server__base_packages:
|
|||
#
|
||||
xymon_server__deploy_state: 'present'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: xymon_server__service_name [[[
|
||||
#
|
||||
# The service name to manage.
|
||||
#
|
||||
xymon_server__service_name: 'xymon'
|
||||
|
||||
# ]]]
|
||||
# .. envvar:: xymon_server__service_manage [[[
|
||||
#
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
# handlers file for xymon_server
|
||||
- name: restart xymon server service
|
||||
service:
|
||||
name: '{{ xymon_server__service_name }}'
|
||||
state: '{{ "restarted" if (xymon_server__deploy_state == "present" and
|
||||
(xymon_server__service_manage | d(True) | bool))
|
||||
else "stopped" }}'
|
||||
enabled: '{{ xymon_server__service_manage | d(True) | bool }}'
|
||||
|
|
@ -21,6 +21,7 @@
|
|||
state: directory
|
||||
with_filetree: '{{ xymon_server__etc_src }}'
|
||||
when: item.state == 'directory'
|
||||
notify: ['restart xymon server service']
|
||||
|
||||
- name: Ensure /etc files are populated from templates
|
||||
template:
|
||||
|
@ -28,12 +29,13 @@
|
|||
dest: "/etc/xymon/{{ item.path | replace('.j2','') }}"
|
||||
with_filetree: '{{ xymon_server__etc_src }}'
|
||||
when: item.state == 'file'
|
||||
notify: ['restart xymon server service']
|
||||
|
||||
# Manage services [[[1
|
||||
# Manage service [[[1
|
||||
|
||||
- name: Manage Xymon server service
|
||||
service:
|
||||
name: 'xymon'
|
||||
name: '{{ xymon_server__service_name }}'
|
||||
state: '{{ "started" if (xymon_server__deploy_state == "present" and
|
||||
(xymon_server__service_manage | d(True) | bool))
|
||||
else "stopped" }}'
|
||||
|
|
Loading…
Reference in New Issue