我有这个任务:
- archive:
path: ./my_dir
dest: ./dir.zip
format: zip
结果
dir.zip
包含一个目录 my_dir/
。是否可以在压缩时重命名目录,将其称为“whatever/”而不是“my_dir/”?
我无法重命名原始目录。我想在压缩时重命名它。
压缩时可以重命名目录吗?
不,这还没有实施。但根据文档Examples,一个最小的示例剧本
---
- hosts: localhost
become: false
gather_facts: false
tasks:
- archive:
path: test/*
dest: test.zip
format: zip
将生成内容为
的 ZIP 文件unzip -t test.zip
Archive: test.zip
testing: folder/one OK
testing: folder/two OK
testing: folder/three OK
testing: one OK
testing: three OK
testing: two OK
No errors detected in compressed data of test.zip.
这意味着,创建全局路径的存档将省略不需要的目录名称,并提供在提取过程中指定其他目录的机会。