I
I
Igor S2016-12-05 19:12:57
linux
Igor S, 2016-12-05 19:12:57

How to execute only those scripts in which there were changes?

Salute comrades!
There is a small playbook that uploads several script files (to be more precise SQL files) to the server and then applies them one by one. At the moment it is implemented like this

- template: src={{ item }} dst=/tmp
  with_item: "{{ some_list }}"

- shell: "sqlplus / @{{ item }}"
  with_item: "{{ some_list }}"

Actually the question is, how can you make it so that only those files that have been changed are applied, while not describing each file, and not assigning a handler to them?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2016-12-06
@xarek1986

I'm not 100% sure, but try:
1) add register in the template step
2) see what's in the variable
I would expect to see separate entries for changed there.
3) if it works, then use the register result in with_items for the script launch step
The second option is to use notify and handler docs.ansible.com/ansible/playbooks_best_practices....
PS The second option will be more correct and concise.

S
Sanes, 2016-12-05
@Sanes

Select via find ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question