Hi
I have a inventory ( hosts ):
[webservers]
web-1
web-2
[nfsserver]
nfs-1
I then have a nfs role ( nfs.yml) :
- hosts: nfsserver
user: root
any_errors_fatal: yes
roles:
- role: common
- role: nfsserver
For various reasons ( like getting IP of all the webservers in order to set
FW rules ) I need to access facts for web-1 and web-2, but not execute any
tasks on these webservers.
Is that possible to force loading of facts for groups which are not in the
current play?
The only way I can figure how to do that is a bit lame:
- let nfs.yml also include webservers in hosts: statement ( "hosts:
webservers:nfsserver" )
- set some variable for nfs-1 ( like "nfsserver=true" in inventory file)
- in every action in roles/nfsserver/tasks/main.yml include a "when:
nfsserver is defined and nfsserver == 'true'"
If not using roles at all, this is not a problem as you can include
multiple playbooks, where each playbook has it's "hosts:" definition. In
order to load facts for all hosts, you therefore may just include one
playbook with "hosts: webservers:nfsservers", but with no actions ( or a
dummy one... )
Best regards,
Vidar
--
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/5ab128a9-ced5-44e4-8018-a27278a4cff3%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.