New in version 2.0.
| parameter | required | default | choices | comments |
|---|---|---|---|---|
| creates | no | If this file or directory exists the specified src will not be extracted. | ||
| delete_archive | no | no |
| Remove the zip file, after unzipping. aliases: rm |
| dest | yes | Destination of zip file (provide absolute path of directory). If it does not exist, the directory will be created. | ||
| recurse | no | no |
| Recursively expand zipped files within the src file. |
| src | yes | File to be unzipped (provide absolute path). |
# This unzips a library that was downloaded with win_get_url, and removes the file after extraction
# $ ansible -i hosts -m win_unzip -a "src=C:\LibraryToUnzip.zip dest=C:\Lib remove=true" all
- name: Unzip a bz2 (BZip) file
win_unzip:
src: C:\Users\Phil\Logs.bz2
dest: C:\Users\Phil\OldLogs
creates: C:\Users\Phil\OldLogs
- name: Unzip gz log
win_unzip:
src: C:\Logs\application-error-logs.gz
dest: C:\ExtractedLogs\application-error-logs
# Unzip .zip file, recursively decompresses the contained .gz files and removes all unneeded compressed files after completion.
- name: Unzip ApplicationLogs.zip and decompress all GZipped log files
hosts: all
gather_facts: false
tasks:
- name: Recursively decompress GZ files in ApplicationLogs.zip
win_unzip:
src: C:\Downloads\ApplicationLogs.zip
dest: C:\Application\Logs
recurse: yes
delete_archive: yes
# Install PSCX to use for extracting a gz file
- name: Grab PSCX msi
win_get_url:
url: http://download-codeplex.sec.s-msft.com/Download/Release?ProjectName=pscx&DownloadId=923562&FileTime=130585918034470000&Build=20959
dest: C:\Windows\Temp\pscx.msi
- name: Install PSCX
win_msi:
path: C:\Windows\Temp\pscx.msi
Common return values are documented here Return Values, the following are the fields unique to this module:
| name | description | returned | type | sample |
|---|---|---|---|---|
| dest | The provided destination path | always | string | C:\ExtractedLogs\application-error-logs |
| src | The provided source path | always | string | C:\Logs\application-error-logs.gz |
| removed | Whether the module did remove any files during task run | always | boolean | True |
Note
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.
© 2012–2017 Michael DeHaan
© 2017 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/win_unzip_module.html