[icinga-checkins] icinga.org: icinga2-ansible/master: Fix on hosts logic creation

git at icinga.org git at icinga.org
Sat Jun 7 13:16:05 CEST 2014


Module: icinga2-ansible
Branch: master
Commit: 080984c4b1f22604c96efdf4450b72f169230588
URL:    https://git.icinga.org/?p=icinga2-ansible.git;a=commit;h=080984c4b1f22604c96efdf4450b72f169230588

Author: Valentino Gagliardi <valentino.g at servermanaged.it>
Date:   Sat May 31 12:33:52 2014 +0200

Fix on hosts logic creation

---

 tasks/icinga2_add_host.yml |    3 ++-
 templates/host_def.j2      |    8 ++------
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/tasks/icinga2_add_host.yml b/tasks/icinga2_add_host.yml
index dbfd29e..6efdc62 100644
--- a/tasks/icinga2_add_host.yml
+++ b/tasks/icinga2_add_host.yml
@@ -1,8 +1,9 @@
 - name: Copy Host Definitions
   template: src=host_def.j2 
-            dest={{ icinga2_hosts_dir }}{% for host in groups['monitored'] %}{{ hostvars[host]['ansible_fqdn'] }}{% endfor %}.conf
+            dest={{ icinga2_hosts_dir }}{{ hostvars[item]['ansible_fqdn'] }}.conf
             owner=root 
             group=root 
             mode=0644
+  with_items: groups['monitored']
   notify:
    - restart icinga2
diff --git a/templates/host_def.j2 b/templates/host_def.j2
index fe6166b..c3fefd2 100644
--- a/templates/host_def.j2
+++ b/templates/host_def.j2
@@ -1,12 +1,8 @@
-{% for host in groups['monitored'] %}
-
-object Host "{{ hostvars[host]['ansible_fqdn'] }}" {
+object Host "{{ hostvars[item]['ansible_fqdn'] }}" {
   import "generic-host"
 
-  address = "{{ hostvars[host]['ansible_eth0']['ipv4']['address'] }}"
+  address = "{{ hostvars[item]['ansible_eth0']['ipv4']['address'] }}"
 
   vars.os = "Linux"
   vars.sla = "24x7"
 }
-
-{% endfor %}



More information about the icinga-checkins mailing list