# unarchive module: creates does not work

**URL:** <https://forum.ansible.com/t/unarchive-module-creates-does-not-work/16215>\
**Category:** Ansible Project\
**Created:** [September 14, 2014, 12:18pm UTC](https://forum.ansible.com/t/unarchive-module-creates-does-not-work/16215 "2014-09-14T12:18:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Olivier\_Javaux](https://avatars.discourse-cdn.com/v4/letter/o/3da27b/32.png) [@Olivier\_Javaux](https://forum.ansible.com/u/Olivier_Javaux)\
**Post date:** [September 14, 2014, 12:18pm UTC](https://forum.ansible.com/t/unarchive-module-creates-does-not-work/16215/1 "2014-09-14T12:18:32Z")

</div>

I am using ansible 1.8 devel

I have a task like this one:

- name: something  
unarchive: creates=some\_file src=src\_file.tar.gz dest=dest\_dir

Archive is always copied, even if some\_file exists  
Browsing through source code, I saw that there is a runner/action\_plugins/unarchive.py  
file, which makes me think that there is an action named “unarchive”.  
In this file, there is no creates option.  
Maybe some collision between action and module?

Please, could you explain me what is wrong?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [September 14, 2014, 1:29pm UTC](https://forum.ansible.com/t/unarchive-module-creates-does-not-work/16215/2 "2014-09-14T13:29:11Z")

</div>

I believe it may copy the file and only crack it open if it doesn’t exist.

Regardless, please file a bug report with steps to reproduce so someone can take a look.

(Code-wise, if you want to take a look, this is dealt with lib/ansible/runner/action\_plugins/unarchive.py – the actual ansible module is only  
the last bit of it)

Thanks!

---

<div class="post-metadata">

**Author:** ![Jon\_Hadfield](https://avatars.discourse-cdn.com/v4/letter/j/6de8d8/32.png) [@Jon\_Hadfield](https://forum.ansible.com/u/Jon_Hadfield)\
**Post date:** [September 14, 2014, 6:23pm UTC](https://forum.ansible.com/t/unarchive-module-creates-does-not-work/16215/3 "2014-09-14T18:23:15Z")

</div>

I submitted a pull request to fix this issue: [https://github.com/ansible/ansible/pull/8116](https://github.com/ansible/ansible/pull/8116)  
The reason is that the creates option is checked in /library/files/unarchive after it’s already been copied in /lib/ansible/runner/action\_plugins/unarchive.py.  
Simply shifting the check to the action\_plugin prevents an unnecessary file transfer.

---

<div class="post-metadata">

**Author:** ![bry111](https://avatars.discourse-cdn.com/v4/letter/b/7ea924/32.png) [@bry111](https://forum.ansible.com/u/bry111)\
**Post date:** [December 9, 2014, 9:52pm UTC](https://forum.ansible.com/t/unarchive-module-creates-does-not-work/16215/4 "2014-12-09T21:52:27Z")

</div>

Has this been addressed in 1.8.2? I am unable to get the creates parameter to work, and am wondering if I’m doing something wrong.

If I edit /usr/share/pyshared/ansible/runner/action\_plugins/unarchive.py (ansible installed via PPA) and add

`  
print module\_return.result

`

after lines

`  
module\_return = self.runner.\_execute\_module(conn, tmp, ‘stat’, module\_args\_tmp, inject=inject,  
complex\_args=complex\_args, persist\_files=True)

`

it outputs

`  
{u’msg’: u’unsupported parameter for module: creates’, u’failed’: True}

`

which makes me think something is rather wrong.

---

<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:** [December 10, 2014, 1:10am UTC](https://forum.ansible.com/t/unarchive-module-creates-does-not-work/16215/5 "2014-12-10T01:10:27Z")

</div>

The code seems to have gone in quite a while ago. It seems to work  
for me and I'm not getting the same debugging output with 1.8.1 and  
current devel.

I don't believe that there was anything in 1.8.2 that would be  
different from both of those.

The fact that it's saying that creates unsupported when it's calling  
the piece of hte module that run remotely implies to me that ansible  
is finding an older module library on your system. Do you by chance  
have an older checkout somewhere or an older distro package?

-Toshio

---

<div class="post-metadata">

**Author:** ![bry111](https://avatars.discourse-cdn.com/v4/letter/b/7ea924/32.png) [@bry111](https://forum.ansible.com/u/bry111)\
**Post date:** [December 10, 2014, 4:38pm UTC](https://forum.ansible.com/t/unarchive-module-creates-does-not-work/16215/6 "2014-12-10T16:38:47Z")

</div>

Thanks for the suggestion. But to my knowledge I don’t have any other checkouts or packages installed. I even ran `sudo apt-get purge ansible`, and before I reinstalled I

- verified that `find /usr/ -name '*ansible*'` output nothing
- deleted /etc/ansible on the control machine
- deleted ~/.ansible on both the control machine and the remote host

However I have the same result; when unarchive.py tries to stat the file I’ve passed as the creates parameter to unarchive, the stat fails as in my previous message.

---

<div class="post-metadata">

**Author:** ![bry111](https://avatars.discourse-cdn.com/v4/letter/b/7ea924/32.png) [@bry111](https://forum.ansible.com/u/bry111)\
**Post date:** [December 10, 2014, 4:49pm UTC](https://forum.ansible.com/t/unarchive-module-creates-does-not-work/16215/7 "2014-12-10T16:49:45Z")

</div>

Pardon the reply to myself but I’ve stumbled upon a lead. If I use YAML module parameters, like

`

- unarchive:  
src: ‘file.zip’  
dest: ‘/foo’  
creates: ‘/foo/bar’

`

then the creates check never works, as described previously (the unarchive itself still works but it doesn’t check for file existence so it always unarchives). But if instead I use key=value module parameters, like

`

- unarchive: src=‘file.zip’ dest=‘/foo’ creates=‘/foo/bar’

`

then it works fine. Bug?

---

<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:** [December 11, 2014, 6:51am UTC](https://forum.ansible.com/t/unarchive-module-creates-does-not-work/16215/8 "2014-12-11T06:51:42Z")

</div>

Yeah, that would be a bug. Probably best to open a bug report on github so we can look into it and not forget.

-Toshio

---

<div class="post-metadata">

**Author:** ![Capi\_Etheriel](https://avatars.discourse-cdn.com/v4/letter/c/9de053/32.png) [@Capi\_Etheriel](https://forum.ansible.com/u/Capi_Etheriel)\
**Post date:** [December 18, 2014, 9:57pm UTC](https://forum.ansible.com/t/unarchive-module-creates-does-not-work/16215/9 "2014-12-18T21:57:15Z")

</div>

are you using variables in both complex syntax and inline syntax?  
can you post the actual task where you use that module?  
also, are you using copy=false?

---

<div class="post-metadata">

**Author:** ![bry111](https://avatars.discourse-cdn.com/v4/letter/b/7ea924/32.png) [@bry111](https://forum.ansible.com/u/bry111)\
**Post date:** [December 18, 2014, 10:59pm UTC](https://forum.ansible.com/t/unarchive-module-creates-does-not-work/16215/10 "2014-12-18T22:59:54Z")

</div>

> are you using variables in both complex syntax and inline syntax?

Not sure I’m well enough versed in Ansible terminology to understand the question. If by variables in complex syntax you mean accessing nested data structures as in [http://docs.ansible.com/playbooks\_variables.html#accessing-complex-variable-data](http://docs.ansible.com/playbooks_variables.html#accessing-complex-variable-data) then no. But if that’s not what you mean then hopefully the following answers your question anyway.

> can you post the actual task where you use that module?

Sure, with some file names changed to protect the innocent. The following task (inside a custom role) works for me, respecting the creates parameter:

`

- name: extract project  
unarchive: src=‘project-{{ project\_version }}.zip’ dest=‘/opt’ creates=‘{{ project\_dest }}/README.txt’  
sudo: true

`

I also have a defaults/main.yml inside the role containing among other things the following:

`
