解压缩压缩文件和存档。
本机支持.zip文件。
支持Powershell社区扩展(PSCX)模块支持的其他格式(基本上是7zip支持的所有内容)
参数 | 选项 | 作用 |
---|---|---|
creates | 如果此文件或目录存在,则不会提取指定的src | |
delete_archive | no / yes | 解压缩后删除zip文件,默认为no,别名: rm |
dest | zip文件的目的地(提供目录的绝对路径)。如果它不存在,将创建该目录 | |
recurse | no / yes | 递归扩展src文件中的压缩文件,如果设置为yes需要安装PSCX模块 |
src | 要解压缩的文件(提供绝对路径) |
模块使用
#Ansible方式
[root@squid win_inzip]# ansible windows -m win_unzip -a 'creates=yes rm=no src=c:\\at.zip dest=c:\\win_unzip_test\\'
10.241.0.4 | SUCCESS => {
"changed": true,
"dest": "c:\\win_unzip_test\\",
"removed": false,
"src": "c:\\at.zip"
}
#playbook方式
[root@squid win_unzip]# cat win_unzip_at.yaml
---
- hosts: windows
tasks:
- name: unzip at.zip
win_unzip:
src: "c:\\at.zip"
dest: "c:\\win_unzip_test\\"
creates: yes
delete_archive: no
[root@squid win_unzip]# ansible-playbook win_unzip_at.yaml
PLAY [windows] *************************************************************
TASK [unzip at.zip] ********************************************************
changed: [10.241.0.4]
PLAY RECAP *****************************************************************
10.241.0.4 : ok=1 changed=1 unreachable=0 failed=0