I have checked some similar questions but those questions don't answer mine.
I have three hosts:
- host_abc_01
- host_def_01
- host_ghi_01
I want to create directories this way:
-
host_abc_01:
-
host_def_01:
-
host_ghi_01:
the only different is the directory name. the sub directories have the same name.
Instead of creating three different roles with own tasks and varfiles, is there any way to achieve this in one play?
- name: create project directory
win_file:
path: '{{ projects_volume }}\{{ item.proj_name }}'
state: directory
loop:
- { proj_name: 'abc', when: "'abc' in inventory_hostname" }
- { proj_name: 'def', when: "'def' in inventory_hostname" }
- { proj_name: 'ghi', when: "'ghi' in inventory_hostname" }
But all directories are created on all hosts.
Any help would be appreciated.