Yeah, I forgot to mention the result.
Basically, there was no error but instead it creates a new directory from the value of ‘app_name’ rather than the item list of the dir_list.
Thank You, Walter.
It does work as expected however, I do have couple of variables inside the dirname.yml and different directories inside of the home path.
The idea, I don’t want to run the copy module (etc) in one execution but instead putting them in a group or set. Another purpose, I don’t want them to restart them at the same time wherein it will be on schedule on when it will happen.
Are you thinking there is different “dir_list” for each group?
–limit awssxb would also need an awssbx vars file that has one list of values for dir_list
–limt awssbx2 would also need an awssbx2 vars file that has a different list of values for dir_list?
In your playbook you can reference vars file by variable names, so you could use the group name
Use *vars* lookup plugin to indirectly reference the value of the
variable stored in *app_name*. Then use filter *product* to create
the combinations. For example, given
* the extra variable '-e app_name=dir_list'
* the variable *dir_list*
> cat dirname.yml
dir_list:
- hello
- goodbye
- take-care
* the inventory
> cat hosts
host01 ansible_hostname=01.us.com
* the variable 'ver=123'
msg: copy lib_1 to hello-01.us.com-123
msg: copy lib_1 to goodbye-01.us.com-123
msg: copy lib_1 to take-care-01.us.com-123
msg: copy lib_2 to hello-01.us.com-123
msg: copy lib_2 to goodbye-01.us.com-123
msg: copy lib_2 to take-care-01.us.com-123