Hi,
I was wondering if there is an idiomatic way to have a secondary loop in a with_items stanza.
I am trying to template the following directory structure:
/opt/my_app/instance-1/foo.cfg
/opt/my_app/instance-1/bar.cfg
/opt/my_app/instance-1/baz.cfg
/opt/my_app/instance-2/foo.cfg
/opt/my_app/instance-2/bar.cfg
/opt/my_app/instance-3/baz.cfg
…………
/opt/my_app/instance-n/foo.cfg
/opt/my_app/instance-n/bar.cfg
/opt/my_app/instance-n/baz.cfg
So in my playbook to create the {foo.cfg,bar.cfg,baz.cfg} trio, I’ve got this fragment:
action: template src=templates/$item.j2 dest=/opt/my_app/instance_1/$item
with_items:
- foo.cfg
- bar.cfg
- baz.cfg
Is there a neat way that I could create an outer loop of 1…n that I could bind my instance_$i subdirectory to?
Cheers,
Ben