I want to use logentries to forward important log files. Most servers have the same files, but there are some which are specific based on which services are running. So I figured out one way to do this by using with_items like the example below, but I’m not sure if this is considered a good practice. The programmer in me instinctively wanted to define a variable in group_vars/all and append to it (like a “subclass”) in group_vars/my_custom_server but that doesn’t seem to be possible(?).
Or should I just create one task for the generic case and another task for the more specific one?
You could choose to define the “with_items” list in your group_vars/ or another variable file to make that a little cleaner.
The complex conditional is definitely available, though a little unusual.
It might be more common to check to see if a file exists with the “stat” module – asking the remote system, rather than the configuration if it needs something.
If you have more than one role configuring something, only copy that last log file in the role that needs it.
thanks for your reply. I did in fact modify my solution according to your latest comment, by defining different roles and running multiple logentries tasks. I realize it’s simpler than attempting to dynamically build a list of arguments.
I like your idea about testing the remote system with stat though. It would be nice to define a list of common files in a group/whatever variable,
and use stat to filter. Do you think the following is an appropriate solution?
Well the debug is just going to show output, rather than fail if something didn’t exist, but I guess that would be fine if you just want to show output.