Hi All,

I'm looking for some help with the Add Hosts roles in this repository 
https://github.com/Icinga/icinga2-ansible , whenever i try to add hosts to 
be monitored by Icinga I always get the below failure;

{
    "msg": "The task includes an option with an undefined variable. The 
error was: 'dict object' has no attribute 'ansible_fqdn'\n\nThe error 
appears to have been in 
'/var/lib/awx/projects/_6__icinga_monitoring/icinga2-ansible-add-hosts/tasks/icinga2_add_hosts.yml':
 
line 2, column 3, but may\nbe elsewhere in the file depending on the exact 
syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: Copy 
Host Definitions\n  ^ here\n\nexception type: <class 
'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'dict object' has no 
attribute 'ansible_fqdn'",
    "failed": true
}

For information, this is my setup;

Ansible AWX

ansible 2.4.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u
'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5 
20150623 (Red Hat 4.8.5-16)]



I have 1 inventory defined with 2 groups, monitoring_servers and webservers 
- the monitoring server is the Centos Icinga Box and the webservers are 
Windows Servers. When running the playbook i always come across the 
undefined variable for the Icinga Box (in group monitoring_servers), cant 
seem to get away from it and cant see whats going wrong?  My playbook is as 
follows.

Any help would be appreciated..

Thanks!

---


##### Contact the monitored hosts to gather facts


- name: Gather Windows System Info for Sytems to be Monitored
  hosts: webservers
  vars_files: 
    - group_vars/windows.yml
  gather_facts: true


##### Contact the monitoring servers to copy host definitions


- name: Add Monitoring Config to Monitoring Hosts
  hosts: monitoring_servers
  vars: 
    cpu_warning: 80
    cpu_critical: 90
    disk_warning: 80
    disk_critical: 90
  roles:
   - role: icinga2-ansible-add-hosts
     configuration_logic: "object"
     icinga_host_attributes:
       check_command: "ping4"
       vars.sla: "24x7"
     host_checks: |
       object Service "cpu" {
         host_name = "{{ hostvars[item]['ansible_fqdn'] }}"
         check_command = "snmp-load"
         vars.snmp_community = "snmp"
         vars.snmp_warn = {{ cpu_warning }}
         vars.snmp_crit = {{ cpu_critical }}
       }
       object Service "mem" {
         host_name = "{{ hostvars[item]['ansible_fqdn'] }}"
         check_command = "snmp-storage"
         vars.snmp_community = "snmp"
         vars.snmp_storage_name = "Mem"
         vars.snmp_warn = {{ disk_warning }}
         vars.snmp_crit = {{ disk_critical }}
       }
       object Service "disk-c" {
         host_name = "{{ hostvars[item]['ansible_fqdn'] }}"
         check_command = "snmp-storage"
         vars.snmp_community = "snmp"
         vars.snmp_storage_name = "C"
         vars.snmp_warn = {{ disk_warning }}
         vars.snmp_crit = {{ disk_critical }}
       }
         object Service "disk-d" {
         host_name = "{{ hostvars[item]['ansible_fqdn'] }}"
         check_command = "snmp-storage"
         vars.snmp_community = "snmp"
         vars.snmp_storage_name = "D"
         vars.snmp_warn = {{ disk_warning }}
         vars.snmp_crit = {{ disk_critical }}
       }
         object Service "disk-e" {
         host_name = "{{ hostvars[item]['ansible_fqdn'] }}"
         check_command = "snmp-storage"
         vars.snmp_community = "snmp"
         vars.snmp_storage_name = "E"
         vars.snmp_warn = {{ disk_warning }}
         vars.snmp_crit = {{ disk_critical }}
       }
     tags: add-hosts
...


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ccdc60a1-7caf-4e43-bffd-edb5dfd88f31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to