# Ansible Local script with Arguments yes/no having some issue

**URL:** <https://forum.ansible.com/t/ansible-local-script-with-arguments-yes-no-having-some-issue/26091>\
**Category:** Ansible Project\
**Created:** [November 21, 2017, 6:16am UTC](https://forum.ansible.com/t/ansible-local-script-with-arguments-yes-no-having-some-issue/26091 "2017-11-21T06:16:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prabahar\_S](https://avatars.discourse-cdn.com/v4/letter/p/71c47a/32.png) [@Prabahar\_S](https://forum.ansible.com/u/Prabahar_S)\
**Post date:** [November 21, 2017, 6:16am UTC](https://forum.ansible.com/t/ansible-local-script-with-arguments-yes-no-having-some-issue/26091/1 "2017-11-21T06:16:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ryan\_Fisher](https://avatars.discourse-cdn.com/v4/letter/r/a4c791/32.png) [@Ryan\_Fisher](https://forum.ansible.com/u/Ryan_Fisher)\
**Post date:** [November 22, 2017, 12:42am UTC](https://forum.ansible.com/t/ansible-local-script-with-arguments-yes-no-having-some-issue/26091/2 "2017-11-22T00:42:16Z")

</div>

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](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](http://docs.ansible.com/ansible/latest/playbooks_error_handling.html#ignoring-failed-commands)  
Good luck
