Hi,
I feel I must be missing something very obvious here, but I can't
find it, so here we go.
Let's say I've got a role's tasks/main.yml that includes some other
tasks on a loop:
- include_tasks: distribute_thing.yml
when: thing_names is defined
loop: "{{ thing_names | flatten(levels=1) }}"
loop_control:
loop_var: thing_name
thing_names is just a list like
- alpha
- bravo
- …
now in distribute_thing.yml for each thing_name I want to copy
several files:
- name: Distribute foo files for each thing
copy:
src: "{{ thing_name }}/foo"
dest: /etc/things/{{ thing_name }}/foo
mode: 0644
- name: Distribute bar files for each thing
no_log: true
copy:
src: "{{ thing_name }}/bar"
dest: /etc/things/{{ thing_name }}/bar
mode: 0640
Fine so far. But now I also want a file /etc/things/{{ thing_name
}}/foobar which is the combined content of foo and bar. I would only
like to bother sending it over if either the foo or the bar task
changed.
What is the simplest way to do it?
I don't care if the content comes from the control host or the
target.
At first I thought a register variable on each of the foo and bar
tasks like:
- name: Distribute foo files for each thing
register: foo_changed
copy: …
then a template file like:
{{ foo_changed['diff'][0]['after'] }}
{{ bar_changed['diff'][0]['after'] }}
to just concat those two register variables together. That does
actually work for foo, but not bar, because bar has no diff content
owing to the no_log: true, which is necessary because the file
content of bar is sensitive and shouldn't be logged.
Probably I missed some really simple way to just concat a bunch of
files together and send that over. Is there something like that?
Thanks,
Andy