更新时间:2023-02-26 22:13:56
目前没有来自 ansible 的模块可以在 Windows 上进行 zip 归档.我已经创建了一个简单的模块,就像我使用的 win-unzip 一样,只要在主机上安装了 powershell 4,这应该对你有用.代码在这里:https://github.com/tjkellie/PublicRepo/blob/master/ansible 可以随意使用,直到创建正式模块.
There is no module from ansible currently to do zip archiving on Windows. I've created a simple module that acts like win-unzip that I use, as long as powershell 4 is installed on the host this should work for you. The code is here: https://github.com/tjkellie/PublicRepo/blob/master/ansible feel free to use until an official module is created.
将文件添加到您的库:
library/ # Put the custom modules files here
filter_plugins/
roles/
library/ # or here
并像这样使用剧本中的模块:
And use the module from a playbook like this:
- name: zip a directory
win_zip:
src: C:\Users\Someuser\Logs
dest: C:\Users\Someuser\OldLogs.zip
creates: C:\Users\Someuser\OldLogs.zip