Ansible模块s3 - mode =获取错误

时间:2015-11-13 11:58:14

标签: ansible ansible-playbook

- name: download files from s3 but dont download if the file checksums match
  s3: bucket=bname object=/file.gz dest=/opt/tmp/file.gz mode=get

以上代码段正常工作并提取文件。从s3开始gz并将其放在/ opt / tmp / location

但是,如果我要重新运行上述任务(当文件已下载一次且出现在/ opt / tmp /时),则会抛出错误 -

  

msg:上传的文件   校验和不支持多部分s3,无法计算   校验和。

我尝试使用overwrite=different

# GET an object but dont download if the file checksums match
s3: bucket=bname object=/file.gz dest=/opt/tmp/file.gz mode=get overwrite=different

但我收到了错误 -

  

msg:布尔值不同于布尔列表

关于如何确保我可以无忧无虑地重新运行任务的任何变通方法或建议都会有所帮助,谢谢。

1 个答案:

答案 0 :(得分:2)

- shell: if [[ -f "/opt/tmp/file.gz" ]]; then /bin/true; else /bin/false; fi
  register: result
  ignore_errors: True

- name: download files from s3 but dont download if the file exists
  s3: bucket=bname object=/file.gz dest=/opt/tmp/file.gz mode=get
  when: result|failed

解决方法 - 检查文件是否存在,跳过 - 如果文件存在并下载 - 如果文件不存在。

https://github.com/ansible/ansible/issues/5442 解释类似的问题

相关问题