Note
This plugin is part of the community.windows collection.
To install it use: ansible-galaxy collection install community.windows.
To use it in a playbook, specify: community.windows.win_unzip.
The below requirements are needed on the host that executes this module.
| Parameter | Choices/Defaults | Comments |
|---|---|---|
| creates path | If this file or directory exists the specified src will not be extracted. | |
| delete_archive boolean |
| Remove the zip file, after unzipping. aliases: rm |
| dest path / required | Destination of zip file (provide absolute path of directory). If it does not exist, the directory will be created. | |
| password string | If a zip file is encrypted with password. Passing a value to a password parameter requires the PSCX module to be installed. | |
| recurse boolean |
| Recursively expand zipped files within the src file. Setting to a value of yes requires the PSCX module to be installed. |
| src path / required | File to be unzipped (provide absolute path). |
Note
See also
The official documentation on the ansible.builtin.unarchive module.
# 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=yes" all
- name: Unzip a bz2 (BZip) file
community.windows.win_unzip:
src: C:\Users\Phil\Logs.bz2
dest: C:\Users\Phil\OldLogs
creates: C:\Users\Phil\OldLogs
- name: Unzip gz log
community.windows.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: Recursively decompress GZ files in ApplicationLogs.zip
community.windows.win_unzip:
src: C:\Downloads\ApplicationLogs.zip
dest: C:\Application\Logs
recurse: yes
delete_archive: yes
- name: Install PSCX
community.windows.win_psmodule:
name: Pscx
state: present
- name: Unzip .7z file which is password encrypted
community.windows.win_unzip:
src: C:\Downloads\ApplicationLogs.7z
dest: C:\Application\Logs
password: abcd
delete_archive: yes
Common return values are documented here, the following are the fields unique to this module:
| Key | Returned | Description |
|---|---|---|
| dest string | always | The provided destination path Sample: C:\ExtractedLogs\application-error-logs |
| removed boolean | always | Whether the module did remove any files during task run Sample: True |
| src string | always | The provided source path Sample: C:\Logs\application-error-logs.gz |
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.10/collections/community/windows/win_unzip_module.html