# Confirm behavior of 'register'  when using sudo and script module

**URL:** <https://forum.ansible.com/t/confirm-behavior-of-register-when-using-sudo-and-script-module/14288>\
**Category:** Ansible Project\
**Created:** [January 7, 2014, 4:34pm UTC](https://forum.ansible.com/t/confirm-behavior-of-register-when-using-sudo-and-script-module/14288 "2014-01-07T16:34:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucc](https://avatars.discourse-cdn.com/v4/letter/l/34f0e0/32.png) [@lucc](https://forum.ansible.com/u/lucc)\
**Post date:** [January 7, 2014, 4:34pm UTC](https://forum.ansible.com/t/confirm-behavior-of-register-when-using-sudo-and-script-module/14288/1 "2014-01-07T16:34:51Z")

</div>

Hello,

I've possibly found a bug, but I would like to confirm before creating a ticket.

I'm trying to capture output of a remote script executed using the 'script' module. If sudo is not enabled, everything works just fine and I can use result.stdout. However, if sudo is enabled, sudo "success\_key" is embedded into result.stdout if I'm using the script module. The same problem do not affect 'command' module.

This was tested with ansible 1.4.3 (pip), as well as the development version from git. It used to work just fine with ansible 1.3.4.

The following playbook demonstrates the issue:

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [January 7, 2014, 5:30pm UTC](https://forum.ansible.com/t/confirm-behavior-of-register-when-using-sudo-and-script-module/14288/2 "2014-01-07T17:30:24Z")

</div>

Might be specific to the script module and the way it’s implemented, but yes, this seems bug-ish.

Please report this one on github even if you don’t get a chance to dive in.

I would probably look to see what’s normally absorbing this message and why it doesn’t in the script module case, provided you can see this behavior on the development branch.

Thanks!

---

<div class="post-metadata">

**Author:** ![Adam\_Morris](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@Adam\_Morris](https://forum.ansible.com/u/Adam_Morris)\
**Post date:** [January 8, 2014, 12:13am UTC](https://forum.ansible.com/t/confirm-behavior-of-register-when-using-sudo-and-script-module/14288/3 "2014-01-08T00:13:38Z")

</div>

One of my colleagues just ran into this same thing on 1.4.4. It looks like the script module is picking up the results of sudo and claiming success no matter what the script actually claims.

I’ll report this issue on github tomorrow morning if Luciano hasn’t.

Adam

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [January 8, 2014, 12:14am UTC](https://forum.ansible.com/t/confirm-behavior-of-register-when-using-sudo-and-script-module/14288/4 "2014-01-08T00:14:46Z")

</div>

This is already done here

[https://github.com/ansible/ansible/issues/5533](https://github.com/ansible/ansible/issues/5533)

---

<div class="post-metadata">

**Author:** ![Adam\_Morris](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@Adam\_Morris](https://forum.ansible.com/u/Adam_Morris)\
**Post date:** [January 8, 2014, 12:31am UTC](https://forum.ansible.com/t/confirm-behavior-of-register-when-using-sudo-and-script-module/14288/5 "2014-01-08T00:31:13Z")

</div>

A little poking finds that lib/ansible/utils/ **init**.py is the only place that uses SUDO-SUCCESS and then only in make\_sudo\_cmd. That function is called in a lot of connection\_plugins files. I can’t work out how the script module is implemented based on a cursory look because it is not like any of the other modules I have looked at.

I hope that this helps somewhat…

Adam
