当我尝试在AWS上对我的EC2计算机运行ansible剧本并使用ec2_instance_facts模块收集一些事实时。我收到以下错误:
botocore.exceptions.NoCredentialsError: Unable to locate credentials
AWS CLI:
[ansible@control aws]$ aws --version
aws-cli/1.16.81 Python/2.7.5 Linux/3.10.0-862.el7.x86_64 botocore/1.12.71
Ansible:
[ansible@control aws]$ ansible --version
ansible 2.7.5
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/ansible/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /bin/ansible
python version = 2.7.5 (default, Oct 30 2018, 23:45:53) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
[ansible@control aws]$
我确实使用aws configure添加了凭据
[ansible@control aws]$ aws configure
AWS Access Key ID [****************SGWA]:
AWS Secret Access Key [****************kZwS]:
Default region name [ca-central]:
Default output format [None]:
[ansible@control aws]$
它已正确保存:
[ansible@control aws]$ aws configure list
Name Value Type Location
---- ----- ---- --------
profile <not set> None None
access_key ****************SGWA shared-credentials-file
secret_key ****************kZwS shared-credentials-file
region ca-central env AWS_DEFAULT_REGION
我检查了凭据
ansible@control .aws]$ cat credentials
[default]
aws_access_key_id = **********************GWA
aws_secret_access_key = ***************************kZwS
我还检查了配置
[ansible@control .aws]$ cat config
[default]
region = ca-central
我的ansible帐户有AmazonEC2FullAccess
不太确定我在这里缺少什么!有任何想法吗?
谢谢
答案 0 :(得分:0)
最好的解决方案是不要将Ansible直接与AWS结合使用,因为包装不正确。尝试使用terraform之类的另一个项目来管理AWS,并使用Ansible来自动化任务。