ansible.xymon_server/tasks/main.yml

55 lines
1.8 KiB
YAML
Raw Permalink Normal View History

---
# .. vim: foldmarker=[[[,]]]:foldmethod=marker
#
# tasks file for ipr-cnrs.xymon_server
# Server Manage required system packages [[[1
- name: Ensure required packages are in there desired state
2024-09-04 15:36:27 +02:00
ansible.builtin.package:
2024-09-04 15:34:05 +02:00
name: '{{ xymon_server__base_packages | list }}'
state: '{{ "present" if (xymon_server__deploy_state == "present") else "absent" }}'
install_recommends: False
register: server_pkg_result
until: server_pkg_result is success
# Server Manage /etc configuration files [[[1
- name: Ensure /etc directory structure exists
2024-09-04 15:36:27 +02:00
ansible.builtin.file:
path: '/etc/xymon/{{ item.path }}'
state: directory
with_filetree: '{{ xymon_server__etc_src }}'
when: item.state == 'directory'
notify: ['restart xymon server service']
- name: Generate Xymon configuration files
2024-09-04 15:36:27 +02:00
ansible.builtin.template:
src: '{{ item.src }}'
dest: "/etc/xymon/{{ item.path | replace('.j2','') }}"
mode: '{{ item.mode }}'
with_filetree: '{{ xymon_server__etc_src }}'
when: item.state == 'file'
notify: ['restart xymon server service']
- name: Generate Xymon configuration symlinks
2024-09-04 15:36:27 +02:00
ansible.builtin.template:
src: '{{ item.src }}'
dest: "/etc/xymon/{{ item.path }}"
mode: '{{ item.mode }}'
state: 'link'
force: true
with_filetree: '{{ xymon_server__etc_src }}'
when: item.state == 'link'
notify: ['restart xymon server service']
# Manage service [[[1
- name: Manage Xymon server service
2024-09-04 15:36:27 +02:00
ansible.builtin.service:
name: '{{ xymon_server__service_name }}'
state: '{{ "started" if (xymon_server__deploy_state == "present" and
(xymon_server__service_manage | d(True) | bool))
else "stopped" }}'
2018-03-09 12:08:05 +01:00
enabled: '{{ (xymon_server__deploy_state == "present") and
(xymon_server__service_manage | d(True) | bool) }}'