Repository: ansible/ansible-modules-core

Issue:
unarchive issue with ansible 2.1 rc3
##### ISSUE TYPE
- Bug Report
##### COMPONENT NAME

unarchive
##### ANSIBLE VERSION

```
ansible-playbook 2.1.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/yannig/dev/ansible-conf/ansible/playbooks/library']
```
##### CONFIGURATION

None
##### OS / ENVIRONMENT

Nothing special
##### SUMMARY

When using unarchive with Ansible 2.1 rc3, I get an error. Using ansible devel or ansible 2.0 work.
##### STEPS TO REPRODUCE

Get unarchive.yml at the following location: https://github.com/Yannig/yannig-ansible-playbooks/blob/master/unarchive/unarchive.yml

And run it.

```
ansible-playbook unarchive.yml
```
##### EXPECTED RESULTS

```
PLAY [Unarchive problem] *******************************************************

TASK [file] ********************************************************************
changed: [localhost]

TASK [file] ********************************************************************
changed: [localhost]

TASK [get_url] *****************************************************************
changed: [localhost]

TASK [unarchive] ***************************************************************
changed: [localhost]

PLAY RECAP *********************************************************************
localhost                  : ok=4    changed=4    unreachable=0    failed=0
```
##### ACTUAL RESULTS

```
PLAY [Unarchive problem] *******************************************************

TASK [file] ********************************************************************
changed: [localhost]

TASK [file] ********************************************************************
changed: [localhost]

TASK [get_url] *****************************************************************
ok: [localhost]

TASK [unarchive] ***************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Unexpected error when accessing exploded file: [Errno 2] Aucun fichier ou dossier de ce type: '/tmp/unarchive/apache-tomee-plus-1.7.4/webapps'"}

NO MORE HOSTS LEFT *************************************************************
        to retry, use: --limit @unarchive.retry

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=2    unreachable=0    failed=1
```

Note: the devel version is not concerned about this issue.



Discussion:
@Yannig please provide the -vvvv output for the task.

Here it is:

```
TASK [unarchive] ***************************************************************
task path: /home/yannig/dev/yannig/yannig-ansible-playbooks/unarchive/unarchive.yml:10
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: yannig
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1463740074.66-247470451521144 `" && echo ansible-tmp-1463740074.66-247470451521144="` echo $HOME/.ansible/tmp/ansible-tmp-1463740074.66-247470451521144 `" )'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1463740074.72-209795485494442 `" && echo ansible-tmp-1463740074.72-209795485494442="` echo $HOME/.ansible/tmp/ansible-tmp-1463740074.72-209795485494442 `" )'
<127.0.0.1> PUT /tmp/tmpoBVsOJ TO /home/yannig/.ansible/tmp/ansible-tmp-1463740074.72-209795485494442/stat
<127.0.0.1> EXEC /bin/sh -c 'LANG=fr_FR.UTF-8 LC_ALL=fr_FR.UTF-8 LC_MESSAGES=fr_FR.UTF-8 /usr/bin/python /home/yannig/.ansible/tmp/ansible-tmp-1463740074.72-209795485494442/stat; rm -rf "/home/yannig/.ansible/tmp/ansible-tmp-1463740074.72-209795485494442/" > /dev/null 2>&1'
<127.0.0.1> PUT /tmp/apache-tomee-1.7.4-plus.tar.gz TO /home/yannig/.ansible/tmp/ansible-tmp-1463740074.66-247470451521144/source
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1463740074.97-87251443976574 `" && echo ansible-tmp-1463740074.97-87251443976574="` echo $HOME/.ansible/tmp/ansible-tmp-1463740074.97-87251443976574 `" )'
<127.0.0.1> PUT /tmp/tmpRPA_Z8 TO /home/yannig/.ansible/tmp/ansible-tmp-1463740074.97-87251443976574/unarchive
<127.0.0.1> EXEC /bin/sh -c 'LANG=fr_FR.UTF-8 LC_ALL=fr_FR.UTF-8 LC_MESSAGES=fr_FR.UTF-8 /usr/bin/python /home/yannig/.ansible/tmp/ansible-tmp-1463740074.97-87251443976574/unarchive; rm -rf "/home/yannig/.ansible/tmp/ansible-tmp-1463740074.97-87251443976574/" > /dev/null 2>&1'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/yannig/.ansible/tmp/ansible-tmp-1463740074.66-247470451521144/ > /dev/null 2>&1'
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"backup": null, "content": null, "copy": true, "creates": null, "delimiter": null, "dest": "/tmp/unarchive", "directory_mode": null, "exclude": [], "extra_opts": [], "follow": false, "force": null, "group": null, "keep_newer": false, "list_files": false, "mode": null, "original_basename": "apache-tomee-1.7.4-plus.tar.gz", "owner": null, "regexp": null, "remote_src": null, "selevel": null, "serole": null, "setype": null, "seuser": null, "src": "/home/yannig/.ansible/tmp/ansible-tmp-1463740074.66-247470451521144/source"}}, "msg": "Unexpected error when accessing exploded file: [Errno 2] Aucun fichier ou dossier de ce type: '/tmp/unarchive/apache-tomee-plus-1.7.4/webapps'"}
```

The problem is still present in RC4 ...

@Yannig I just tried to reproduce this and couldn't with stable-2.1 (head), or either of the tags: v2.1.0.0-0.3.rc3 or v2.1.0.0-0.4.rc4 .  

Could there be something else going on?  are you running your devel checkout on the same machine as the 2.1-rc4?  Could the machine be running out of disk space on /tmp?  Maybe some other difference between the 2.1 and devel install that could give a clue to reproduce this?

Hi,

/tmp is fine (25Go of free space). I'm using an ubuntu 16.04. Here's the version of various utilities I'm using:
- uname -a

```
Linux travail 4.4.0-22-generic #40-Ubuntu SMP Thu May 12 22:03:46 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
```
- tar --version

```
tar (GNU tar) 1.28
```
- gzip --version

```
gzip 1.6
```

Replacing unarchive.py with the version from 2.0 or from devel fix the problem. I was enable to find the origin of the problem and I don't have much time this next few days.

I was able to fix the problem by forcing LC_ALL=C in unarchive.py. Here is the patch:

``` patch
--- unarchive.py.bak    2016-05-22 22:44:26.000000000 +0200
+++ unarchive.py        2016-05-26 13:58:25.326408590 +0200
@@ -532,7 +532,7 @@
         if self.excludes:
             cmd += ' --exclude="' + '" --exclude="'.join(self.excludes) + '"'
         cmd += ' -f "%s"' % self.src
-        rc, out, err = self.module.run_command(cmd)
+        rc, out, err = self.module.run_command(cmd, environ_update={'LC_ALL': 'C'})

         # Check whether the differences are in something that we're
         # setting anyway
```

By the way, here is my locale:

```
LANG=fr_FR.UTF-8
LANGUAGE=
LC_CTYPE="fr_FR.UTF-8"
LC_NUMERIC="fr_FR.UTF-8"
LC_TIME="fr_FR.UTF-8"
LC_COLLATE="fr_FR.UTF-8"
LC_MONETARY="fr_FR.UTF-8"
LC_MESSAGES="fr_FR.UTF-8"
LC_PAPER="fr_FR.UTF-8"
LC_NAME="fr_FR.UTF-8"
LC_ADDRESS="fr_FR.UTF-8"
LC_TELEPHONE="fr_FR.UTF-8"
LC_MEASUREMENT="fr_FR.UTF-8"
LC_IDENTIFICATION="fr_FR.UTF-8"
LC_ALL=
```

I'm also seeing this issue in the release version of 2.1 (it wasn't happening in 2.0).

In my case I'm running ansible locally on an alpine linux docker image (ansible installed via pip).

I set:

```
mkdir -p /etc/ansible && \
echo 'localhost' > /etc/ansible/hosts
```

Playbook:

```
- hosts: all
  roles:
    - nodejs
```

relevant role tasks:

```
- name: Download node.js
  get_url: url=https://nodejs.org/dist/{{ node_version }}/node-{{ node_version}}.tar.gz
           dest=/node-{{ node_version}}.tar.gz

- name: Extract node.js
  unarchive: src=/node-{{ node_version }}.tar.gz
             dest=/
```

With node_version set to v6.2.0 I get the following output:

```
No config file found; using defaults

PLAYBOOK: nodejs.yml ***********************************************************
1 plays in nodejs.yml

PLAY [all] *********************************************************************

TASK [setup] *******************************************************************
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1464266969.19-11238855454888 `" && echo ansible-tmp-1464266969.19-11238855454888="` echo $HOME/.ansible/tmp/ansible-tmp-1464266969.19-11238855454888 `" ) && sleep 0'
<localhost> PUT /tmp/tmpYL3y6i TO /root/.ansible/tmp/ansible-tmp-1464266969.19-11238855454888/setup
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1464266969.19-11238855454888/setup; rm -rf "/root/.ansible/tmp/ansible-tmp-1464266969.19-11238855454888/" > /dev/null 2>&1 && sleep 0'
ok: [localhost]

TASK [nodejs : Download node.js] ***********************************************
task path: /srv/ansible/roles/nodejs/tasks/main.yml:13
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1464266970.69-77474146385437 `" && echo ansible-tmp-1464266970.69-77474146385437="` echo $HOME/.ansible/tmp/ansible-tmp-1464266970.69-77474146385437 `" ) && sleep 0'
<localhost> PUT /tmp/tmpZbcA0I TO /root/.ansible/tmp/ansible-tmp-1464266970.69-77474146385437/get_url
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1464266970.69-77474146385437/get_url; rm -rf "/root/.ansible/tmp/ansible-tmp-1464266970.69-77474146385437/" > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {"changed": true, "checksum_dest": null, "checksum_src": "228a0c2ff23294778f226e5d7fc85fc2e80a3cd1", "dest": "/node-v6.2.0.tar.gz", "gid": 0, "group": "root", "invocation": {"module_args": {"backup": false, "checksum": "", "content": null, "delimiter": null, "dest": "/node-v6.2.0.tar.gz", "directory_mode": null, "follow": false, "force": false, "force_basic_auth": false, "group": null, "headers": null, "http_agent": "ansible-httpget", "mode": null, "owner": null, "path": "/node-v6.2.0.tar.gz", "regexp": null, "remote_src": null, "selevel": null, "serole": null, "setype": null, "seuser": null, "sha256sum": "", "src": null, "timeout": 10, "tmp_dest": "", "url": "https://nodejs.org/dist/v6.2.0/node-v6.2.0.tar.gz", "url_password": null, "url_username": null, "use_proxy": true, "validate_certs": true}, "module_name": "get_url"}, "md5sum": "aec5b7ca5c16a50848fc446f936cd4ce", "mode": "0644", "msg": "OK (25429125 bytes)", "owner": "root", "size": 25429125, "src": "/tmp/tmpKhW4OP", "state": "file", "uid": 0, "url": "https://nodejs.org/dist/v6.2.0/node-v6.2.0.tar.gz"}

TASK [nodejs : Extract node.js] ************************************************
task path: /srv/ansible/roles/nodejs/tasks/main.yml:29
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1464267007.76-110596763637561 `" && echo ansible-tmp-1464267007.76-110596763637561="` echo $HOME/.ansible/tmp/ansible-tmp-1464267007.76-110596763637561 `" ) && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1464267007.84-212614433683930 `" && echo ansible-tmp-1464267007.84-212614433683930="` echo $HOME/.ansible/tmp/ansible-tmp-1464267007.84-212614433683930 `" ) && sleep 0'
<localhost> PUT /tmp/tmpyQsc_q TO /root/.ansible/tmp/ansible-tmp-1464267007.84-212614433683930/stat
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1464267007.84-212614433683930/stat; rm -rf "/root/.ansible/tmp/ansible-tmp-1464267007.84-212614433683930/" > /dev/null 2>&1 && sleep 0'
<localhost> PUT /node-v6.2.0.tar.gz TO /root/.ansible/tmp/ansible-tmp-1464267007.76-110596763637561/source
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1464267008.08-241031603158567 `" && echo ansible-tmp-1464267008.08-241031603158567="` echo $HOME/.ansible/tmp/ansible-tmp-1464267008.08-241031603158567 `" ) && sleep 0'
<localhost> PUT /tmp/tmpe6fjyT TO /root/.ansible/tmp/ansible-tmp-1464267008.08-241031603158567/unarchive
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1464267008.08-241031603158567/unarchive; rm -rf "/root/.ansible/tmp/ansible-tmp-1464267008.08-241031603158567/" > /dev/null 2>&1 && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1464267007.76-110596763637561/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"backup": null, "content": null, "copy": true, "creates": null, "delimiter": null, "dest": "/", "directory_mode": null, "exclude": [], "extra_opts": [], "follow": false, "force": null, "group": null, "keep_newer": false, "list_files": false, "mode": null, "original_basename": "node-v6.2.0.tar.gz", "owner": null, "regexp": null, "remote_src": null, "selevel": null, "serole": null, "setype": null, "seuser": null, "src": "/root/.ansible/tmp/ansible-tmp-1464267007.76-110596763637561/source"}}, "msg": "Unexpected error when accessing exploded file: [Errno 2] No such file or directory: '/node-v6.2.0'"}

NO MORE HOSTS LEFT *************************************************************
    to retry, use: --limit @nodejs.retry

PLAY RECAP *********************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=1
```

As mentioned, this was working previously under Ansible 2.0. Is there any further information I can provide to help figure this out?

Thanks @Yannig !  That is extremely helpful.

Sorry, I didn't see the recent updates before posting (I should have refreshed the page).

I've tried adding the LC_ALL environment variable to the task (to see if it would work as a workaround for now) like so:

```
- name: Extract node.js
  unarchive: src=/node-{{ node_version }}.tar.gz
             dest=/
  environment:
    LC_ALL: C
```

but it still fails:

```
TASK [nodejs : Extract node.js] ************************************************
task path: /srv/ansible/roles/nodejs/tasks/main.yml:29
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1464268855.99-237067909623425 `" && echo ansible-tmp-1464268855.99-237067909623425="` echo $HOME/.ansible/tmp/ansible-tmp-1464268855.99-237067909623425 `" ) && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1464268856.07-44577399003204 `" && echo ansible-tmp-1464268856.07-44577399003204="` echo $HOME/.ansible/tmp/ansible-tmp-1464268856.07-44577399003204 `" ) && sleep 0'
<localhost> PUT /tmp/tmpRFC5gD TO /root/.ansible/tmp/ansible-tmp-1464268856.07-44577399003204/stat
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=C LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1464268856.07-44577399003204/stat; rm -rf "/root/.ansible/tmp/ansible-tmp-1464268856.07-44577399003204/" > /dev/null 2>&1 && sleep 0'
<localhost> PUT /node-v6.2.0.tar.gz TO /root/.ansible/tmp/ansible-tmp-1464268855.99-237067909623425/source
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1464268856.33-103837916642216 `" && echo ansible-tmp-1464268856.33-103837916642216="` echo $HOME/.ansible/tmp/ansible-tmp-1464268856.33-103837916642216 `" ) && sleep 0'
<localhost> PUT /tmp/tmpeNWmDR TO /root/.ansible/tmp/ansible-tmp-1464268856.33-103837916642216/unarchive
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=C LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1464268856.33-103837916642216/unarchive; rm -rf "/root/.ansible/tmp/ansible-tmp-1464268856.33-103837916642216/" > /dev/null 2>&1 && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1464268855.99-237067909623425/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"backup": null, "content": null, "copy": true, "creates": null, "delimiter": null, "dest": "/", "directory_mode": null, "exclude": [], "extra_opts": [], "follow": false, "force": null, "group": null, "keep_newer": false, "list_files": false, "mode": null, "original_basename": "node-v6.2.0.tar.gz", "owner": null, "regexp": null, "remote_src": null, "selevel": null, "serole": null, "setype": null, "seuser": null, "src": "/root/.ansible/tmp/ansible-tmp-1464268855.99-237067909623425/source"}}, "msg": "Unexpected error when accessing exploded file: [Errno 2] No such file or directory: '/node-v6.2.0'"}
```

Darn, that might mean that there's more than one bug here.  I'm working through several issues with unarchive right now.  Let me try and get a fix in place for @Yannig's bug in (and any other calls to run_command that may occur in the module).  If it still happens for you after that, I'll have you open a new bug to diagnose the issue.

Okay @Yannig and @wp-davisona give that PR a try and see if it fixes things.  If it works for Yannig i can merge and we can close this bug.  If it fixes for Yannig but does not work for wp-davisona then we should open a new bug for wp-davisona's symptoms and try to track that down separately.

Sorry, this still doesn't work for me:

```
ansible 2.2.0 (devel c03555b650) last updated 2016/05/27 10:25:49 (GMT +000)
  lib/ansible/modules/core: (fix-unarchive-screenscraping 59e784d839) last updated 2016/05/27 10:26:32 (GMT +000)
  lib/ansible/modules/extras: (detached HEAD 0e4a023a7e) last updated 2016/05/27 10:26:30 (GMT +000)
  config file =
  configured module search path = Default w/o overrides
```

Extract command with no environment variables set:

```
- name: Extract node.js
  unarchive: src=/node-{{ node_version }}.tar.gz
             dest=/
```

Output:

```
TASK [nodejs : Extract node.js] ************************************************
task path: /srv/ansible/roles/nodejs/tasks/main.yml:29
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1464345577.57-191517768640143 `" && echo ansible-tmp-1464345577.57-191517768640143="` echo $HOME/.ansible/tmp/ansible-tmp-1464345577.57-191517768640143 `" ) && sleep 0'
Using module file /ansible/lib/ansible/modules/core/files/stat.py
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1464345577.65-15103029751682 `" && echo ansible-tmp-1464345577.65-15103029751682="` echo $HOME/.ansible/tmp/ansible-tmp-1464345577.65-15103029751682 `" ) && sleep 0'
<localhost> PUT /tmp/tmppXQueK TO /root/.ansible/tmp/ansible-tmp-1464345577.65-15103029751682/stat.py
<localhost> EXEC /bin/sh -c 'chmod -R u+x /root/.ansible/tmp/ansible-tmp-1464345577.65-15103029751682/ && sleep 0'
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1464345577.65-15103029751682/stat.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1464345577.65-15103029751682/" > /dev/null 2>&1 && sleep 0'
<localhost> PUT /node-v6.2.0.tar.gz TO /root/.ansible/tmp/ansible-tmp-1464345577.57-191517768640143/source
<localhost> EXEC /bin/sh -c 'chmod -R u+x /root/.ansible/tmp/ansible-tmp-1464345577.57-191517768640143/ && sleep 0'
Using module file /ansible/lib/ansible/modules/core/files/unarchive.py
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1464345577.93-134195304746468 `" && echo ansible-tmp-1464345577.93-134195304746468="` echo $HOME/.ansible/tmp/ansible-tmp-1464345577.93-134195304746468 `" ) && sleep 0'
<localhost> PUT /tmp/tmpnI2nuB TO /root/.ansible/tmp/ansible-tmp-1464345577.93-134195304746468/unarchive.py
<localhost> EXEC /bin/sh -c 'chmod -R u+x /root/.ansible/tmp/ansible-tmp-1464345577.93-134195304746468/ && sleep 0'
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1464345577.93-134195304746468/unarchive.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1464345577.93-134195304746468/" > /dev/null 2>&1 && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1464345577.57-191517768640143/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"backup": null, "content": null, "copy": true, "creates": null, "delimiter": null, "dest": "/", "directory_mode": null, "exclude": [], "extra_opts": [], "follow": false, "force": null, "group": null, "keep_newer": false, "list_files": false, "mode": null, "original_basename": "node-v6.2.0.tar.gz", "owner": null, "regexp": null, "remote_src": null, "selevel": null, "serole": null, "setype": null, "seuser": null, "src": "/root/.ansible/tmp/ansible-tmp-1464345577.57-191517768640143/source", "validate_certs": true}}, "msg": "Unexpected error when accessing exploded file: [Errno 2] No such file or directory: '/node-v6.2.0'"}
```

Extract command trying with environment variables:

```
- name: Extract node.js
  unarchive: src=/node-{{ node_version }}.tar.gz
             dest=/
  environment:
    LANG: C
    LC_ALL: C
    LC_MESSAGES: C
```

Output:

```
TASK [nodejs : Extract node.js] ************************************************
task path: /srv/ansible/roles/nodejs/tasks/main.yml:29
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1464345844.23-269035133202983 `" && echo ansible-tmp-1464345844.23-269035133202983="` echo $HOME/.ansible/tmp/ansible-tmp-1464345844.23-269035133202983 `" ) && sleep 0'
Using module file /ansible/lib/ansible/modules/core/files/stat.py
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1464345844.31-144548982599267 `" && echo ansible-tmp-1464345844.31-144548982599267="` echo $HOME/.ansible/tmp/ansible-tmp-1464345844.31-144548982599267 `" ) && sleep 0'
<localhost> PUT /tmp/tmpdnGsdl TO /root/.ansible/tmp/ansible-tmp-1464345844.31-144548982599267/stat.py
<localhost> EXEC /bin/sh -c 'chmod -R u+x /root/.ansible/tmp/ansible-tmp-1464345844.31-144548982599267/ && sleep 0'
<localhost> EXEC /bin/sh -c 'LANG=C LC_MESSAGES=C LC_ALL=C /usr/bin/python /root/.ansible/tmp/ansible-tmp-1464345844.31-144548982599267/stat.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1464345844.31-144548982599267/" > /dev/null 2>&1 && sleep 0'
<localhost> PUT /node-v6.2.0.tar.gz TO /root/.ansible/tmp/ansible-tmp-1464345844.23-269035133202983/source
<localhost> EXEC /bin/sh -c 'chmod -R u+x /root/.ansible/tmp/ansible-tmp-1464345844.23-269035133202983/ && sleep 0'
Using module file /ansible/lib/ansible/modules/core/files/unarchive.py
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1464345844.6-241415176733621 `" && echo ansible-tmp-1464345844.6-241415176733621="` echo $HOME/.ansible/tmp/ansible-tmp-1464345844.6-241415176733621 `" ) && sleep 0'
<localhost> PUT /tmp/tmpujdk9S TO /root/.ansible/tmp/ansible-tmp-1464345844.6-241415176733621/unarchive.py
<localhost> EXEC /bin/sh -c 'chmod -R u+x /root/.ansible/tmp/ansible-tmp-1464345844.6-241415176733621/ && sleep 0'
<localhost> EXEC /bin/sh -c 'LANG=C LC_MESSAGES=C LC_ALL=C /usr/bin/python /root/.ansible/tmp/ansible-tmp-1464345844.6-241415176733621/unarchive.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1464345844.6-241415176733621/" > /dev/null 2>&1 && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1464345844.23-269035133202983/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"backup": null, "content": null, "copy": true, "creates": null, "delimiter": null, "dest": "/", "directory_mode": null, "exclude": [], "extra_opts": [], "follow": false, "force": null, "group": null, "keep_newer": false, "list_files": false, "mode": null, "original_basename": "node-v6.2.0.tar.gz", "owner": null, "regexp": null, "remote_src": null, "selevel": null, "serole": null, "setype": null, "seuser": null, "src": "/root/.ansible/tmp/ansible-tmp-1464345844.23-269035133202983/source", "validate_certs": true}}, "msg": "Unexpected error when accessing exploded file: [Errno 2] No such file or directory: '/node-v6.2.0'"}
```

Just re-iterating this is on an alpine docker image (but it was working previously in 2.0). I'll try against an ubuntu image and see if the behaviour is different.

Work for me :)

Thanks @abadger 

I don't have this problem on a Docker Ubuntu image even with stock Ansible 2.1:

```
TASK [nodejs : Extract node.js] ************************************************
task path: /srv/ansible/roles/nodejs/tasks/main.yml:29
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1464349685.69-258414283248355 `" && echo ansible-tmp-1464349685.69-258414283248355="` echo $HOME/.ansible/tmp/ansible-tmp-1464349685.69-258414283248355 `" ) && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1464349685.76-274695190698836 `" && echo ansible-tmp-1464349685.76-274695190698836="` echo $HOME/.ansible/tmp/ansible-tmp-1464349685.76-274695190698836 `" ) && sleep 0'
<localhost> PUT /tmp/tmpVBx7hz TO /root/.ansible/tmp/ansible-tmp-1464349685.76-274695190698836/stat
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1464349685.76-274695190698836/stat; rm -rf "/root/.ansible/tmp/ansible-tmp-1464349685.76-274695190698836/" > /dev/null 2>&1 && sleep 0'
<localhost> PUT /node-v6.2.0.tar.gz TO /root/.ansible/tmp/ansible-tmp-1464349685.69-258414283248355/source
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1464349686.03-245121372317490 `" && echo ansible-tmp-1464349686.03-245121372317490="` echo $HOME/.ansible/tmp/ansible-tmp-1464349686.03-245121372317490 `" ) && sleep 0'
<localhost> PUT /tmp/tmpPJcvon TO /root/.ansible/tmp/ansible-tmp-1464349686.03-245121372317490/unarchive
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1464349686.03-245121372317490/unarchive; rm -rf "/root/.ansible/tmp/ansible-tmp-1464349686.03-245121372317490/" > /dev/null 2>&1 && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1464349685.69-258414283248355/ > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {"changed": true, "dest": "/", "extract_results": {"cmd": "/bin/tar -C \"/\" -xz -f \"/root/.ansible/tmp/ansible-tmp-1464349685.69-258414283248355/source\"", "err": "", "out": "", "rc": 0}, "gid": 0, "group": "root", "handler": "TgzArchive", "invocation": {"module_args": {"backup": null, "content": null, "copy": true, "creates": null, "delimiter": null, "dest": "/", "directory_mode": null, "exclude": [], "extra_opts": [], "follow": false, "force": null, "group": null, "keep_newer": false, "list_files": false, "mode": null, "original_basename": "node-v6.2.0.tar.gz", "owner": null, "regexp": null, "remote_src": null, "selevel": null, "serole": null, "setype": null, "seuser": null, "src": "/root/.ansible/tmp/ansible-tmp-1464349685.69-258414283248355/source"}}, "mode": "0755", "owner": "root", "size": 4096, "src": "/root/.ansible/tmp/ansible-tmp-1464349685.69-258414283248355/source", "state": "directory", "uid": 0}
```

So I'm so far only seeing the problem on a Docker alpine linux image, which may be due to it being a minimal image and may be missing some expected dependencies. Should I raise a separate issue?

@wp-davisona indeed. In order to be able to extract something on a docker container, you need to install tar and gunzip/bzip2/whatever on you container.

Oh. Yes. Well if that isn't a big facepalm moment! Sorry for all the extra noise. I'm a little confused as to why it worked previously, but that's something I can investigate on my own, I have a working solution now. Many thanks!


Resolving patch:
diff --git a/files/unarchive.py b/files/unarchive.py
--- a/files/unarchive.py
+++ b/files/unarchive.py
@@ -701,6 +701,9 @@ def main():
 #        supports_check_mode = True,
     )
 
+    # We screenscrape a huge amount of commands so use C locale anytime we do
+    module.run_command_environ_update = dict(LANG='C', LC_ALL='C', LC_MESSAGES='C', LC_CTYPE='C')
+
     src    = os.path.expanduser(module.params['src'])
     dest   = os.path.expanduser(module.params['dest'])
     copy   = module.params['copy']


Test patch: