--- - 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 notify: - restart life-noc input api - name: generate icinga services from domains ansible.builtin.command: cmd: python3 scripts/generate_services.py chdir: "{{ life_noc_project_root }}" environment: LIFE_NOC_PUBLIC_BASE_URL: "{{ life_noc_public_base_url }}" 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 servicegroup files on target ansible.builtin.find: paths: "{{ life_noc_project_root }}/icinga/servicegroups" patterns: "*.conf" file_type: file register: life_noc_servicegroup_files - name: deploy life-noc servicegroup files into icinga conf.d ansible.builtin.copy: src: "{{ item.path }}" dest: "/etc/icinga2/conf.d/life-noc-servicegroup-{{ item.path | basename }}" remote_src: true owner: root group: root mode: "0644" loop: "{{ life_noc_servicegroup_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: install generic life-noc probe plugin ansible.builtin.copy: src: "{{ life_noc_project_root }}/checks/check_life_noc_probe.py" dest: /usr/lib/nagios/plugins/check_life_noc_probe.py 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 config ansible.builtin.copy: src: "{{ life_noc_project_root }}/bpm/Life-NOC.conf" dest: "{{ life_noc_bpm_destination_dir }}/Life-NOC.conf" remote_src: true owner: root group: root mode: "0644" when: - life_noc_bpm_deploy_enabled | bool - life_noc_bpm_destination_dir is defined - name: install api dependencies for inputs service ansible.builtin.apt: name: - python3-fastapi - python3-uvicorn - python3-multipart state: present update_cache: true - name: deploy life-noc input api systemd unit ansible.builtin.template: src: life-noc-input-api.service.j2 dest: /etc/systemd/system/life-noc-input-api.service owner: root group: root mode: "0644" notify: - reload systemd - restart life-noc input api - name: enable and start life-noc input api ansible.builtin.service: name: life-noc-input-api enabled: true state: started