correctifs
This commit is contained in:
parent
0ad751714a
commit
8b8709b7e6
6 changed files with 177 additions and 49 deletions
21
ansible/group_vars/all.yml
Normal file
21
ansible/group_vars/all.yml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
life_noc_fqdn: c7-life-noc-01
|
||||
life_noc_admin_user: icingadmin
|
||||
life_noc_admin_password: l1f3_N0C!_ADM
|
||||
|
||||
life_noc_db_root_socket: /run/mysqld/mysqld.sock
|
||||
|
||||
life_noc_db_icinga_name: icinga
|
||||
life_noc_db_icinga_user: icinga
|
||||
life_noc_db_icinga_password: l1f3_N0C!_DB
|
||||
|
||||
life_noc_db_web_name: icingaweb2
|
||||
life_noc_db_web_user: icingaweb2
|
||||
life_noc_db_web_password: l1f3_N0C!_WEB_DB
|
||||
|
||||
life_noc_icinga_repo_enabled: true
|
||||
life_noc_icinga_repo_distribution: icinga-bookworm
|
||||
life_noc_icinga_keyring_deb_url: https://packages.icinga.com/icinga-archive-keyring_latest+debian12.deb
|
||||
|
||||
life_noc_businessprocess_enabled: true
|
||||
life_noc_businessprocess_version: v2.5.2
|
||||
life_noc_businessprocess_repo: https://github.com/Icinga/icingaweb2-module-businessprocess.git
|
||||
2
ansible/inventory
Normal file
2
ansible/inventory
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
[icinga]
|
||||
c7-life-noc-01 ansible_host=192.168.12.40 ansible_user=ansible
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
- python3
|
||||
- python3-yaml
|
||||
- unzip
|
||||
- wget
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
|
|
@ -25,10 +26,42 @@
|
|||
state: present
|
||||
when: life_noc_icinga_repo_enabled | bool
|
||||
|
||||
- name: verify icinga keyring exists
|
||||
ansible.builtin.stat:
|
||||
path: /usr/share/keyrings/icinga-archive-keyring.gpg
|
||||
register: icinga_keyring_file
|
||||
|
||||
- name: fail if icinga keyring is missing
|
||||
ansible.builtin.fail:
|
||||
msg: "La keyring Icinga /usr/share/keyrings/icinga-archive-keyring.gpg est absente après installation."
|
||||
when: not icinga_keyring_file.stat.exists
|
||||
|
||||
- name: configure official icinga apt repository
|
||||
ansible.builtin.apt_repository:
|
||||
repo: "deb https://packages.icinga.com/debian {{ life_noc_icinga_repo_distribution }} main"
|
||||
repo: "deb [signed-by=/usr/share/keyrings/icinga-archive-keyring.gpg] https://packages.icinga.com/debian {{ life_noc_icinga_repo_distribution }} main"
|
||||
filename: icinga
|
||||
state: present
|
||||
update_cache: true
|
||||
update_cache: false
|
||||
when: life_noc_icinga_repo_enabled | bool
|
||||
|
||||
- name: configure official icinga apt source repository
|
||||
ansible.builtin.apt_repository:
|
||||
repo: "deb-src [signed-by=/usr/share/keyrings/icinga-archive-keyring.gpg] https://packages.icinga.com/debian {{ life_noc_icinga_repo_distribution }} main"
|
||||
filename: icinga
|
||||
state: present
|
||||
update_cache: false
|
||||
when: life_noc_icinga_repo_enabled | bool
|
||||
|
||||
- name: verify icinga repository file exists
|
||||
ansible.builtin.stat:
|
||||
path: /etc/apt/sources.list.d/icinga.list
|
||||
register: icinga_repo_file
|
||||
|
||||
- name: fail if icinga repository file is missing
|
||||
ansible.builtin.fail:
|
||||
msg: "Le fichier /etc/apt/sources.list.d/icinga.list est absent."
|
||||
when: not icinga_repo_file.stat.exists
|
||||
|
||||
- name: update apt cache after icinga repository configuration
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
|
|
|
|||
|
|
@ -46,7 +46,9 @@
|
|||
|
||||
- name: import icingaweb2 schema
|
||||
ansible.builtin.shell: |
|
||||
mysql --socket={{ life_noc_db_root_socket }} {{ life_noc_db_web_name }} < /usr/share/icingaweb2/etc/schema/mysql.schema.sql
|
||||
mysql --socket={{ life_noc_db_root_socket }} {{ life_noc_db_web_name }} < /usr/share/icingaweb2/schema/mysql.schema.sql
|
||||
args:
|
||||
executable: /bin/bash
|
||||
when: life_noc_web_schema_check.stdout | trim == '0'
|
||||
|
||||
- name: generate icingaweb2 admin password hash
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@ life_noc_icinga_conf_root: /etc/icinga2/conf.d/life-noc
|
|||
life_noc_plugin_dir: /usr/lib/nagios/plugins
|
||||
life_noc_validate_icinga: true
|
||||
life_noc_reload_icinga: true
|
||||
life_noc_bpm_deploy_enabled: true
|
||||
life_noc_bpm_deploy_enabled: false
|
||||
life_noc_project_root: /opt/life-noc
|
||||
life_noc_bpm_deploy_enabled: false
|
||||
life_noc_bpm_destination_dir: /etc/icingaweb2/modules/businessprocess/processes
|
||||
life_noc_bpm_target_file: /etc/icingaweb2/modules/businessprocess/processes/life-noc.json
|
||||
life_noc_owner: root
|
||||
life_noc_group: root
|
||||
|
|
|
|||
|
|
@ -1,124 +1,191 @@
|
|||
---
|
||||
- name: install minimal dependencies
|
||||
ansible.builtin.package:
|
||||
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: "{{ life_noc_owner }}"
|
||||
group: "{{ life_noc_group }}"
|
||||
owner: root
|
||||
group: root
|
||||
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"
|
||||
mode: preserve
|
||||
|
||||
- name: generate icinga services from domains
|
||||
ansible.builtin.command: python3 scripts/generate_services.py
|
||||
args:
|
||||
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: python3 scripts/generate_bpm.py
|
||||
args:
|
||||
ansible.builtin.command:
|
||||
cmd: python3 scripts/generate_bpm.py
|
||||
chdir: "{{ life_noc_project_root }}"
|
||||
changed_when: true
|
||||
|
||||
- name: deploy icinga commands
|
||||
##################################
|
||||
|
||||
- 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: "{{ life_noc_project_root }}/icinga/commands/"
|
||||
dest: "{{ life_noc_icinga_conf_root }}/commands/"
|
||||
src: "{{ item.path }}"
|
||||
dest: "/etc/icinga2/conf.d/life-noc-command-{{ item.path | basename }}"
|
||||
remote_src: true
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify: validate and reload icinga
|
||||
loop: "{{ life_noc_command_files.files }}"
|
||||
notify:
|
||||
- validate icinga
|
||||
- reload icinga
|
||||
|
||||
- name: deploy icinga hosts
|
||||
- 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: "{{ life_noc_project_root }}/icinga/hosts/"
|
||||
dest: "{{ life_noc_icinga_conf_root }}/hosts/"
|
||||
src: "{{ item.path }}"
|
||||
dest: "/etc/icinga2/conf.d/life-noc-template-{{ item.path | basename }}"
|
||||
remote_src: true
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify: validate and reload icinga
|
||||
loop: "{{ life_noc_template_files.files }}"
|
||||
notify:
|
||||
- validate icinga
|
||||
- reload icinga
|
||||
|
||||
- name: deploy icinga templates
|
||||
- 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: "{{ life_noc_project_root }}/icinga/templates/"
|
||||
dest: "{{ life_noc_icinga_conf_root }}/templates/"
|
||||
src: "{{ item.path }}"
|
||||
dest: "/etc/icinga2/conf.d/life-noc-host-{{ item.path | basename }}"
|
||||
remote_src: true
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify: validate and reload icinga
|
||||
loop: "{{ life_noc_host_files.files }}"
|
||||
notify:
|
||||
- validate icinga
|
||||
- reload icinga
|
||||
|
||||
- name: deploy icinga services
|
||||
- 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: "{{ life_noc_project_root }}/icinga/services/"
|
||||
dest: "{{ life_noc_icinga_conf_root }}/services/"
|
||||
src: "{{ item.path }}"
|
||||
dest: "/etc/icinga2/conf.d/life-noc-service-{{ item.path | basename }}"
|
||||
remote_src: true
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify: validate and reload icinga
|
||||
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: "{{ life_noc_plugin_dir }}/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 and reload icinga
|
||||
notify:
|
||||
- validate icinga
|
||||
- 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"
|
||||
dest: /usr/lib/nagios/plugins/check_echeance_vie.sh
|
||||
remote_src: true
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
notify: validate and reload icinga
|
||||
notify:
|
||||
- validate icinga
|
||||
- reload icinga
|
||||
|
||||
- name: ensure bpm destination directory exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ life_noc_bpm_target_file | dirname }}"
|
||||
path: "{{ life_noc_bpm_destination_dir }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
when: life_noc_bpm_deploy_enabled | bool
|
||||
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_target_file }}"
|
||||
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
|
||||
when:
|
||||
- life_noc_bpm_deploy_enabled | bool
|
||||
- life_noc_bpm_destination_dir is defined
|
||||
|
|
|
|||
Loading…
Reference in a new issue