Ansible: unzipping an encrypted file using the unarchive module

If you need to expand an encrypted zip file using the Ansible unarchive module, then you will need to provide the password using the ‘extra_opts’ parameter.

Per below, make sure you place the “-P” flag as an independent argument to the password.

- name: unzip encrypted zip
  unarchive:
    src: mysource.zip
    dest: /remote/path
  extra_opts:
    - "-P"
    - "theP4ssword!"

REFERENCES

unzip man page

Ansible unarchive module

NOTES

If the zip is already on the remote host, you can use the ‘remote_src’ parameter.