Skip to content

Instantly share code, notes, and snippets.

@lazyfrosch
Last active February 21, 2020 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lazyfrosch/27c413f270fd139efce4a27e0538a1e7 to your computer and use it in GitHub Desktop.
Save lazyfrosch/27c413f270fd139efce4a27e0538a1e7 to your computer and use it in GitHub Desktop.
Ansible Icinga Plugin constants
- name: Icinga 2 const
hosts:
- test
tasks:
- name: Determine PluginDir for default
set_fact:
icinga2_plugin_dir: /usr/lib/nagios/plugins
- name: Determine PluginDir for RedHat
set_fact:
icinga2_plugin_dir: /usr/lib64/nagios/plugins
when: ansible_facts['os_family'] == "RedHat"
- name: Ensure correct PluginDir is set
lineinfile:
path: /etc/icinga2/constants.conf
regexp: '^const PluginDir'
line: 'const PluginDir = "{{ icinga2_plugin_dir }}"'
- name: Ensure correct PluginContribDir is set
lineinfile:
path: /etc/icinga2/constants.conf
regexp: '^const PluginContribDir'
line: 'const PluginContribDir = "{{ icinga2_plugin_dir }}/contrib"'
PLAY [Icinga 2 const] ***************************************************************************************************************************************************************
TASK [Gathering Facts] **************************************************************************************************************************************************************
ok: [centos-2gb-nbg1-2]
TASK [Determine PluginDir for default] **********************************************************************************************************************************************
ok: [centos-2gb-nbg1-2]
TASK [Determine PluginDir for RedHat] ***********************************************************************************************************************************************
ok: [centos-2gb-nbg1-2]
TASK [Ensure correct PluginDir is set] **********************************************************************************************************************************************
ok: [centos-2gb-nbg1-2]
TASK [Ensure correct PluginContribDir is set] ***************************************************************************************************************************************
--- before: /etc/icinga2/constants.conf (content)
+++ after: /etc/icinga2/constants.conf (content)
@@ -14,7 +14,7 @@
/* The directory which you use to store additional plugins which ITL provides user contributed command definitions for.
* Check the documentation, chapter "Plugins Contribution", for details.
*/
-const PluginContribDir = "/usr/lib64/nagios/plugins"
+const PluginContribDir = "/usr/lib64/nagios/plugins/contrib"
/* Our local instance name. By default this is the server's hostname as returned by `hostname --fqdn`.
* This should be the common name from the API certificate.
changed: [centos-2gb-nbg1-2]
PLAY RECAP **************************************************************************************************************************************************************************
centos-2gb-nbg1-2 : ok=5 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment