我只想从 yaml 文件 download.yaml 下载文件(仅当它们发生更改时)。
我已经找到了这个/sf/answers/1586792441/但似乎 ansible 仍然下载整个文件,即使它没有改变
playbook.yaml 中的任务:
tasks:
- name: Download File
get_url:
url="{{ item.value.url }}"
dest="{{ item.value.dest }}{{item.value.file }}"
loop: "{{ lookup('dict', dl) }}"
Run Code Online (Sandbox Code Playgroud)
下载.yaml:
dl:
4mlinux:
dest: /var/www/html/live/asset-mirror/releases/download/36.1-39ff9a19/
file: vmlinuz
url: https://github.com/netbootxyz/asset-mirror/releases/download/36.1-39ff9a19/vmlinuz
4mlinux-antivirus:
dest: /var/www/html/live/asset-mirror/releases/download/37.0-0.103.2-ba9e3ece/
file: vmlinuz
url: https://github.com/netbootxyz/asset-mirror/releases/download/37.0-0.103.2-ba9e3ece/vmlinuz
4mlinux-bakandimg:
dest: /var/www/html/live/asset-mirror/releases/download/36.0-262576bf/
file: vmlinuz
url: https://github.com/netbootxyz/asset-mirror/releases/download/36.0-262576bf/vmlinuz
Run Code Online (Sandbox Code Playgroud)
编辑:
为了让我的问题更清楚。
Github 不提供版本的哈希值,请参阅此处Where to get MD5 hashes from a GitHub release?
我想避免自己计算校验和,因为校验和download.yaml是从另一个 yaml 文件生成的。
get_url如果模块仅检查文件的大小就足够了。
Edit2:
Ansible 仍然下载整个文件。以下是详细输出示例:
ok: [127.0.0.1] => (item={'key': …Run Code Online (Sandbox Code Playgroud) ansible ×1