Hi all,
I'm learning Ansible, and I'm trying to use it to template a Nagios config file. My network is 98% Debian and Ubuntu, with a FreePBX server to mix things up. There en lies the issue I'm having. When I run this command to check facts:
ansible freepbx.domain.com -m
"ansible_os_family": "Sangoma"
{% if ansible_os_family == "Debian" or ansible_os_family == "Ubuntu" %}
define service{
use local-service
host_name {{ hostvars[item].inventory_hostname }}
service_description Apt Status
check_command check_apt
}
{% endif %}
I posted this on Reddit as well, and I realized that the issue is that the template is being applied to my Nagios server, which is Debian, so the ansible_os_family is always coming back Debian. What I'm having trouble with is how to get the if statement to get it's facts from the target server, and not the one the playbook is running on. I'm able to get the hostname from the static hosts file like this
{{ hostvars[item].inventory_hostname }}