Skip to content

Commit

Permalink
fixed role icinga_plugins for debian
Browse files Browse the repository at this point in the history
* added user group and plugins_basedir based on distribution to defaults.yml
* changed conditions of installation tasks
  • Loading branch information
beechesII authored Jan 31, 2022
1 parent 3f9f369 commit 209f906
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
6 changes: 5 additions & 1 deletion roles/icinga_plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

This role copies custom checks to the wished icinga-agent node.

## Limitations

The users nagios (Debian) or icinga (Redhat) are not created by this Role you need to create these user by yourself or by the role icinga_agent.

## Dependencies

Some checks might have dependencies, define `dependency_packages` as variable to install them.
Expand All @@ -19,7 +23,7 @@ dependency_packages:
| dependency_packages | no | [] | install dependency packages
| icinga_install_plugins | yes | | list of plugins that should be installed
| icinga2_plugins_pluginsdir | yes | {{ icinga2_plugins_basedir }}/plugins | directory for icinga plugins
| icinga2_plugins_basedir | yes | /usr/lib64/nagios | base directory for your icinga plugins
| icinga2_plugins_basedir | yes | Debian: /usr/lib/nagios Redhat: /usr/lib64/nagios | base directory for your icinga plugins
| icinga_plugins_path | yes | | path with your plugins for example {{ playbook_dir }}/../files
# Examples
Expand Down
14 changes: 12 additions & 2 deletions roles/icinga_plugins/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
---
icinga2_plugins_basedir: /usr/lib64/nagios
icinga2_plugins_pluginsdir: "{{ icinga2_plugins_basedir }}/plugins"
icinga2_plugins_basedir:
Debian: /usr/lib/nagios
Redhat: /usr/lib64/nagios

icinga2_plugins_pluginsdir: "{{ icinga2_plugins_basedir[ansible_os_family] }}/plugins"

icinga2_user:
Debian: nagios
RedHat: icinga
icinga2_group:
Debian: nagios
RedHat: icinga
8 changes: 4 additions & 4 deletions roles/icinga_plugins/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
- icinga_install_plugins is defined
- icinga_install_plugins | length > 0
- ansible_facts.os_family == "RedHat"
- ansible_facts.distribution_major_version|int is version('8', '>=')
- ansible_facts.distribution_major_version | int is version('8', '>=')

- name: install icinga and nagios plugins
ansible.builtin.package:
Expand All @@ -35,7 +35,7 @@
when:
- icinga_install_plugins is defined
- icinga_install_plugins | length > 0
- ansible_facts.distribution != "RedHat" and ansible_facts.distribution_major_version|int is version('8', '<')
- ansible_facts.os_family == "RedHat" and ansible_facts.distribution_major_version | int is version('7', "=") or ansible_facts.os_family == "Debian"

- name: copy icinga plugins to target node
ansible.builtin.copy:
Expand All @@ -58,8 +58,8 @@
- name: set plugins ownership
ansible.builtin.file:
path: "{{ item.path }}"
owner: "icinga"
group: "icinga"
owner: "{{ icinga2_user[ansible_os_family] }}"
group: "{{ icinga2_group[ansible_os_family] }}"
mode: 0755
loop: "{{ files_in_plugins_dir.files }}"
loop_control:
Expand Down

0 comments on commit 209f906

Please sign in to comment.