diff --git a/roles/icinga-monitor/tasks/disk.yml b/roles/icinga-monitor/tasks/disk.yml index 4948c02..3fcc40e 100644 --- a/roles/icinga-monitor/tasks/disk.yml +++ b/roles/icinga-monitor/tasks/disk.yml @@ -11,7 +11,7 @@ - name: Regenerate hosts.conf assemble: src: /etc/icinga2/conf.d/hosts - dest: /etc/icinga2/conf.d/hosts.conf + dest: /etc/icinga2/zones.d/master/hosts.conf # validate: /usr/sbin/icinga2 daemon -c %s --validate notify: Restart icinga2 delegate_to: "{{ icinga_server }}" diff --git a/roles/icinga-monitor/tasks/http.yml b/roles/icinga-monitor/tasks/http.yml index fc12df7..ca2ff9a 100644 --- a/roles/icinga-monitor/tasks/http.yml +++ b/roles/icinga-monitor/tasks/http.yml @@ -11,7 +11,7 @@ - name: Regenerate hosts.conf assemble: src: /etc/icinga2/conf.d/hosts - dest: /etc/icinga2/conf.d/hosts.conf + dest: /etc/icinga2/zones.d/master/hosts.conf # validate: /usr/sbin/icinga2 daemon -c %s --validate notify: Restart icinga2 delegate_to: "{{ icinga_server }}" diff --git a/roles/icinga-monitor/templates/disk.j2 b/roles/icinga-monitor/templates/disk.j2 index ce17be5..eb47eac 100644 --- a/roles/icinga-monitor/templates/disk.j2 +++ b/roles/icinga-monitor/templates/disk.j2 @@ -1,8 +1,8 @@ {% for disk in disks %} - vars.disks["disk {{ disk }}"] = { + vars.disks[" {{ disk }}"] = { disk_partitions = "{{ disk }}" - disk_wfree = "10%" disk_cfree = "5%" + disk_wfree = "10%" } {% endfor %} diff --git a/roles/icinga/tasks/main.yml b/roles/icinga/tasks/main.yml index 80b20e8..15c1b91 100644 --- a/roles/icinga/tasks/main.yml +++ b/roles/icinga/tasks/main.yml @@ -65,6 +65,17 @@ # TODO setup as master node # icinga2 node setup --master +- name: Ensure directory for zone config exists + file: + path: /etc/icinga2/zones.d/master + state: directory + owner: "{{ icinga_user }}" + group: "{{ icinga_group }}" + +- name: Configure zones + template: src=icinga2/zones.conf.j2 dest=/etc/icinga2/zones.conf owner={{ icinga_user }} group={{ icinga_group }} + notify: Restart icinga2 + - name: Ensure directory for host snippets exists file: path: /etc/icinga2/conf.d/hosts diff --git a/roles/icinga/templates/icinga2/zones.conf.j2 b/roles/icinga/templates/icinga2/zones.conf.j2 new file mode 100644 index 0000000..0119624 --- /dev/null +++ b/roles/icinga/templates/icinga2/zones.conf.j2 @@ -0,0 +1,28 @@ +object Endpoint "{{ ansible_fqdn }}" { +} + +object Zone "master" { + endpoints = [ "{{ ansible_fqdn }}" ] +} + +{% for host in groups['all'] %} +{% if host != ansible_fqdn %} +object Endpoint "{{ host }}" { + host = "{{ host }}" +} + + +object Zone "{{ host }}" { + endpoints = [ "{{ host }}" ] + parent = "master" +} + +{% endif %} +{% endfor %} +object Zone "global-templates" { + global = true +} + +object Zone "director-global" { + global = true +} diff --git a/roles/icinga_agent/tasks/main.yml b/roles/icinga_agent/tasks/main.yml index f21a0fa..f3b4565 100644 --- a/roles/icinga_agent/tasks/main.yml +++ b/roles/icinga_agent/tasks/main.yml @@ -64,7 +64,7 @@ - name: Regenerate hosts.conf assemble: src: /etc/icinga2/conf.d/hosts - dest: /etc/icinga2/conf.d/hosts.conf + dest: /etc/icinga2/zones.d/master/hosts.conf # validate: /usr/sbin/icinga2 daemon -c %s --validate notify: Restart icinga2 delegate_to: "{{ icinga_server }}"