diff --git a/.config/ansible-lint.yml b/.config/ansible-lint.yml index fbc3ca3..e2405d6 100644 --- a/.config/ansible-lint.yml +++ b/.config/ansible-lint.yml @@ -10,6 +10,5 @@ exclude_paths: offline: false warn_list: - - fqcn[keyword] - var-naming[no-role-prefix] - args[module] diff --git a/README.md b/README.md index b1333da..47a74a2 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This Ansible collection contains: 1. A [role](roles/icinga_agent) to manage the Installation for your Icinga agents 2. A [role](roles/icinga_plugins) to deploy your custom check scripts to your Icinga agents - + 3. A [role](roles/icinga_downtime) to manage downtimes in your Icinga 3. The [collection](https://github.com/telekom-mms/ansible-collection-icinga-director) to deploy your Icinga master via the Icinga Director module @@ -60,26 +60,26 @@ Check out the 'Documentation' part for this collection [here](https://github.com | mms_standard.yml | create a timeperiod and service template to use for other checks | - | azure_oauth_token.yml | get azure oauth token to use in other checks | [azure_oauth_token.py](https://gist.github.com/rndmh3ro/e9abbca17a4d39597443176f99d585ae) needs to exist in the [PluginDir](https://icinga.com/docs/icinga-2/latest/doc/04-configuration/#constants-conf) on your Icinga Server or Agent | check_gitlab_scheduler.yml | check gitlab scheduled pipelines | [check_gitlab_scheduler](https://github.com/telekom-mms/check_gitlab_scheduler/) needs to exist in the [PluginDir](https://icinga.com/docs/icinga-2/latest/doc/04-configuration/#constants-conf) on your Icinga Server or Agent -| check_https.yml | check https reachability and certificates | - +| check_https.yml | check https reachability and certificates | - | check_json_azure_restapi_resourcehealth.yml | check state of azure resourcehealth | [check_json.pl](https://github.com/c-kr/check_json) needs to exist in the [PluginDir](https://icinga.com/docs/icinga-2/latest/doc/04-configuration/#constants-conf) on your Icinga Server or Agent | check_json_azure_restapi.yml | do a json check against azure restapi (with oauth_token) | [check_json.pl](https://github.com/c-kr/check_json) needs to exist in the [PluginDir](https://icinga.com/docs/icinga-2/latest/doc/04-configuration/#constants-conf) on your Icinga Server or Agent | check_json.yml | do a json check | [check_json.pl](https://github.com/c-kr/check_json) needs to exist in the [PluginDir](https://icinga.com/docs/icinga-2/latest/doc/04-configuration/#constants-conf) on your Icinga Server or Agent -| template_empty_host.yml | create a host template for an empty host | - +| template_empty_host.yml | create a host template for an empty host | - You can use these playbooks in your playbook like this: ``` - name: Import mms standard playbook to create services that other checks depend on - import-playbook: telekom_mms.ansible_collection_icinga.mms_standard + ansible.builtin.import_playbook: telekom_mms.ansible_collection_icinga.mms_standard - name: Import playbook to create azure oauth token check - import-playbook: telekom_mms.ansible_collection_icinga.check_azure_oauth_token + ansible.builtin.import_playbook: telekom_mms.ansible_collection_icinga.check_azure_oauth_token - name: Import playbook to create gitlab_scheduler check - import-playbook: telekom_mms.ansible_collection_icinga.check_gitlab_scheduler + ansible.builtin.import_playbook: telekom_mms.ansible_collection_icinga.check_gitlab_scheduler - name: Import playbook to create check_https checks - import-playbook: telekom_mms.ansible_collection_icinga.check_https + ansible.builtin.import_playbook: telekom_mms.ansible_collection_icinga.check_https ``` diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..3e2b4ae --- /dev/null +++ b/requirements.yml @@ -0,0 +1,4 @@ +--- +collections: + - name: telekom_mms.icinga_director + version: 1.35.0 diff --git a/roles/icinga_agent/tasks/main.yml b/roles/icinga_agent/tasks/main.yml index c336aab..d18ab0b 100644 --- a/roles/icinga_agent/tasks/main.yml +++ b/roles/icinga_agent/tasks/main.yml @@ -8,7 +8,7 @@ - name: Create /etc/icinga2/repository.d ansible.builtin.file: - dest: /etc/icinga2/repository.d + path: /etc/icinga2/repository.d mode: "0750" owner: "{{ icinga2_user[ansible_os_family] }}" group: "{{ icinga2_group[ansible_os_family] }}" @@ -71,7 +71,7 @@ src: ../features-available/{{ item }} dest: /etc/icinga2/features-enabled/{{ item }} state: link - with_items: + loop: - "{{ icinga_agent_enable_features }}" when: - icinga_agent_enable_features is defined diff --git a/roles/icinga_downtime/tasks/add_downtimes.yml b/roles/icinga_downtime/tasks/add_downtimes.yml index 18636dc..f012938 100644 --- a/roles/icinga_downtime/tasks/add_downtimes.yml +++ b/roles/icinga_downtime/tasks/add_downtimes.yml @@ -2,8 +2,8 @@ - name: Add icinga host downtimes ansible.builtin.uri: url: "{{ icinga_api_uri }}:{{ icinga_api_port }}/v1/actions/schedule-downtime?type=Host" - user: "{{ icinga_api_user }}" - password: "{{ icinga_api_password }}" + url_username: "{{ icinga_api_user }}" + url_password: "{{ icinga_api_password }}" validate_certs: true method: POST status_code: 200 @@ -20,7 +20,7 @@ "pretty": true, "fixed": true, }' - with_items: + loop: - "{{ icinga_host_filter }}" when: - host_downtime @@ -28,8 +28,8 @@ - name: Add icinga service downtimes ansible.builtin.uri: url: "{{ icinga_api_uri }}:{{ icinga_api_port }}/v1/actions/schedule-downtime?type=Service" - user: "{{ icinga_api_user }}" - password: "{{ icinga_api_password }}" + url_username: "{{ icinga_api_user }}" + url_password: "{{ icinga_api_password }}" validate_certs: true method: POST status_code: 200 @@ -47,7 +47,7 @@ "fixed": true, }' delegate_to: localhost - with_items: + loop: - "{{ icinga_host_filter }}" when: - service_downtime @@ -56,8 +56,8 @@ - name: Add icinga single service downtimes ansible.builtin.uri: url: "{{ icinga_api_uri }}:{{ icinga_api_port }}/v1/actions/schedule-downtime?type=Service" - user: "{{ icinga_api_user }}" - password: "{{ icinga_api_password }}" + url_username: "{{ icinga_api_user }}" + url_password: "{{ icinga_api_password }}" validate_certs: true method: POST status_code: 200 @@ -75,7 +75,7 @@ "fixed": true, }' delegate_to: localhost - with_items: + loop: - "{{ icinga_host_filter }}" when: - single_service_downtime diff --git a/roles/icinga_downtime/tasks/main.yml b/roles/icinga_downtime/tasks/main.yml index 03f99ee..b6c19a5 100644 --- a/roles/icinga_downtime/tasks/main.yml +++ b/roles/icinga_downtime/tasks/main.yml @@ -22,16 +22,19 @@ - not single_host_downtime - name: Include add_downtimes - ansible.builtin.include_tasks: add_downtimes.yml + ansible.builtin.include_tasks: + file: add_downtimes.yml when: - icinga_action == "add_downtimes" - name: Include remove_downtimes - ansible.builtin.include_tasks: remove_downtimes.yml + ansible.builtin.include_tasks: + file: remove_downtimes.yml when: - icinga_action == "remove_downtimes" - name: Include remove_all_downtimes - ansible.builtin.include_tasks: remove_all_downtimes.yml + ansible.builtin.include_tasks: + file: remove_all_downtimes.yml when: - icinga_action == "remove_all_downtimes" diff --git a/roles/icinga_downtime/tasks/remove_all_downtimes.yml b/roles/icinga_downtime/tasks/remove_all_downtimes.yml index a078399..faba556 100644 --- a/roles/icinga_downtime/tasks/remove_all_downtimes.yml +++ b/roles/icinga_downtime/tasks/remove_all_downtimes.yml @@ -2,8 +2,8 @@ - name: Delete all icinga downtimes (host and service) ansible.builtin.uri: url: "{{ icinga_api_uri }}:{{ icinga_api_port }}/v1/actions/remove-downtime?type=Downtime" - user: "{{ icinga_api_user }}" - password: "{{ icinga_api_password }}" + url_username: "{{ icinga_api_user }}" + url_password: "{{ icinga_api_password }}" validate_certs: true method: POST status_code: 200 diff --git a/roles/icinga_downtime/tasks/remove_downtimes.yml b/roles/icinga_downtime/tasks/remove_downtimes.yml index 8dbf045..67978b3 100644 --- a/roles/icinga_downtime/tasks/remove_downtimes.yml +++ b/roles/icinga_downtime/tasks/remove_downtimes.yml @@ -2,8 +2,8 @@ - name: Delete icinga downtimes (host and service) from defined author ansible.builtin.uri: url: "{{ icinga_api_uri }}:{{ icinga_api_port }}/v1/actions/remove-downtime?type=Downtime" - user: "{{ icinga_api_user }}" - password: "{{ icinga_api_password }}" + url_username: "{{ icinga_api_user }}" + url_password: "{{ icinga_api_password }}" validate_certs: true method: POST status_code: 200 @@ -13,5 +13,5 @@ body_format: json body: '{ "filter": "host.name==\"{{ item }}\" && downtime.author==\"{{ author }}\"", "pretty": true }' delegate_to: localhost - with_items: + loop: - "{{ icinga_host_filter }}" diff --git a/roles/icinga_plugins/tasks/main.yml b/roles/icinga_plugins/tasks/main.yml index 359cf3b..727df3f 100644 --- a/roles/icinga_plugins/tasks/main.yml +++ b/roles/icinga_plugins/tasks/main.yml @@ -12,7 +12,7 @@ # https://github.com/Icinga/icinga2/issues/7927 - name: Install icinga and nagios plugins except for the mysql-plugins on el8 - ansible.builtin.package: + ansible.builtin.yum: name: "{{ item }}" exclude: - nagios-plugins-all