# Unarchive nested zip file from local to remote directory

**URL:** <https://forum.ansible.com/t/unarchive-nested-zip-file-from-local-to-remote-directory/26027>\
**Category:** Ansible Project\
**Created:** [November 15, 2017, 9:38am UTC](https://forum.ansible.com/t/unarchive-nested-zip-file-from-local-to-remote-directory/26027 "2017-11-15T09:38:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dev](https://avatars.discourse-cdn.com/v4/letter/d/e8c25b/32.png) [@Dev](https://forum.ansible.com/u/Dev)\
**Post date:** [November 15, 2017, 9:38am UTC](https://forum.ansible.com/t/unarchive-nested-zip-file-from-local-to-remote-directory/26027/1 "2017-11-15T09:38:48Z")

</div>

Hello everyone,

How in easiest way can I unarchive .zip file, with nested structure, from local to remote directory? Example below:

Local directory:

~/pack.zip  
└── pack  
├── bin  
│ ├── file1  
│ └── file2  
├── conf  
│ ├── file3  
│ └── file4  
└── lib  
├── file5  
└── file6

And I want to unarchive pack to 3 remote directories:  
~/bin  
├── file1  
└── file2  
~/conf  
├── file3  
└── file4  
~/lib  
├── file5  
└── file6

Problem is that I have an nested directory ‘pack’, so when I just use unarchive module I getting:  
~/pack  
├── bin  
│ ├── file1  
│ └── file2  
├── conf  
│ ├── file3  
│ └── file4  
└── lib  
├── file5  
└── file6

Unfortunately unix unzip package doesn’t contain _–strip-components_ option.

Additionally ansible remote\_src parameter doesn’t support recursive copying, co I can’t unpack zip archive to the /tmp directory and next copy all 3 directories (bin, conf and lib) to my remote home folder.

Theoretically I can use

`unzip -j pack.zip 'pack/bin/*' -d bin`unzip -j `pack`.zip 'pack/`conf/*' -d `conf` `unzip -j `pack`.zip 'pack/`lib/*' -d `lib` `  
or simple move those three directories to the destination folder, but this is beyond ansible solution.

Do you have any idea?

---

<div class="post-metadata">

**Author:** ![ZillaYT](https://avatars.discourse-cdn.com/v4/letter/z/4da419/32.png) [@ZillaYT](https://forum.ansible.com/u/ZillaYT)\
**Post date:** [November 15, 2017, 1:30pm UTC](https://forum.ansible.com/t/unarchive-nested-zip-file-from-local-to-remote-directory/26027/2 "2017-11-15T13:30:46Z")

</div>

You can’t. Ansible just calls the appropriate uncompress application, in this case, unzip. You can’t do what you want in unzip, so Ansible can’t do it.

---

<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:** [November 15, 2017, 2:22pm UTC](https://forum.ansible.com/t/unarchive-nested-zip-file-from-local-to-remote-directory/26027/3 "2017-11-15T14:22:48Z")

</div>

Sometimes the only solution is to use the shell or the command module.
