ansible-role-icinga2/tasks/config.yml

131 lines
3 KiB
YAML
Raw Normal View History

2021-01-03 15:10:04 +00:00
---
- name: remove old config files
2021-08-15 16:15:12 +00:00
ansible.builtin.file:
2021-01-03 15:10:04 +00:00
path: /etc/icinga2/conf.d/apt.conf
state: absent
notify: reload icinga2
tags: icinga2
2021-08-15 16:42:01 +00:00
- name: copy scripts
ansible.builtin.copy:
content: '{{ item.value }}'
dest: '/etc/icinga2/scripts/{{ item.key }}'
owner: root
group: nagios
mode: 0750
2022-11-09 13:11:22 +00:00
loop: '{{ icinga2_scripts | dict2items }}'
2021-08-15 16:42:01 +00:00
loop_control:
label: '{{ item.key }}'
tags: icinga2
2021-01-03 15:10:04 +00:00
- name: copy config files
2021-08-15 16:15:12 +00:00
ansible.builtin.template:
2021-01-03 15:10:04 +00:00
src: '{{ item }}.conf.j2'
dest: '/etc/icinga2/conf.d/{{ item }}.conf'
owner: root
group: nagios
mode: 0640
loop:
- check_commands
2021-08-15 16:42:01 +00:00
- commands
2022-11-09 13:11:22 +00:00
- dependencies
2021-01-03 15:10:04 +00:00
- groups
- hosts
- notifications
- services
- templates
- timeperiods
- users
notify: reload icinga2
tags: icinga2
- name: copy zones config files
2021-08-15 16:15:12 +00:00
ansible.builtin.template:
2021-01-03 15:10:04 +00:00
src: zones.conf.j2
dest: /etc/icinga2/zones.conf
owner: root
group: nagios
mode: 0640
notify: reload icinga2
tags: icinga2
- name: copy ido config file
2021-08-15 16:15:12 +00:00
ansible.builtin.template:
2021-01-03 15:10:04 +00:00
src: ido-db.conf.j2
dest: /etc/icinga2/conf.d/ido-db.conf
owner: root
group: nagios
mode: 0640
notify: restart icinga2
tags: icinga2
- name: copy api SSL key
2021-08-15 16:15:12 +00:00
ansible.builtin.copy:
2021-01-03 15:10:04 +00:00
content: '{{ icinga2_api_ssl_node_key }}'
dest: '/var/lib/icinga2/certs/{{ inventory_hostname }}.key'
owner: root
group: nagios
mode: 0640
when: '"api" in icinga2_features'
notify: restart icinga2
tags: icinga2
- name: copy api SSL certificate
2021-08-15 16:15:12 +00:00
ansible.builtin.copy:
2021-01-03 15:10:04 +00:00
content: '{{ icinga2_api_ssl_node_crt }}'
dest: '/var/lib/icinga2/certs/{{ inventory_hostname }}.crt'
owner: root
group: nagios
mode: 0640
when: '"api" in icinga2_features'
notify: restart icinga2
tags: icinga2
- name: copy api SSL ca certifiacte
2021-08-15 16:15:12 +00:00
ansible.builtin.copy:
2021-01-03 15:10:04 +00:00
content: '{{ icinga2_api_ssl_ca_crt }}'
dest: '{{ item }}/ca.crt'
owner: root
group: nagios
mode: 0640
when: '"api" in icinga2_features'
loop:
- /var/lib/icinga2/certs
- /etc/icinga2/pki
notify: restart icinga2
tags: icinga2
- name: copy api SSL ca key
2021-08-15 16:15:12 +00:00
ansible.builtin.copy:
2021-01-03 15:10:04 +00:00
content: '{{ icinga2_api_ssl_ca_key }}'
dest: /etc/icinga2/pki/ca.key
owner: root
group: nagios
mode: 0640
when: '"api" in icinga2_features and icinga2_master'
notify: restart icinga2
tags: icinga2
- name: copy feature config files
2021-08-15 16:15:12 +00:00
ansible.builtin.template:
2021-01-03 15:10:04 +00:00
src: feature.conf.j2
dest: '/etc/icinga2/features-available/{{ item.key }}.conf'
owner: root
group: nagios
mode: 0640
2022-11-09 13:11:22 +00:00
loop: '{{ icinga2_features | dict2items }}'
2021-01-03 15:10:04 +00:00
loop_control:
label: '{{ item.key }}'
notify: restart icinga2
tags: icinga2
- name: manage features
2021-08-15 16:15:12 +00:00
community.general.icinga2_feature:
2021-01-03 15:10:04 +00:00
name: '{{ item.key }}'
2022-11-09 13:11:22 +00:00
state: '{{ item.state | default("present") }}'
loop: '{{ icinga2_features | dict2items }}'
2021-01-03 15:10:04 +00:00
loop_control:
label: '{{ item.key }}'
notify: restart icinga2
tags: icinga2