– Compress file or directory as zip archive on the Windows node


This plugin is part of the collection (version 1.9.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install

To use it in a playbook, specify:


  • Compress file or directory as zip archive.

  • For non-Windows targets, use the ansible.builtin.archive module instead.


The below requirements are needed on the host that executes this module.

  • .NET Framework 4.5 or later


Parameter Choices/Defaults Comments
path / required
Destination path of zip file (provide absolute path of zip file on the target node).
string / required
File or directory path to be zipped (provide absolute path on the target node).
When a directory path the directory is zipped as the root entry in the archive.
Specify \* to the end of src to zip the contents of the directory and not the directory itself.



  • The filenames in the zip are encoded using UTF-8.

See Also

See also


The official documentation on the ansible.builtin.archive module.


- name: Compress a file
    src: C:\Users\hiyoko\log.txt
    dest: C:\Users\hiyoko\

- name: Compress a directory as the root of the archive
    src: C:\Users\hiyoko\log
    dest: C:\Users\hiyoko\

- name: Compress the directories contents
    src: C:\Users\hiyoko\log\*
    dest: C:\Users\hiyoko\


  • Kento Yagisawa (@hiyoko_taisa)