# Add stdout and stdout\_lines to the results registered by the yum module

**URL:** <https://forum.ansible.com/t/add-stdout-and-stdout-lines-to-the-results-registered-by-the-yum-module/16740>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [November 10, 2014, 10:23pm UTC](https://forum.ansible.com/t/add-stdout-and-stdout-lines-to-the-results-registered-by-the-yum-module/16740 "2014-11-10T22:23:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sankalp\_Khare](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@Sankalp\_Khare](https://forum.ansible.com/u/Sankalp_Khare)\
**Post date:** [November 10, 2014, 10:23pm UTC](https://forum.ansible.com/t/add-stdout-and-stdout-lines-to-the-results-registered-by-the-yum-module/16740/1 "2014-11-10T22:23:44Z")

</div>

Hi,

I’ve been trying to get some helpful output from playbook runs that use the yum and apt modules.

When I register the results of an invocation of these modules, I notice that the apt module very conveniently returns a “stdout\_lines” field which contains something that is much more readable than “msg” or “stdout”, which contain literal "\n"s. But the yum module does not have any such field in its results. There is only a “results” field which is not formatted in a very readable way:

> > [ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com](http://ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com) | success \>\> {
> 
> > “changed”: true,
> 
> > “msg”: “”,
> 
> > “rc”: 0,
> 
> > “results”: [
> 
> > "Loaded plugins: priorities, update-motd, upgrade-helper\n1018 packages excluded due to repository priority protections\nResolving Dependencies\n → Running transaction check\n—\> Package at.x86\_64 0:3.1.10-43.8.amzn1 will be updated\n—\> Package at.x86\_64 0:3.1.10-43.11.amzn1 will be an update\n—\> Package audit.x86\_64 0:2.3.2-3.19.amzn1 will be updated\n—\> Package audit.x86\_64 0:2.3.3-4.21.amzn1 will be an update\n—\> Package audit-libs.i686 0:2.3.2-3.19.amzn1 will be updated\n—\> Package audit-libs.x86\_64 0:2.3.2-3.19.amzn1 will be updated\n—\> Package audit-libs.i686 0:2.3.3-4.21.amzn1 will be an update\n—\> Package audit-libs.x86\_64 0:2.3.3-4.21.amzn1 will be an update\n—\> Package aws-amitools-ec2.noarch 0:1.5.2-0.0.amzn1 will be updated\n—\> Package aws-amitools-ec2.noarch 0:1.5.6-1.1.amzn1 will be an update\n—\> Package aws-apitools-as.noarch 0:1.0.61.5-1.0.amzn1 will be updated\n—\> Package aws-apitools-as.noarch 0:1.0.61.6-1.0.amzn1 will be an update\n—\> Package aws-apitools-ec2.noarch 0:1.6.13.0-1.1.amzn1 will be updated\n—\> Package aws-apitools-ec2.noarch 0:1.7.1.3-1.0.amzn1 will be an update\n—\> Package aws-apitools-elb.noarch 0:1.0.34.0-1.0.amzn1 will be updated\n—\> Package aws-apitools-elb.noarch 0:1.0.35.0-1.0.amzn1 will be an update\n—\> Package aws-apitools-rds.noarch 0:1.15.001-1.0.amzn1 will be updated\n—\> Package aws-apitools-rds.noarch 0:1.18.001-1.0.amzn…

I’m snipping the rest of it, but you get the idea.

Is it possible to introduce a “stdout\_lines” in the output of the yum module as well?

Thanks!

---

<div class="post-metadata">

**Author:** ![Sankalp\_Khare](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@Sankalp\_Khare](https://forum.ansible.com/u/Sankalp_Khare)\
**Post date:** [November 11, 2014, 2:21am UTC](https://forum.ansible.com/t/add-stdout-and-stdout-lines-to-the-results-registered-by-the-yum-module/16740/2 "2014-11-11T02:21:39Z")

</div>

In comparison, here is the output of the apt module, with the stdout\_lines field that I find readable:

---

<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:** [November 11, 2014, 1:24pm UTC](https://forum.ansible.com/t/add-stdout-and-stdout-lines-to-the-results-registered-by-the-yum-module/16740/3 "2014-11-11T13:24:19Z")

</div>

open a feature request on github for the ansible-modules-core project, this should not be hard to add

---

<div class="post-metadata">

**Author:** ![Sankalp\_Khare](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@Sankalp\_Khare](https://forum.ansible.com/u/Sankalp_Khare)\
**Post date:** [November 12, 2014, 10:48am UTC](https://forum.ansible.com/t/add-stdout-and-stdout-lines-to-the-results-registered-by-the-yum-module/16740/4 "2014-11-12T10:48:06Z")

</div>

Hi Brian,

I am concerned with ansible-playbook, and so I’ll restrict my observations to the context of playbook executions only.

I examined the source code and there is a marked difference in the way the apt and yum modules deal with the outputs captured from their respective actions. The difference is in what is passed to the exit\_json() call which passes information back to playbook.

1. apt.py sends stdout in a key called stdout and stderr in a key called stderr
2. yum.py, on the other hand, puts stdout into a results key and stderr into the msg key  
playbook/ **init**.py contains instructions to split anything returned as stdout into lines, and put that into stdout\_lines, which is what we want.

Therefore I feel that the yum module is behaving in a non-standard way here and its information returning style must be revised to make it more aligned with what the apt module does. If this seems like the right course of action, I can work on the yum module code and submit a PR.

Awaiting your comments/suggestions.

Regards,  
Sankalp

---

<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:** [November 12, 2014, 3:40pm UTC](https://forum.ansible.com/t/add-stdout-and-stdout-lines-to-the-results-registered-by-the-yum-module/16740/5 "2014-11-12T15:40:43Z")

</div>

Actually the yum module output is more consistent with what you would expect registering a var using with\_items. Both modules use a special optimization in which they slurp the whole list instead of executing it one at a time.

Also I think you are comparing outputs on different operations. In any case a quick workaround is to add .split() to the yum output to get the same output as stdout\_lines.
