# corrupted output when running script module

**URL:** <https://forum.ansible.com/t/corrupted-output-when-running-script-module/18384>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [June 2, 2015, 11:29pm UTC](https://forum.ansible.com/t/corrupted-output-when-running-script-module/18384 "2015-06-02T23:29:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dave1](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@dave1](https://forum.ansible.com/u/dave1)\
**Post date:** [June 2, 2015, 11:29pm UTC](https://forum.ansible.com/t/corrupted-output-when-running-script-module/18384/1 "2015-06-02T23:29:42Z")

</div>

Hello,

I’m having a problem with Ansible 1.8.4, which I’m running on a Macintosh to  
remotely configure a host running on Amazon AWS. The command I’m using  
to run a playbook is as follows:

ansible-playbook playbooks/site.yml -l [ec2-54-242-9-223.compute-1.amazonaws.com](http://ec2-54-242-9-223.compute-1.amazonaws.com) -v -s -i inventory/qa -e {"zoo\_stage":"qa","release\_name":"20150602222150"} --skip-tags skip\_during\_zoo\_boot

The playbook includes the following content:

- name: run decide\_istore\_action script  
script: …/bin/decide\_istore\_action {{ instance\_store\_devices|join(" ") }} 2\> /tmp/dave\_debug\_stderr | tee /tmp/dave\_debug\_stdout  
register: istore\_action

- debug: msg=“istore action is ==\>{{ istore\_action.stdout }}\<==”

The script writes only a single character ‘F’ (upper case letter F) to standard  
output, which I am able to verify by inspecting the contents of  
/tmp/dave\_debug\_stdout on the AWS host. However I see the following output  
when the playbook executes:

TASK: [run decide\_istore\_action script] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [[minsk.scholarific.us](http://minsk.scholarific.us)] =\> {“changed”: true, “rc”: 0, “stderr”: “”, “stdout”: “sudo: unable to resolve host [minsk.scholarific.us](http://minsk.scholarific.us)\r\nsudo: unable to resolve host [minsk.scholarific.us](http://minsk.scholarific.us)\r\nSUDO-SUCCESS-znqxbojxeouzargyysdupmmfyzzbncsy\r\nF”}

TASK: [debug msg=“istore action is ==\>{{ istore\_action.stdout }}\<==”] \*\*\*\*\*\*\*\*\*  
ok: [[minsk.scholarific.us](http://minsk.scholarific.us)] =\> {  
“msg”: “istore action is ==\>sudo: unable to resolve host [minsk.scholarific.us](http://minsk.scholarific.us)\nsudo: unable to resolve host [minsk.scholarific.us](http://minsk.scholarific.us)\nSUDO-SUCCESS-znqxbojxeouzargyysdupmmfyzzbncsy\nF\<==”  
}

Notice that the ‘F’ character written by the script is preceded by two error  
messages and some additional text. Thus it appears that a bug in Ansible is  
corrupting my script’s output by injecting extra text before the script’s actual  
output. Does this problem look familiar to anyone, or does anyone have ideas  
about what may be happening? The hostname [minsk.scholarific.us](http://minsk.scholarific.us) mentioned  
in the error message is the name of the EC2 instance, which was created  
shortly before the playbook ran. I’m not sure whether the DNS lookup was  
attempted on the Mac where the playbook was being executed from, or the  
EC2 instance. However, shortly after observing the above behavior I logged  
into the EC2 instance and did a DNS lookup, which failed:

dave@minsk:~$ nslookup [minsk.scholarific.us](http://minsk.scholarific.us)  
Server: 172.16.0.23  
Address: 172.16.0.23#53

\*\* server can’t find [minsk.scholarific.us](http://minsk.scholarific.us): NXDOMAIN

dave@minsk:~$

After waiting a few minutes I tried the lookup again and it succeeded, so I guess  
it took a while for the DNS change to propagate. So this raises two questions:

1. If the error message is the result of a DNS lookup attempted on the  
EC2 host, why would Ansible be doing a lookup there just to run a local  
command?

2. Why is the output getting mixed in with my script’s standard output?

Any help anyone may be able to offer is greatly appreciated.

Thanks  
Dave

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 3, 2015, 1:09pm UTC](https://forum.ansible.com/t/corrupted-output-when-running-script-module/18384/2 "2015-06-03T13:09:31Z")

</div>

The warning is not from ansible, but from sudo, which ansible is using  
at your request.

Sudo is trying to verify the hostname and spurting the message into  
stdout, since Ansible is executing your script under sudo it gets both  
outputs and cannot distinguish which came from which. The common  
solution for this sudo issue is adding the host to dns or /etc/hosts  
on the machine, in this case it seems that DNS is being slow to  
propagate.

Sadly this error message varies a lot across sudo  
installations/versions/etc, so it is not easy to filter out  
universally. I'm not sure there is much we can do on the ansible side.

---

<div class="post-metadata">

**Author:** ![dave1](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@dave1](https://forum.ansible.com/u/dave1)\
**Post date:** [June 3, 2015, 5:18pm UTC](https://forum.ansible.com/t/corrupted-output-when-running-script-module/18384/3 "2015-06-03T17:18:23Z")

</div>

ok thanks
