{
"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
}
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)]
---
##### 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
...
SSH password: 2Vault password: 34PLAY [Gather Windows System Info for Sytems to be Monitored] *******************13:43:4056TASK [Gathering Facts] *********************************************************13:43:407ok: [web1]8ok: [web2]9ok: [web3]10ok: [web4]11ok: [web5]12ok: [web6]13ok: [web7]14ok: [web8]1516PLAY [Add Monitoring Config to Monitoring Hosts] *******************************13:43:491718TASK [Gathering Facts] *********************************************************13:43:4919ok: [icinga]2021TASK [icinga2-ansible-add-hosts : include_tasks] *******************************13:43:5022included: /var/lib/awx/projects/_6__icinga_monitoring/icinga2-ansible-add-hosts/tasks/icinga2_add_hosts.yml for GB1LICINV001.kbops.net2324TASK [icinga2-ansible-add-hosts : Copy Host Definitions] ***********************13:43:5025ok: [icinga] => (item=web1)26ok: [icinga] => (item=web2)27ok: [icinga] => (item=web3)28ok: [icinga] => (item=web4)29ok: [icinga] => (item=web5)30ok: [icinga] => (item=web6)31ok: [icinga] => (item=web7)32ok: [icinga] => (item=web8)33fatal: [icinga]: FAILED! => {"failed": true, "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'"}3435PLAY RECAP *********************************************************************13:43:5536icinga : ok=2 changed=0 unreachable=0 failed=1 37web1 : ok=1 changed=0 unreachable=0 failed=0 38web2 : ok=1 changed=0 unreachable=0 failed=0 39web3 : ok=1 changed=0 unreachable=0 failed=0 40web4 : ok=1 changed=0 unreachable=0 failed=0 41web5 : ok=1 changed=0 unreachable=0 failed=0 42web6 : ok=1 changed=0 unreachable=0 failed=0 43web7 : ok=1 changed=0 unreachable=0 failed=0 44web8 : ok=1 changed=0 unreachable=0 failed=0 45^ TOPAbout AWX