ansible-role-icinga2/tasks/config.yml

131 lines
3 KiB
YAML
Raw Normal View History

2021-01-03 15:10:04 +00:00
---
2024-05-07 20:39:05 +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
2024-05-07 20:39:05 +00:00
notify: Reload icinga2
2021-01-03 15:10:04 +00:00
tags: icinga2
2024-05-07 20:39:05 +00:00
- name: Copy scripts
2021-08-15 16:42:01 +00:00
ansible.builtin.copy:
2024-05-07 20:39:05 +00:00
content: "{{ item.value }}"
dest: "/etc/icinga2/scripts/{{ item.key }}"
2021-08-15 16:42:01 +00:00
owner: root
group: nagios
2024-05-07 20:39:05 +00:00
mode: "0750"
loop: "{{ icinga2_scripts | dict2items }}"
2021-08-15 16:42:01 +00:00
loop_control:
2024-05-07 20:39:05 +00:00
label: "{{ item.key }}"
2021-08-15 16:42:01 +00:00
tags: icinga2
2024-05-07 20:39:05 +00:00
- name: Copy config files
2021-08-15 16:15:12 +00:00
ansible.builtin.template:
2024-05-07 20:39:05 +00:00
src: "{{ item }}.conf.j2"
dest: "/etc/icinga2/conf.d/{{ item }}.conf"
2021-01-03 15:10:04 +00:00
owner: root
group: nagios
2024-05-07 20:39:05 +00:00
mode: "0640"
2021-01-03 15:10:04 +00:00
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
2024-05-07 20:39:05 +00:00
notify: Reload icinga2
2021-01-03 15:10:04 +00:00
tags: icinga2
2024-05-07 20:39:05 +00:00
- 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
2024-05-07 20:39:05 +00:00
mode: "0640"
notify: Reload icinga2
2021-01-03 15:10:04 +00:00
tags: icinga2
2024-05-07 20:39:05 +00:00
- 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
2024-05-07 20:39:05 +00:00
mode: "0640"
notify: Restart icinga2
2021-01-03 15:10:04 +00:00
tags: icinga2
2024-05-07 20:39:05 +00:00
- name: Copy api SSL key
2021-08-15 16:15:12 +00:00
ansible.builtin.copy:
2024-05-07 20:39:05 +00:00
content: "{{ icinga2_api_ssl_node_key }}"
dest: "/var/lib/icinga2/certs/{{ inventory_hostname }}.key"
2021-01-03 15:10:04 +00:00
owner: root
group: nagios
2024-05-07 20:39:05 +00:00
mode: "0640"
when: "'api' in icinga2_features"
notify: Restart icinga2
2021-01-03 15:10:04 +00:00
tags: icinga2
2024-05-07 20:39:05 +00:00
- name: Copy api SSL certificate
2021-08-15 16:15:12 +00:00
ansible.builtin.copy:
2024-05-07 20:39:05 +00:00
content: "{{ icinga2_api_ssl_node_crt }}"
dest: "/var/lib/icinga2/certs/{{ inventory_hostname }}.crt"
2021-01-03 15:10:04 +00:00
owner: root
group: nagios
2024-05-07 20:39:05 +00:00
mode: "0640"
when: "'api' in icinga2_features"
notify: Restart icinga2
2021-01-03 15:10:04 +00:00
tags: icinga2
2024-05-07 20:39:05 +00:00
- name: Copy api SSL ca certifiacte
2021-08-15 16:15:12 +00:00
ansible.builtin.copy:
2024-05-07 20:39:05 +00:00
content: "{{ icinga2_api_ssl_ca_crt }}"
dest: "{{ item }}/ca.crt"
2021-01-03 15:10:04 +00:00
owner: root
group: nagios
2024-05-07 20:39:05 +00:00
mode: "0640"
when: "'api' in icinga2_features"
2021-01-03 15:10:04 +00:00
loop:
- /var/lib/icinga2/certs
- /etc/icinga2/pki
2024-05-07 20:39:05 +00:00
notify: Restart icinga2
2021-01-03 15:10:04 +00:00
tags: icinga2
2024-05-07 20:39:05 +00:00
- name: Copy api SSL ca key
2021-08-15 16:15:12 +00:00
ansible.builtin.copy:
2024-05-07 20:39:05 +00:00
content: "{{ icinga2_api_ssl_ca_key }}"
2021-01-03 15:10:04 +00:00
dest: /etc/icinga2/pki/ca.key
owner: root
group: nagios
2024-05-07 20:39:05 +00:00
mode: "0640"
when: "'api' in icinga2_features and icinga2_master"
notify: Restart icinga2
2021-01-03 15:10:04 +00:00
tags: icinga2
2024-05-07 20:39:05 +00:00
- 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
2024-05-07 20:39:05 +00:00
dest: "/etc/icinga2/features-available/{{ item.key }}.conf"
2021-01-03 15:10:04 +00:00
owner: root
group: nagios
2024-05-07 20:39:05 +00:00
mode: "0640"
loop: "{{ icinga2_features | dict2items }}"
2021-01-03 15:10:04 +00:00
loop_control:
2024-05-07 20:39:05 +00:00
label: "{{ item.key }}"
notify: Restart icinga2
2021-01-03 15:10:04 +00:00
tags: icinga2
2024-05-07 20:39:05 +00:00
- name: Manage features
2021-08-15 16:15:12 +00:00
community.general.icinga2_feature:
2024-05-07 20:39:05 +00:00
name: "{{ item.key }}"
state: "{{ item.state | default('present') }}"
loop: "{{ icinga2_features | dict2items }}"
2021-01-03 15:10:04 +00:00
loop_control:
2024-05-07 20:39:05 +00:00
label: "{{ item.key }}"
notify: Restart icinga2
2021-01-03 15:10:04 +00:00
tags: icinga2