ansible - 错误是:botocore.exceptions.NoCredentialsError: Unable to locate credential
问题描述
嗨,我无法解决这些问题,我得到了这些,我的 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
解决方案
根据模块文档,您可以再提供 2 个参数:aws_access_key
和aws_secret_key
. 如果未设置AWS_ACCESS_KEY_ID
,则使用AWS_ACCESS_KEY
或EC2_ACCESS_KEY
环境变量的值aws_access_key
。和AWS_SECRET_ACCESS_KEY
, AWS_SECRET_KEY
, 或EC2_SECRET_KEY
环境变量用于aws_secret_key
.
推荐阅读
- android - 在颤振应用程序中生成签名报告时出错
- excel - Excel VBA .替换不替换文本
- angular - 导航到特定路由而不重新加载页面但更新 router.url
- xml - 如何使用节点从 TSQL 中的 XML 获取数据?
- spring-boot - 在带有 Spring Boot 的 Swagger 安全方案上使用两个 API 密钥
- ios - UITextView Height 如何增加它的某个点
- oauth-2.0 - 如何为修改其他电子表格和幻灯片的脚本启用权限?
- python - 匹配 ORB 特征并使用它们来查找同应性
- python - 无法找到 matplotlib 配置文件 .mplstyle 的正确文档
- python - Herepy EV充电站API;发生错误:禁止访问,说明:这些凭据未授权访问