Hi All,
I know there’s a simple fix for this, but I’ve been running 'round the Net for hours now and I can’t crack this issue - could someone please point me in the right direction?
vars/main.yml File:
variable_one:
- var_1_1
- var_1_2
variable_two:
- var_2_1
- var_2_2
task File:
- name: Copy Template Files
ansible.builtin.template:
src: "my_source/mytemplate_{{item.0}}.j2"
dest: "my_destination/{{item.0}}_{{item.1}}.txt"
owner: me
group: me
mode: "0640"
with_nested:
- "{{variable_one}}"
- "{{variable_two}}"
Expected Output (in no particular order):
my_destination/var_1_1_var_2_1.txt
my_destination/var_1_1_var_2_2.txt"
my_destination/var_1_2_var_2_1.txt"
my_destination/var_1_2_var_2_2.txt"
Issue:
The ‘Copy Template Files’ task is trying to find:
my_source/mytemplate_[.j2
my_source/mytemplate_v.j2
my_source/mytemplate_a.j2
my_source/mytemplate_r.j2
...
In other words, its looping over the individual characters of var_1_1 and var_1_2 instead of looping of var_1_1 and var_1_2.
So my syntax is wrong (or I’m using the wrong Ansible function).
Any ideas?
Thanks in Advance
Dulux Oz