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 I can see that "ansible_os_family": "Sangoma" In my template, I have the following if statement: {% 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 %} and the issue is that the block is still being generated for that server, even though it's not Debian or Ubuntu. I posted this on Reddit as well <https://www.reddit.com/r/ansible/comments/7y5uje/troubles_with_an_if_statement_in_a_jinja2_template/?st=jdrthmo2&sh=38998e5f>, 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 }} but I'm not having any luck figuring out how to get the template to apply to the values from that host. Anyone have any ideas? -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ce5f35a6-fc8a-450a-868b-d31b7afd06a8%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.