【问题标题】:The error was: botocore.exceptions.NoCredentialsError: Unable to locate credential错误是:botocore.exceptions.NoCredentialsError:无法找到凭据
【发布时间】:2020-06-03 17:34:49
【问题描述】:

嗨,我无法解决这些问题,我得到了这些,我的 ansible 代码无法找到凭据

可靠的代码

---
 - name: main yaml file
   remote_user: ec2-user
   become: yes
   hosts: localhost
   roles:
      - s3

角色:

- name: basic upload
  s3_sync:
   bucket: s3uploadlocust
   file_root: /home/ec2-user
   include: "*.csv"
   exclude: "*.txt,.*"
   permission: public-read
   file_change_strategy: force
   region: us-east-1

这里是我的环境工具版本:

Name: boto3
Version: 1.12.2
Summary: The AWS SDK for Python
Home-page: https://github.com/boto/boto3
Author: Amazon Web Services
Author-email: UNKNOWN
License: Apache License 2.0
Location: /usr/local/lib/python2.7/site-packages
Requires: s3transfer, jmespath, botocore

Name: ansible
Version: 2.9.5
Summary: Radically simple IT automation
Home-page: https://ansible.com/
Author: Ansible, Inc.
Author-email: info@ansible.com
License: GPLv3+
Location: /usr/local/lib/python2.7/site-packages
Requires: jinja2, PyYAML, cryptography

Python 2.7.16

【问题讨论】:

标签: ansible boto3 boto


【解决方案1】:

根据模块文档,您可以再提供 2 个参数:aws_access_keyaws_secret_key。 如果未设置,则 AWS_ACCESS_KEY_IDAWS_ACCESS_KEYEC2_ACCESS_KEY 环境变量的值将用于 aws_access_key。 而AWS_SECRET_ACCESS_KEYAWS_SECRET_KEYEC2_SECRET_KEY环境变量用于aws_secret_key

【讨论】:

  • 即使我尝试在代码本身中提供访问密钥和密钥之后我也得到了同样的错误
猜你喜欢
  • 2016-01-22
  • 2019-11-26
  • 2022-07-20
  • 1970-01-01
  • 2021-04-25
  • 2022-08-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多