AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,100 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example" published by Apress, and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

Ansible win_unzip Module: Extract ZIP Archives on Windows (Guide)

By Luca Berton · Published 2024-01-01 · Category: installation

How to extract ZIP archives on Windows with Ansible win_unzip module (community.windows.win_unzip). Unzip files, extract to directory. Practical YAML playbook examples.

How to extract a ZIP compressed archive in Windows-like systems in Ansible?

I'm going to show you a live Playbook and some simple Ansible code. I'm Luca Berton and welcome to today's episode of Ansible Pilot.

Ansible extracts an archive in Windows-like systems • community.windows.win_unzip • Unzips compressed files and archives on the Windows node

Today we're talking about the Ansible module win_unzip. The full name is community.windows.win_unzip, which means that is part of modules maintained by the community for Windows target hosts. It unzips compressed files and archives on the Windows node. It supports .zip files natively and can handle also other 7zip formats when combined with the Powershell Community Extensions (PSCX) module. For Linux targets, use the ansible.builtin.unarchive module.

Parameters • src string - remote path • dest string - remote path • password string - password (require PSCX) • recurse boolean - no/yes - recursively expand zip files (require PSCX)

The parameters of module win_unzip. The only mandatory parameters are "src" and "dest" which are the source and destination paths. The "src" is quite special because is supposed to be a remote path on Windows-like systems. The following two parameters require Powershell Community Extensions (PSCX) module. You could specify the encryption password to expand the archive in the "password" parameter. You could recursively expand zip files inside an archive enabling the "recurse" boolean.

LinksAnsible module win_unzip

## Playbook

How to extract an archive in Windows-like systems with Ansible Playbook.

code

code with ❤️ in GitHub

execution

NOT idempotent

before execution

!example.zip input before execution

after execution

!output folder after execution

Conclusion Now you know how to extract an archive in Windows-like systems with Ansible.

Extract ZIP File

Download and Extract

Extract with Password (7zip)

Deployment Pattern

win_unzip Parameters

| Parameter | Description | |-----------|-------------| | src | Path to archive on Windows host | | dest | Extraction destination | | creates | Skip if this path exists | | delete_archive | Remove ZIP after extraction | | password | Archive password (7zip only) | | recurse | Extract nested archives |

Supported Formats

| Format | Requires | |--------|----------| | .zip | Built-in (PowerShell) | | .7z | 7-Zip installed | | .tar.gz | 7-Zip installed | | .rar | 7-Zip installed |

FAQ

How do I install 7-Zip for non-ZIP formats?

Linux equivalent?

Use ansible.builtin.unarchive module for Linux/macOS.

Why does extraction fail silently?

Check destination permissions and available disk space. Use -vvv for verbose output.

Related ArticlesAnsible Become GuideAnsible Inventory GuideAnsible for Windows Guide

Category: installation

Watch the video: Ansible win_unzip Module: Extract ZIP Archives on Windows (Guide) — Video Tutorial

Browse all Ansible tutorials · AnsiblePilot Home