Guy, you saved my day!

You are right, my script is not a module, it is just called by the *shell* 
module. Then using the *changed_when* clause did the job. Here is the code.

*my_playbook.yml*:
[...]
    - name: my action
      shell: /path/to/my_action.sh {{ my_arg }}
      register: script
      changed_when: script.rc == "changed"
      when: my_arg is defined
[...]



*my_action.sh*:
[...]
echo "rc=changed"
exit 0
[...]



*Execution*:
[root@my_host] # ansible-playbook -v -l $(hostname -s) -c local 
/path/to/my_playbook.yml
[...]
TASK: [my action] 
*************************************************************
ok: [my_host] => {"changed": false, "cmd": "/path/to/my_action.sh 
2015-04-05", "delta": "0:00:00.213521", "end": "2015-04-22 17:17:54.159018", 
"rc": 0, "start": "2015-04-22 17:17:53.945497", "stderr": "", "stdout": "", 
"stdout_lines": []}

Thank you very much, Brian!

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/12ae829f-6594-43b1-937d-1dd476859808%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to