diff --git a/roles/icinga/tasks/main.yml b/roles/icinga/tasks/main.yml index ae637df..2b04b3f 100644 --- a/roles/icinga/tasks/main.yml +++ b/roles/icinga/tasks/main.yml @@ -61,6 +61,10 @@ changed_when: "'for these changes to take effect' in features_result.stdout" notify: Restart icinga2 +- name: Configure known hosts for icinga + template: src=icinga2/conf.d/hosts.conf.j2 dest=/etc/icinga2/conf.d/hosts.conf owner={{ icinga_user }} group={{ icinga_group }} + notify: Restart icinga2 + - name: Create group icingaweb2 group: name=icingaweb2 system=yes diff --git a/roles/icinga/templates/icinga2/conf.d/hosts.conf.j2 b/roles/icinga/templates/icinga2/conf.d/hosts.conf.j2 new file mode 100644 index 0000000..24e550d --- /dev/null +++ b/roles/icinga/templates/icinga2/conf.d/hosts.conf.j2 @@ -0,0 +1,12 @@ +{% for host in groups['all'] %} +object Host "{{ host }}" { + /* Import the default host template defined in `templates.conf`. */ + import "generic-host" + + /* Specify the address attributes for checks e.g. `ssh` or `http`. */ + address = "{{ host }}" + + /* Set custom variable `os` for hostgroup assignment in `groups.conf`. */ + vars.os = "Linux" +} +{% endfor %}