I’ve been trying to come up with an elegant solution to this, but alas; no such luck - perhaps some of you smart people can help.
Enough blabbering: I have a directory containing subdirectories named after some groups in my inventory.
I’m using the ‘group_names’ variable in the ‘src’ parameter’s value for the ‘copy’ module. Take the following block as an example:
`
copy: src={{ static_data_store }}/some_path/groups/{{ group_names}}/*
dest=/some/path/
`
So the idea here is that any node going through this play picks up any data from the Ansible server intended for it, depending on group membership.
I need to introduce a conditional here that checks for the existence of this data on the Ansible server, before attempting to distribute it.
This is necessary because, when going through the play, and the ‘group_names’ variable is expanded, there may not be some data for some of the groups within that list, only some.
If there is no ‘webservers’ directory, for example, if a node is a member of such a group, this play would fail.
Any thoughts/contributions/criticisms are welcome!
Thanks in advance.