本文介绍了Ansible 2.4的aws_s3模块版本ID错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的任务,即从s3存储桶下载文件,该文件可与Ansible 2.3正常运行,当我将ansible从2.3升级到2.4时,它抱怨说我需要使用aws_s3模块而不是我所做的s3并获得出现以下错误:

I have simple task to download file from s3 bucket which works fine with Ansible 2.3, when I have upgraded the ansible from 2.3 to 2.4, it complain that I need to use the aws_s3 module instead of s3 which I did and getting the following error:

─➤ansible-playbook -i localhost, playbook.yml                                                                    4 ↵


PLAY [all] *******************************************************************************************************************


TASK [Download the latest version of from S3 bucket] *************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Key /node/qa/1.0.483/node.tar.gz with version id None does not exist."}


PLAY RECAP *******************************************************************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=1

这是我的任务:

- name: Download the latest version of from S3 bucket
  aws_s3:
    aws_access_key: "xxxxxxxxxxx"
    aws_secret_key: "yyyyyyyyyyyyyyyyyyyyyyy"
    bucket: "artifacts-bucket"
    object: "/node/qa/1.0.483/node.tar.gz"
    mode: get
    dest: "node.tar.gz"

一些注意事项:-我的s3存储桶未启用版本控制-安装了aws_s3模块所需的boto3-相同的任务在ansible 2.3上可以正常工作,并且确实给出了此错误

Few notes:- versioning is not enabled on my s3 bucket- installed the boto3 that is the requirement for aws_s3 module- the exact same tasks work fine with ansible 2.3 and did give this error

"Key /node/qa/1.0.483/node.tar.gz with version id None does not exist."

推荐答案

由于 boto3 ,存在一个错误.在将该模块移植到boto3 object之前:/path/to/object 引用了 bucketname/path/to/object .在2.4版中,它变成了 bucketname//path/to/object .

There is a bug due to boto3. Prior to porting this module to boto3 object: /path/to/object refered to bucketname/path/to/object. In 2.4 this became bucketname//path/to/object.

忽略导入/导入对象是一种解决方法.该代码对我有用:

Omitting the leading / in object is a workaround. This code work for me:

- name: Download the latest version of from S3 bucket
  aws_s3:
    aws_access_key: "xxxxxxxxxxx"
    aws_secret_key: "yyyyyyyyyyyyyyyyyyyyyyy"
    bucket: "artifacts-bucket"
    object: "node/qa/1.0.483/node.tar.gz"
    mode: get
    dest: "node.tar.gz"

希望它会对其他人有帮助.在ansible github存储库上打开一个错误,希望它将在Ansible 2.4.1中修复

Hope it will help other. Open a bug over ansible github repo, hopefully it will fix in Ansible 2.4.1

这篇关于Ansible 2.4的aws_s3模块版本ID错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 19:46