On 17.02.2018 23:20, Brigzzy Briggs wrote:
I tried that, but it didn't work. Thanks for the reply all the same!
Here's the section of the playbook. Let me know if you can see the
issue,
or if I can post anything else that would help.
- hosts: nagios-server
become: yes
tasks:
....
- name: Generate Configs
template:
src=skins/larry/root/ansible/ansible-files/nagios/nagios-monitored-server.cfg.j2
dest=/usr/local/nagios/etc/servers/{{ item }}.cfg owner=root mode=0644
with_items: "{{groups['nagios-monitored']}}"
.....
This is the error the playbook spits out. It throws it for all the
servers, not just the FreePBX one.
failed: [nagios.domain.com] (item=freepbx.domain.com) => {"failed":
true, "item": "freepbx.domain.com", "msg": "AnsibleUndefinedVariable:
'dict object' has no attribute 'ansible_os_family'"}
You don't have access to the facts the hosts in group nagios-monitored,
that's the reason it fails.
So you need to enable fact caching
http://docs.ansible.com/ansible/latest/playbooks_variables.html#fact-caching
or gather the facts before you run the nagios-server play.
Facts gathered in one play is available in subsequent plays as long as
they are in the same playbook.
---
- hosts: nagios-monitored
gather_facts: yes
- hosts: nagios-server
become: yes
tasks:
....
- name: Generate Configs
--
Kai Stian Olstad
--
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/433db1c9c9a30f72711b5df03d726a16%40olstad.com.
For more options, visit https://groups.google.com/d/optout.