python api return code. when task fails

16 views
Skip to first unread message

Mario Garcia

unread,
Jun 24, 2021, 10:00:15 AM6/24/21
to Ansible Development
I am running the python api to develop an inhouse script but the script returns always 0 even if a task failed. how can we capture the task exit code.? 

the python script always returns 0 even per instance there is a copy tasks that failed to validate.  i get on stdout that the task failed however the rc code of the script is still 0! 

I am using this example to copy a file to remote hosts it works fine but not when the copy is unsuccessful.. 
https://docs.ansible.com/ansible/2.9/dev_guide/developing_api.html

Brian Coca

unread,
Jun 24, 2021, 10:11:35 AM6/24/21
to Mario Garcia, Ansible Development
tasks do not use return codes, their status is reflected in the return
data dictionary as keys.

--
----------
Brian Coca

Reply all
Reply to author
Forward
0 new messages