life-noc/ansible/roles/life_noc/tasks/main.yml
2026-03-13 16:13:37 -04:00

124 lines
3.3 KiB
YAML

- name: install minimal dependencies
ansible.builtin.package:
name:
- python3
- python3-yaml
state: present
- name: create project root
ansible.builtin.file:
path: "{{ life_noc_project_root }}"
state: directory
owner: "{{ life_noc_owner }}"
group: "{{ life_noc_group }}"
mode: "0755"
- name: copy project files
ansible.builtin.copy:
src: "{{ playbook_dir }}/../"
dest: "{{ life_noc_project_root }}/"
owner: "{{ life_noc_owner }}"
group: "{{ life_noc_group }}"
- name: ensure icinga config tree exists
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: root
group: root
mode: "0755"
loop:
- "{{ life_noc_icinga_conf_root }}"
- "{{ life_noc_icinga_conf_root }}/commands"
- "{{ life_noc_icinga_conf_root }}/hosts"
- "{{ life_noc_icinga_conf_root }}/services"
- "{{ life_noc_icinga_conf_root }}/templates"
- name: generate icinga services from domains
ansible.builtin.command: python3 scripts/generate_services.py
args:
chdir: "{{ life_noc_project_root }}"
- name: generate bpm from domains
ansible.builtin.command: python3 scripts/generate_bpm.py
args:
chdir: "{{ life_noc_project_root }}"
- name: deploy icinga commands
ansible.builtin.copy:
src: "{{ life_noc_project_root }}/icinga/commands/"
dest: "{{ life_noc_icinga_conf_root }}/commands/"
remote_src: true
owner: root
group: root
mode: "0644"
notify: validate and reload icinga
- name: deploy icinga hosts
ansible.builtin.copy:
src: "{{ life_noc_project_root }}/icinga/hosts/"
dest: "{{ life_noc_icinga_conf_root }}/hosts/"
remote_src: true
owner: root
group: root
mode: "0644"
notify: validate and reload icinga
- name: deploy icinga templates
ansible.builtin.copy:
src: "{{ life_noc_project_root }}/icinga/templates/"
dest: "{{ life_noc_icinga_conf_root }}/templates/"
remote_src: true
owner: root
group: root
mode: "0644"
notify: validate and reload icinga
- name: deploy icinga services
ansible.builtin.copy:
src: "{{ life_noc_project_root }}/icinga/services/"
dest: "{{ life_noc_icinga_conf_root }}/services/"
remote_src: true
owner: root
group: root
mode: "0644"
notify: validate and reload icinga
- name: install mock plugin
ansible.builtin.copy:
src: "{{ life_noc_project_root }}/checks/check_life_noc_mock.sh"
dest: "{{ life_noc_plugin_dir }}/check_life_noc_mock.sh"
remote_src: true
owner: root
group: root
mode: "0755"
notify: validate and reload icinga
- name: install compatibility wrapper plugin
ansible.builtin.copy:
src: "{{ life_noc_project_root }}/checks/check_echeance_vie.sh"
dest: "{{ life_noc_plugin_dir }}/check_echeance_vie.sh"
remote_src: true
owner: root
group: root
mode: "0755"
notify: validate and reload icinga
- name: ensure bpm destination directory exists
ansible.builtin.file:
path: "{{ life_noc_bpm_target_file | dirname }}"
state: directory
owner: root
group: root
mode: "0755"
when: life_noc_bpm_deploy_enabled | bool
- name: deploy bpm json
ansible.builtin.copy:
src: "{{ life_noc_project_root }}/bpm/life-noc.json"
dest: "{{ life_noc_bpm_target_file }}"
remote_src: true
owner: root
group: root
mode: "0644"
when: life_noc_bpm_deploy_enabled | bool