# Unarchive module verbosity

**URL:** <https://forum.ansible.com/t/unarchive-module-verbosity/17974>\
**Category:** Ansible Developer\
**Created:** [April 14, 2015, 12:06pm UTC](https://forum.ansible.com/t/unarchive-module-verbosity/17974 "2015-04-14T12:06:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![user87](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@user87](https://forum.ansible.com/u/user87)\
**Post date:** [April 14, 2015, 12:06pm UTC](https://forum.ansible.com/t/unarchive-module-verbosity/17974/1 "2015-04-14T12:06:23Z")

</div>

Hello everyone!

I’ve got a problem with “unarchive” core module. With the latest version 1.9 the behavior of the module changed.

In ansible version 1.7.2 all gzip and tar archives were extracted with  
tar (or gtar) command that had “-v” (–verbose) argument.

here is the piece of code from 1.7.2 version module (from class that handles gzip)

cmd = ‘%s **_-v_** -C “%s” --diff -%sf “%s”’ % (self.cmd\_path, self.dest, self.zipflag, self.src)

and here is the same one from 1.9

cmd = ‘%s -C “%s” --diff -%sf “%s”’ % (self.cmd\_path, self.dest, self.zipflag, self.src)

This affects the json output, especially the “out” section

“unarchived”: {  
“changed”: false,  
“msg”: “All items completed”,  
“results”: [  
{  
“changed”: false,  
“check\_results”: {  
“cmd”: “/bin/gtar -C "/app/tools" --diff -zf "/app/downloads/jdk-8.20.tar.gz"”,  
“err”: “”,  
**“out”: “”,**  
“rc”: 0,  
“unarchived”: true  
},

In version 1.7.2 (with verbose flag) the “out” section contained all the files extracted, concatenated in one string.  
This was really helpful when I need to create a symlink to the contents extracted.

Let me give you a bit more details. For example I have an archive of Java SDK.  
The name of archive differs from the folder name that is inside of this archive. I need to create a symlink “/opt/java” (where my applications look for java) that point to the extracted contents.

So I used the following ansible code:

- name: Unarchive Java  
tags:

- java\_install  
unarchive:  
src={{ item.dest }}  
dest={{ tools\_dir }}  
copy=no  
register: unarchived  
with\_items:

- “{{ artifacts }}”

- name: Create symlink for Java  
tags:

- java\_install  
file:  
state=link  
src={{ tools\_dir }}/{{ **unarchived.results[0].check\_results.out.split(‘\n’)\*\*\*\*[0].rstrip(‘/’)** }}  
dest={{ java\_dir }}

In this way i determined what folder names was inside the archive, so I was able to create a symlink.

With a newer version I can’t do this. So the questions are the following:

1. Can I pass some kind of argument in ansible code to use verbose output?
2. Is there any other way to determine the name of the folder inside of the archive using ansible? ( I could possibly miss something )
3. Will this beavior be fixed/changed/modified?

Currently as a workaround I had to manually add “-v” argument to the module, but that would be really nice to have an option in a module so I can choose verbosity in ansible code.

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [April 14, 2015, 2:29pm UTC](https://forum.ansible.com/t/unarchive-module-verbosity/17974/2 "2015-04-14T14:29:01Z")

</div>

I'll look into adding this back in today. I think I removed it since  
we're screenscraping the output of tar here and using -v seemed like  
it might interfere with getting the data we needed. If it turns out  
that was just worrying for nothing I'll restore the -v flag.

-Toshio

---

<div class="post-metadata">

**Author:** ![Jesse\_Keating](https://avatars.discourse-cdn.com/v4/letter/j/3bc359/32.png) [@Jesse\_Keating](https://forum.ansible.com/u/Jesse_Keating)\
**Post date:** [April 14, 2015, 5:56pm UTC](https://forum.ansible.com/t/unarchive-module-verbosity/17974/3 "2015-04-14T17:56:48Z")

</div>

Could you make it an option? I’d rather NOT see the huge mess on screen and in logs when the information is not needed.

---

<div class="post-metadata">

**Author:** ![user87](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@user87](https://forum.ansible.com/u/user87)\
**Post date:** [April 15, 2015, 6:41am UTC](https://forum.ansible.com/t/unarchive-module-verbosity/17974/4 "2015-04-15T06:41:14Z")

</div>

I am totally agree with Jesse. An option would be the best of both solutions, flexible and nice.

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [April 15, 2015, 4:33pm UTC](https://forum.ansible.com/t/unarchive-module-verbosity/17974/5 "2015-04-15T16:33:50Z")

</div>

Done. [https://github.com/ansible/ansible-modules-core/commit/a19fa6ba48bf092b574eb6ee40f38f06500d767d](https://github.com/ansible/ansible-modules-core/commit/a19fa6ba48bf092b574eb6ee40f38f06500d767d)

i implemented a list\_files parameter for unarchive. If you specify  
that, then in the return values you get a list of filenames via the  
new files field. Use it like this:

$ ansible localhost -m unarchive -a 'src=/var/tmp/foo.tar.gz  
dest=/var/tmp/unarchive list\_files=True' -c local  
localhost | success \>\> {  
&nbsp;&nbsp;&nbsp;&nbsp;"changed": false,  
&nbsp;&nbsp;&nbsp;&nbsp;"check\_results": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"cmd": "/bin/gtar -C \"/var/tmp/unarchive\" --diff -zf  
\"/root/.ansible/tmp/ansible-tmp-1429115525.59-235961690068875/source\"",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"err": "",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"out": "",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"rc": 0,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"unarchived": true  
&nbsp;&nbsp;&nbsp;&nbsp;},  
&nbsp;&nbsp;&nbsp;&nbsp;"dest": "/var/tmp/unarchive",  
&nbsp;&nbsp;&nbsp;&nbsp;"files": [  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"foo/",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"foo/bar.txt"  
&nbsp;&nbsp;&nbsp;&nbsp;],  
&nbsp;&nbsp;&nbsp;&nbsp;"gid": 1000,  
&nbsp;&nbsp;&nbsp;&nbsp;"group": "badger",  
&nbsp;&nbsp;&nbsp;&nbsp;"handler": "TgzArchive",  
&nbsp;&nbsp;&nbsp;&nbsp;"mode": "0755",  
&nbsp;&nbsp;&nbsp;&nbsp;"owner": "badger",  
&nbsp;&nbsp;&nbsp;&nbsp;"secontext": "unconfined\_u:object\_r:user\_tmp\_t:s0",  
&nbsp;&nbsp;&nbsp;&nbsp;"size": 4096,  
&nbsp;&nbsp;&nbsp;&nbsp;"src": "/root/.ansible/tmp/ansible-tmp-1429115525.59-235961690068875/source",  
&nbsp;&nbsp;&nbsp;&nbsp;"state": "directory",  
&nbsp;&nbsp;&nbsp;&nbsp;"uid": 1000  
}

This is a little different than before (where it was all one string in  
the "out" parameter but I think it's a little easier to use too. Hope  
that works for you.

-Toshio

---

<div class="post-metadata">

**Author:** ![user87](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@user87](https://forum.ansible.com/u/user87)\
**Post date:** [April 19, 2015, 4:18pm UTC](https://forum.ansible.com/t/unarchive-module-verbosity/17974/6 "2015-04-19T16:18:31Z")

</div>

Cool! This is awesome!

---

<div class="post-metadata">

**Author:** ![user87](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@user87](https://forum.ansible.com/u/user87)\
**Post date:** [July 8, 2015, 7:26am UTC](https://forum.ansible.com/t/unarchive-module-verbosity/17974/7 "2015-07-08T07:26:17Z")

</div>

Hi tkuratomi,

I just tested with version 1.9.2 and I get  
“msg: unsupported parameter for module: list\_files”

Did this change went into 1.9.2 version or it is still pending?

---

<div class="post-metadata">

**Author:** ![user87](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@user87](https://forum.ansible.com/u/user87)\
**Post date:** [July 8, 2015, 7:30am UTC](https://forum.ansible.com/t/unarchive-module-verbosity/17974/8 "2015-07-08T07:30:34Z")

</div>

please disregard.

Found in docs (added in 2.0)
