# Show clean yum output

**URL:** <https://forum.ansible.com/t/show-clean-yum-output/26805>\
**Category:** Ansible Project\
**Created:** [February 20, 2018, 5:39pm UTC](https://forum.ansible.com/t/show-clean-yum-output/26805 "2018-02-20T17:39:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Willem\_D\_Haese](https://avatars.discourse-cdn.com/v4/letter/w/b38774/32.png) [@Willem\_D\_Haese](https://forum.ansible.com/u/Willem_D_Haese)\
**Post date:** [February 20, 2018, 5:39pm UTC](https://forum.ansible.com/t/show-clean-yum-output/26805/1 "2018-02-20T17:39:45Z")

</div>

Hello,

I’ve been struggling with outputting yum update results in a nice way. So I start with installing some required packages and registering the output in yum\_install\_required\_output:

`

- name: “Install multiple required packages to get started”  
yum:  
name:
- deltarpm
- yum-utils
- zsh
- git
- openssh
- openssh-server  
register: yum\_install\_required\_output  
`

Then I try to output the yum\_install\_required\_output registered result without the \n’s:

`

- debug:  
msg: “ITEM {{item.split(‘\n’)}}”  
with\_items: “{{yum\_install\_required\_output.results}}”  
ignore\_errors: true  
`

So as openssh and openssh-server are already installed (on this particular server), I get a list like this:

`  
ok: [172.104.136.100] =\> (item=openssh-7.4p1-13.el7\_4.x86\_64 providing openssh is already installed) =\> {  
“changed”: false,  
“item”: “openssh-7.4p1-13.el7\_4.x86\_64 providing openssh is already installed”,  
“msg”: “ITEM [u’openssh-7.4p1-13.el7\_4.x86\_64 providing openssh is already installed’]”  
}  
ok: [172.104.136.100] =\> (item=openssh-server-7.4p1-13.el7\_4.x86\_64 providing openssh-server is already installed) =\> {  
“changed”: false,  
“item”: “openssh-server-7.4p1-13.el7\_4.x86\_64 providing openssh-server is already installed”,  
“msg”: “ITEM [u’openssh-server-7.4p1-13.el7\_4.x86\_64 providing openssh-server is already installed’]”  
}  
ok: [172.104.136.100] =\> (item=Loaded plugins: fastestmirror  
Loading mirror speeds from cached hostfile

- base: [mirrors.linode.com](http://mirrors.linode.com)
- epel: [mirror.23media.de](http://mirror.23media.de)
- extras: [mirrors.linode.com](http://mirrors.linode.com)
- updates: [mirrors.linode.com](http://mirrors.linode.com)  
Resolving Dependencies  
 → Running transaction check  
—\> Package deltarpm.x86\_64 0:3.6-3.el7 will be installed  
—\> Package git.x86\_64 0:1.8.3.1-12.el7\_4 will be installed  
 → Processing Dependency: perl-Git = 1.8.3.1-12.el7\_4 for package: git-1.8.3.1-12.el7\_4.x86\_64  
 → Processing Dependency: rsync for package: git-1.8.3.1-12.el7\_4.x86\_64  
 → Processing Dependency: perl(Term::ReadKey) for package: git-1.8.3.1-12.el7\_4.x86\_64  
 → Processing Dependency: perl(Git) for package: git-1.8.3.1-12.el7\_4.x86\_64  
 → Processing Dependency: perl(Error) for package: git-1.8.3.1-12.el7\_4.x86\_64  
 → Processing Dependency: libgnome-keyring.so.0()(64bit) for package: git-1.8.3.1-12.el7\_4.x86\_64  
—\> Package yum-utils.noarch 0:1.1.31-42.el7 will be installed  
 → Processing Dependency: python-kitchen for package: yum-utils-1.1.31-42.el7.noarch  
 → Processing Dependency: libxml2-python for package: yum-utils-1.1.31-42.el7.noarch  
—\> Package zsh.x86\_64 0:5.0.2-28.el7 will be installed  
 → Running transaction check  
—\> Package libgnome-keyring.x86\_64 0:3.12.0-1.el7 will be installed  
—\> Package libxml2-python.x86\_64 0:2.9.1-6.el7\_2.3 will be installed  
—\> Package perl-Error.noarch 1:0.17020-2.el7 will be installed  
—\> Package perl-Git.noarch 0:1.8.3.1-12.el7\_4 will be installed  
—\> Package perl-TermReadKey.x86\_64 0:2.30-20.el7 will be installed  
—\> Package python-kitchen.noarch 0:1.1.1-5.el7 will be installed  
 → Processing Dependency: python-chardet for package: python-kitchen-1.1.1-5.el7.noarch  
—\> Package rsync.x86\_64 0:3.0.9-18.el7 will be installed  
 → Running transaction check  
—\> Package python-chardet.noarch 0:2.2.1-1.el7\_1 will be installed  
 → Finished Dependency Resolution

Dependencies Resolved

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [February 20, 2018, 6:45pm UTC](https://forum.ansible.com/t/show-clean-yum-output/26805/2 "2018-02-20T18:45:10Z")

</div>

It pretty much boils down to this.  
Ansible is a configuration management tool and not a reporting tool, so support for this is limited.

That being said, Ansible has a few callback plugins that alter the presentation of Ansibles output.  
You could try the debug callback plugin, with that \n in msg is a newline.  
If debug is not to you liking you probably need to write your own.

---

<div class="post-metadata">

**Author:** ![Willem\_D\_Haese](https://avatars.discourse-cdn.com/v4/letter/w/b38774/32.png) [@Willem\_D\_Haese](https://forum.ansible.com/u/Willem_D_Haese)\
**Post date:** [February 20, 2018, 6:56pm UTC](https://forum.ansible.com/t/show-clean-yum-output/26805/3 "2018-02-20T18:56:47Z")

</div>

Hey Kai,

Thanks for your answer. It’s a bit weird imho that Ansible seems not able to just show what has been installed / updated in a clean way. But if you say there is no way to make this work with the debug module, then I guess I’ll have to believe you. Still think it’s weird though.

Grtz

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [February 20, 2018, 7:03pm UTC](https://forum.ansible.com/t/show-clean-yum-output/26805/4 "2018-02-20T19:03:59Z")

</div>

I didn't say no way, just that you have limited possibilities.  
You should try the debug callback before you give up.  
I use that as standard an get a pretty good human readable out of it.

You can test it with  
ANSIBLE\_STDOUT\_CALLBACK ansible-playbook \<your\_playbook.yml\>

If you like it just add stdout\_callback=debug in you ansible.cfg

---

<div class="post-metadata">

**Author:** ![Willem\_D\_Haese](https://avatars.discourse-cdn.com/v4/letter/w/b38774/32.png) [@Willem\_D\_Haese](https://forum.ansible.com/u/Willem_D_Haese)\
**Post date:** [February 20, 2018, 7:44pm UTC](https://forum.ansible.com/t/show-clean-yum-output/26805/5 "2018-02-20T19:44:09Z")

</div>

Still not getting it to work. Giving up on this for today… It seems like such a trivial thing to just register and cleanly output installed / updated yum packages… I guess it’s not.

Thanks for the help anyway Kai.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [February 20, 2018, 8:55pm UTC](https://forum.ansible.com/t/show-clean-yum-output/26805/6 "2018-02-20T20:55:07Z")

</div>

Use the debug callback plugin and try this

&nbsp;&nbsp;- debug:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msg: |  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{% for x in yum\_install\_required\_output.results %}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{% for y in x.split('\n') %}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ y }}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{% endfor %}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{% endfor %}

---

<div class="post-metadata">

**Author:** ![Willem\_D\_Haese](https://avatars.discourse-cdn.com/v4/letter/w/b38774/32.png) [@Willem\_D\_Haese](https://forum.ansible.com/u/Willem_D_Haese)\
**Post date:** [February 21, 2018, 6:02pm UTC](https://forum.ansible.com/t/show-clean-yum-output/26805/7 "2018-02-21T18:02:23Z")

</div>

Kai,

Just tested this and your solution seems to do exactly what I want. I didn’t knew I could use this ninja2 syntax directly in the debug msg.

Thank you very much for your time.

Grtz
