life-noc/ansible/roles/life_noc/tasks/main.yml

192 lines
4.9 KiB
YAML
Raw Normal View History

2026-03-13 23:40:05 -04:00
---
2026-03-13 16:13:37 -04:00
- name: install minimal dependencies
2026-03-13 23:40:05 -04:00
ansible.builtin.apt:
2026-03-13 16:13:37 -04:00
name:
- python3
- python3-yaml
state: present
2026-03-13 23:40:05 -04:00
update_cache: true
- name: remove legacy life-noc subdirectory under icinga conf.d
ansible.builtin.file:
path: /etc/icinga2/conf.d/life-noc
state: absent
notify:
- validate icinga
- reload icinga
- name: find previously deployed flattened life-noc config files
ansible.builtin.find:
paths: /etc/icinga2/conf.d
patterns: "life-noc-*"
file_type: file
register: life_noc_flattened_files
- name: remove previously deployed flattened life-noc config files
ansible.builtin.file:
path: "{{ item.path }}"
state: absent
loop: "{{ life_noc_flattened_files.files }}"
notify:
- validate icinga
- reload icinga
2026-03-13 16:13:37 -04:00
- name: create project root
ansible.builtin.file:
path: "{{ life_noc_project_root }}"
state: directory
2026-03-13 23:40:05 -04:00
owner: root
group: root
2026-03-13 16:13:37 -04:00
mode: "0755"
- name: copy project files
ansible.builtin.copy:
src: "{{ playbook_dir }}/../"
dest: "{{ life_noc_project_root }}/"
owner: root
group: root
2026-03-13 23:40:05 -04:00
mode: preserve
2026-03-13 16:13:37 -04:00
- name: generate icinga services from domains
2026-03-13 23:40:05 -04:00
ansible.builtin.command:
cmd: python3 scripts/generate_services.py
2026-03-13 16:13:37 -04:00
chdir: "{{ life_noc_project_root }}"
2026-03-13 23:40:05 -04:00
changed_when: true
2026-03-13 16:13:37 -04:00
- name: generate bpm from domains
2026-03-13 23:40:05 -04:00
ansible.builtin.command:
cmd: python3 scripts/generate_bpm.py
2026-03-13 16:13:37 -04:00
chdir: "{{ life_noc_project_root }}"
2026-03-13 23:40:05 -04:00
changed_when: true
##################################
- name: find life-noc command files on target
ansible.builtin.find:
paths: "{{ life_noc_project_root }}/icinga/commands"
patterns: "*.conf"
file_type: file
register: life_noc_command_files
2026-03-13 16:13:37 -04:00
2026-03-13 23:40:05 -04:00
- name: deploy life-noc command files into icinga conf.d
2026-03-13 16:13:37 -04:00
ansible.builtin.copy:
2026-03-13 23:40:05 -04:00
src: "{{ item.path }}"
dest: "/etc/icinga2/conf.d/life-noc-command-{{ item.path | basename }}"
2026-03-13 16:13:37 -04:00
remote_src: true
owner: root
group: root
mode: "0644"
2026-03-13 23:40:05 -04:00
loop: "{{ life_noc_command_files.files }}"
notify:
- validate icinga
- reload icinga
2026-03-13 16:13:37 -04:00
2026-03-13 23:40:05 -04:00
- name: find life-noc template files on target
ansible.builtin.find:
paths: "{{ life_noc_project_root }}/icinga/templates"
patterns: "*.conf"
file_type: file
register: life_noc_template_files
- name: deploy life-noc template files into icinga conf.d
2026-03-13 16:13:37 -04:00
ansible.builtin.copy:
2026-03-13 23:40:05 -04:00
src: "{{ item.path }}"
dest: "/etc/icinga2/conf.d/life-noc-template-{{ item.path | basename }}"
2026-03-13 16:13:37 -04:00
remote_src: true
owner: root
group: root
mode: "0644"
2026-03-13 23:40:05 -04:00
loop: "{{ life_noc_template_files.files }}"
notify:
- validate icinga
- reload icinga
- name: find life-noc host files on target
ansible.builtin.find:
paths: "{{ life_noc_project_root }}/icinga/hosts"
patterns: "*.conf"
file_type: file
register: life_noc_host_files
2026-03-13 16:13:37 -04:00
2026-03-13 23:40:05 -04:00
- name: deploy life-noc host files into icinga conf.d
2026-03-13 16:13:37 -04:00
ansible.builtin.copy:
2026-03-13 23:40:05 -04:00
src: "{{ item.path }}"
dest: "/etc/icinga2/conf.d/life-noc-host-{{ item.path | basename }}"
2026-03-13 16:13:37 -04:00
remote_src: true
owner: root
group: root
mode: "0644"
2026-03-13 23:40:05 -04:00
loop: "{{ life_noc_host_files.files }}"
notify:
- validate icinga
- reload icinga
2026-03-13 16:13:37 -04:00
2026-03-13 23:40:05 -04:00
- name: find life-noc service files on target
ansible.builtin.find:
paths: "{{ life_noc_project_root }}/icinga/services"
patterns: "*.conf"
file_type: file
register: life_noc_service_files
- name: deploy life-noc service files into icinga conf.d
2026-03-13 16:13:37 -04:00
ansible.builtin.copy:
2026-03-13 23:40:05 -04:00
src: "{{ item.path }}"
dest: "/etc/icinga2/conf.d/life-noc-service-{{ item.path | basename }}"
2026-03-13 16:13:37 -04:00
remote_src: true
owner: root
group: root
mode: "0644"
2026-03-13 23:40:05 -04:00
loop: "{{ life_noc_service_files.files }}"
notify:
- validate icinga
- reload icinga
##################################
2026-03-13 16:13:37 -04:00
- name: install mock plugin
ansible.builtin.copy:
src: "{{ life_noc_project_root }}/checks/check_life_noc_mock.sh"
2026-03-13 23:40:05 -04:00
dest: /usr/lib/nagios/plugins/check_life_noc_mock.sh
2026-03-13 16:13:37 -04:00
remote_src: true
owner: root
group: root
mode: "0755"
2026-03-13 23:40:05 -04:00
notify:
- validate icinga
- reload icinga
2026-03-13 16:13:37 -04:00
- name: install compatibility wrapper plugin
ansible.builtin.copy:
src: "{{ life_noc_project_root }}/checks/check_echeance_vie.sh"
2026-03-13 23:40:05 -04:00
dest: /usr/lib/nagios/plugins/check_echeance_vie.sh
2026-03-13 16:13:37 -04:00
remote_src: true
owner: root
group: root
mode: "0755"
2026-03-13 23:40:05 -04:00
notify:
- validate icinga
- reload icinga
2026-03-13 16:13:37 -04:00
- name: ensure bpm destination directory exists
ansible.builtin.file:
2026-03-13 23:40:05 -04:00
path: "{{ life_noc_bpm_destination_dir }}"
2026-03-13 16:13:37 -04:00
state: directory
owner: root
group: root
mode: "0755"
2026-03-13 23:40:05 -04:00
when:
- life_noc_bpm_deploy_enabled | bool
- life_noc_bpm_destination_dir is defined
2026-03-13 16:13:37 -04:00
- name: deploy bpm json
ansible.builtin.copy:
src: "{{ life_noc_project_root }}/bpm/life-noc.json"
2026-03-13 23:40:05 -04:00
dest: "{{ life_noc_bpm_destination_dir }}/life-noc.json"
2026-03-13 16:13:37 -04:00
remote_src: true
owner: root
group: root
mode: "0644"
2026-03-13 23:40:05 -04:00
when:
- life_noc_bpm_deploy_enabled | bool
- life_noc_bpm_destination_dir is defined