Your script is being run, but it is exciting with a non-zero return code 
which causes the playbook to exit with a failure. This is the expected 
behavior, see this part of the output:

"msg": "non-zero return code", "rc": 1, 


If you don't want the playbook to fail when the script exits with a 
non-zero return, you need to set the failed_when: condition to your liking. 
Or, if you simply want to ignore all failures (from the perspective of 
Ansible), you can set ignore_errrors: True.

See these docs:


   - 
   failed_when: 
http://docs.ansible.com/ansible/latest/playbooks_error_handling.html#controlling-what-defines-failure
   - 
   ignore_errors: 
http://docs.ansible.com/ansible/latest/playbooks_error_handling.html#ignoring-failed-commands

Good luck

On Monday, November 20, 2017 at 10:16:53 PM UTC-8, Prabahar S wrote:
>
> Hi All,
>
> Can someone give an idea about to run the script in local? My script 
> having yes/no question. If I give "Yes" it'll run the script, "NO" it will 
> terminate the script. So I need a playbook to execute this scenario. It's 
> quite an urgency.
>
>
> - hosts: test
>   tasks:
>
>         - name: Running Script
>           run_once: true
>           local_action: script /data/scripts/script.sh
>           register: history
>           
>
> I have tried above playbook. it's not working and the throwing the error
>
>
>  ansible-playbook testing.yml
>
> PLAY [test] 
> ************************************************************************************************************************************************************************************************
>
> TASK [Gathering Facts] 
> *************************************************************************************************************************************************************************************
> ok: [unixpgtest1]
>
> TASK [Running Script] 
> *************************************************************************************************************************************************
> fatal: [unixpgtest1 -> localhost]: FAILED! => {"changed": true, "msg": 
> "non-zero return code", "rc": 1, "stderr": "", "stdout": "\u001b[5m 
> ############################################################\n\u001b[15m 
> Hello Admin... Welcome to Script\n\u001b[5m 
> ############################################################\n\u001b[0m\n\nNo 
> server Arguments to the script are found.\n\nThe script will use the 
> servers mentioned in the file \"\".\n\nBelow are the servers mentioned in 
> the file /data/scripts/OS_PATCHING/Patching_Servers.txt\nunixpgtest1 test 
> auto \n\n\nExiting....\n", "stdout_lines": ["\u001b[5m 
> ############################################################", "\u001b[15m 
> Hello Admin... Welcome to Script", "\u001b[5m 
> ############################################################", "\u001b[0m", 
> "", "No server Arguments to the script are found.", "", "The script will 
> use the servers mentioned in the file \"\".", "", "Below are the servers 
> mentioned in the file", "unixpgtest1 test auto ", "", "", "Exiting...."]}
>
> NO MORE HOSTS LEFT 
> *****************************************************************************************************************************************************************************************
>         to retry, use: --limit @/etc/ansible/playbook/testing.retry
>
> PLAY RECAP 
> *************************************************************************************************************************************************************************************************
> unixpgtest1                : ok=1    changed=0    unreachable=0    failed=1
>
>

-- 
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/4dbe3631-88ea-4885-9558-14152d1a6efd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to