2025-01-11 12:44:28 +01:00
|
|
|
---
|
|
|
|
|
2025-01-24 23:42:30 +01:00
|
|
|
- name: Allow icinga2 to/from Agent, and needed ports for some checks
|
2025-01-12 11:02:58 +01:00
|
|
|
become: true
|
2025-01-14 11:07:46 +01:00
|
|
|
ansible.builtin.template:
|
2025-01-19 19:23:40 +01:00
|
|
|
src: "nftables/{{ item }}.d/icinga2.conf.j2"
|
|
|
|
dest: "/etc/nftables/{{ item }}.d/icinga2.conf"
|
2025-01-12 11:02:58 +01:00
|
|
|
mode: 0640
|
2025-01-19 19:23:40 +01:00
|
|
|
loop:
|
|
|
|
- input
|
|
|
|
- output
|
2025-01-12 11:02:58 +01:00
|
|
|
notify: Reload nftables service
|
|
|
|
|
2025-01-14 11:25:27 +01:00
|
|
|
- name: Add Icinga2 Agent to /etc/hosts
|
|
|
|
become: true
|
|
|
|
ansible.builtin.lineinfile:
|
|
|
|
path: /etc/hosts
|
2025-01-24 10:14:47 +01:00
|
|
|
line: "{{ hostvars[icinga2_agent].ipv4_addr }}\t{{ icinga2_agent }}"
|
2025-01-14 11:25:27 +01:00
|
|
|
|
2025-01-12 10:32:24 +01:00
|
|
|
- name: Setup Master node
|
|
|
|
become: true
|
|
|
|
ansible.builtin.command:
|
|
|
|
cmd: "icinga2 node setup --master --cn {{ ansible_hostname }} --disable-confd"
|
|
|
|
creates: "/var/lib/icinga2/certs/{{ ansible_hostname }}.crt"
|
|
|
|
notify: Restart icinga2 service
|
2025-01-14 13:08:24 +01:00
|
|
|
|
2025-01-16 22:23:32 +01:00
|
|
|
- name: Copy zones.conf file
|
|
|
|
become: true
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: zones.conf.j2
|
|
|
|
dest: /etc/icinga2/zones.conf
|
|
|
|
owner: nagios
|
|
|
|
group: nagios
|
|
|
|
mode: 0644
|
|
|
|
notify: Reload icinga2 service
|
|
|
|
|
2025-01-14 13:08:24 +01:00
|
|
|
- name: Create master zone directory
|
|
|
|
become: true
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: /etc/icinga2/zones.d/master
|
|
|
|
state: directory
|
|
|
|
owner: nagios
|
|
|
|
group: nagios
|
|
|
|
mode: 0750
|
2025-01-16 22:45:11 +01:00
|
|
|
|
|
|
|
- name: Copy files under master zone directory
|
|
|
|
become: true
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: "{{ item }}"
|
|
|
|
dest: "/etc/icinga2/zones.d/master/{{ item | basename | replace('.j2', '') }}"
|
|
|
|
owner: nagios
|
|
|
|
group: nagios
|
|
|
|
mode: 0644
|
|
|
|
with_fileglob:
|
2025-01-17 22:43:08 +01:00
|
|
|
- "{{ role_path }}/templates/zones.d/master/*"
|
2025-01-16 22:45:11 +01:00
|
|
|
notify: Reload icinga2 service
|
2025-01-19 22:02:12 +01:00
|
|
|
|
|
|
|
- name: Install bsd-mailx for sending mail notifications
|
|
|
|
become: true
|
|
|
|
ansible.builtin.apt:
|
|
|
|
name: bsd-mailx
|
2025-01-24 23:22:05 +01:00
|
|
|
|
|
|
|
- name: Copy get_service_states.sh script
|
|
|
|
become: true
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: get_service_states.sh.j2
|
|
|
|
dest: /usr/local/bin/get_service_states.sh
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0700
|