我正在运行具有分配的Iamangular色的EC2实例上的Ansible。 我正在运行这个剧本:
$ cat s3.yaml --- - hosts: localhost remote_user: ec2-user tasks: - name: download ec2.py from s3 s3: bucket: mybucket object: /ec2.py dest: /tmp/ec2.py mode: get
用-vvv运行它提供了这个错误信息:
fatal: [localhost]: FAILED! => { "changed": false, "failed": true, "invocation": { "module_args": { "aws_access_key": null, "aws_secret_key": null, "bucket": "mybucket", "dest": "/tmp/ec2.py", "ec2_url": null, "encrypt": true, "expiry": "600", "headers": null, "marker": null, "max_keys": "1000", "metadata": null, "mode": "get", "object": "/ec2.py", "overwrite": "always", "permission": [ "private" ], "prefix": null, "profile": null, "region": null, "retries": 0, "rgw": false, "s3_url": null, "security_token": null, "src": null, "validate_certs": true, "version": null }, "module_name": "s3" }, "msg": "Source bucket cannot be found" }
根据文件,Ansible与boto应该能够拿起EC2实例angular色。
到目前为止我有:
aws s3 cp s3://mybucket/ec2.py /tmp/ec2.py工作正常) curl http://169.254.169.254/latest/meta-data/iam/security-credentials/s3access 这个回答的问题和文件表明,这是可能的。
我可以做到这一点,而无需直接向boto / ansible提供实例证书吗? 如果是,如何。 文件似乎有点欠缺。
经过一些debugging和试验后,我发现问题的原因是Ansible S3模块中的一个错误。
在我原来的问题中引用的有用的剧本只有在IAMangular色除GetObject权限之外还具有ListBucket权限的情况下才有效。
我遇到完全相同的问题。 我发现,如果我通过完善的手册提供AWS访问密钥ID和秘密访问密钥,它将从S3开始工作并下载对象。 运行它作为一个有效的命令与键提供的内联也是可行的。 因此,“源桶无法find”的消息是误导性的,这是由于Ansible不能使用IAMangular色。
在Ansible GitHub中有一个错误票(我猜是由同一个作者打开的),但是仍然没有解决。