life-noc/.patch-backup/life_noc_tasks_main.yml.bak

191 lines
4.9 KiB
YAML

---
- name: install minimal dependencies
ansible.builtin.apt:
name:
- python3
- python3-yaml
state: present
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
- name: create project root
ansible.builtin.file:
path: "{{ life_noc_project_root }}"
state: directory
owner: root
group: root
mode: "0755"
- name: copy project files
ansible.builtin.copy:
src: "{{ playbook_dir }}/../"
dest: "{{ life_noc_project_root }}/"
owner: root
group: root
mode: preserve
- name: generate icinga services from domains
ansible.builtin.command:
cmd: python3 scripts/generate_services.py
chdir: "{{ life_noc_project_root }}"
changed_when: true
- name: generate bpm from domains
ansible.builtin.command:
cmd: python3 scripts/generate_bpm.py
chdir: "{{ life_noc_project_root }}"
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
- name: deploy life-noc command files into icinga conf.d
ansible.builtin.copy:
src: "{{ item.path }}"
dest: "/etc/icinga2/conf.d/life-noc-command-{{ item.path | basename }}"
remote_src: true
owner: root
group: root
mode: "0644"
loop: "{{ life_noc_command_files.files }}"
notify:
- validate icinga
- reload icinga
- 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
ansible.builtin.copy:
src: "{{ item.path }}"
dest: "/etc/icinga2/conf.d/life-noc-template-{{ item.path | basename }}"
remote_src: true
owner: root
group: root
mode: "0644"
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
- name: deploy life-noc host files into icinga conf.d
ansible.builtin.copy:
src: "{{ item.path }}"
dest: "/etc/icinga2/conf.d/life-noc-host-{{ item.path | basename }}"
remote_src: true
owner: root
group: root
mode: "0644"
loop: "{{ life_noc_host_files.files }}"
notify:
- validate icinga
- reload icinga
- 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
ansible.builtin.copy:
src: "{{ item.path }}"
dest: "/etc/icinga2/conf.d/life-noc-service-{{ item.path | basename }}"
remote_src: true
owner: root
group: root
mode: "0644"
loop: "{{ life_noc_service_files.files }}"
notify:
- validate icinga
- reload icinga
##################################
- name: install mock plugin
ansible.builtin.copy:
src: "{{ life_noc_project_root }}/checks/check_life_noc_mock.sh"
dest: /usr/lib/nagios/plugins/check_life_noc_mock.sh
remote_src: true
owner: root
group: root
mode: "0755"
notify:
- validate icinga
- reload icinga
- name: install compatibility wrapper plugin
ansible.builtin.copy:
src: "{{ life_noc_project_root }}/checks/check_echeance_vie.sh"
dest: /usr/lib/nagios/plugins/check_echeance_vie.sh
remote_src: true
owner: root
group: root
mode: "0755"
notify:
- validate icinga
- reload icinga
- name: ensure bpm destination directory exists
ansible.builtin.file:
path: "{{ life_noc_bpm_destination_dir }}"
state: directory
owner: root
group: root
mode: "0755"
when:
- life_noc_bpm_deploy_enabled | bool
- life_noc_bpm_destination_dir is defined
- name: deploy bpm json
ansible.builtin.copy:
src: "{{ life_noc_project_root }}/bpm/life-noc.json"
dest: "{{ life_noc_bpm_destination_dir }}/life-noc.json"
remote_src: true
owner: root
group: root
mode: "0644"
when:
- life_noc_bpm_deploy_enabled | bool
- life_noc_bpm_destination_dir is defined