Conditionnal 'changed_when' based on output in a 'with_items' task
0
I have a simple shell task which is feed with_items . I want to have the ' changed ' status only when the run actually did something. So for that I have to parse the output and look for a « Done ». The issue is using a register at the same time that the with_items generates a list of results. And I don't find a way to access the stdout of the current loop iteration. --- - name: Test to set changed status only on when output match with 'Done' hosts: my-host-01 gather_facts: no tasks: - name: Task doing stuff shell: | echo {{ item }} register: do_stuff with_items: - "Doing... Done!" - "Nothing to do" #changed_when: do_stuff.results[{{ item.id }}].stdout.find('Done') - name: Print 'do_stu...