amazon-web-services - 错误:>AWS 在执行 ansible playbook 时无法验证提供的访问凭证
问题描述
我有一个启动 ec2 实例的剧本。我已经安装了 ansible 并配置了主机,并打开了服务器和客户端之间的 ssh 连接。我已经使用 aws configure 配置了我的凭据。
---
- name: Create EC2 instance
hosts: localhost
connection: local
gather_facts: False
vars:
region: us-east-1
instance_type: t2.micro
ami: ami-01ac7d9c1179d7b74
keypair: priyajdm
tasks:
- name: Create an EC2 instance
ec2:
key_name: "{{ keypair }}"
group: launch-wizard-31
instance_type: "{{ instance_type }}"
image: "{{ ami }}"
wait: true
region: "{{ region }}"
count: 1
vpc_subnet_id: subnet-02f498e16fd56c277
assign_public_ip: yes
register: ec2
我收到此错误:
[WARNING]: Found both group and host with same name: localhost
PLAY [Create EC2 instance] *********************************************************************************************************************************************
TASK [Create an EC2 instance] ******************************************************************************************************************************************An exception occurred during task execution. To see the full traceback, use -vvv. The error was: <Response><Errors><Error><Code>AuthFailure</Code><Message>AWS was not able to validate the provided access credentials</Message></Error></Errors><RequestID>fc03d812-27ae-4081-91de-f3134a35c532</RequestID></Response>
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/root/.ansible/tmp/ansible-tmp-1551078795.63-127068750845381/AnsiballZ_ec2.py\", line 113, in <module>\n _ansiballz_main()\n File \"/root/.ansible/tmp/ansible-tmp-1551078795.63-127068750845381/AnsiballZ_ec2.py\", line 105, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/root/.ansible/tmp/ansible-tmp-1551078795.63-127068750845381/AnsiballZ_ec2.py\", line 48, in invoke_module\n imp.load_module('__main__', mod, module, MOD_DESC)\n File \"/tmp/ansible_ec2_payload_knSbXZ/__main__.py\", line 1702, in <module>\n File \"/tmp/ansible_ec2_payload_knSbXZ/__main__.py\", line 1686, in main\n File \"/tmp/ansible_ec2_payload_knSbXZ/__main__.py\", line 989, in create_instances\n File \"/usr/local/lib/python2.7/dist-packages/boto/vpc/__init__.py\", line 1152, in get_all_subnets\n return self.get_list('DescribeSubnets', params, [('item', Subnet)])\n File \"/usr/local/lib/python2.7/dist-packages/boto/connection.py\", line 1186, in get_list\n raise self.ResponseError(response.status, response.reason, body)\nboto.exception.EC2ResponseError: EC2ResponseError: 401 Unauthorized\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Response><Errors><Error><Code>AuthFailure</Code><Message>AWS was not able to validate the provided access credentials</Message></Error></Errors><RequestID>fc03d812-27ae-4081-91de-f3134a35c532</RequestID></Response>\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
to retry, use: --limit @/etc/ansible/launch.retry
PLAY RECAP *************************************************************************************************************************************************************localhost : ok=0 changed=0 unreachable=0 failed=1
我不确定是什么问题?
解决方案
推荐阅读
- bash - 如何在 bash 中对所有字符(特殊和非特殊)进行 url 编码
- git - Flutter - 使用和修改包的正确方法?
- .net - 向远程 WebDriver 服务器发送 HTTP 请求以获取 URL 时遇到未知异常
- python - 如何修改存储为列表的numpy数组行
- html - Jekyll 自定义变量输出不正确的值
- java - Android:TCP 连接中的周期性掉线
- python - 确定python函数是否已更改
- php - 在远程服务器上执行 PHP 脚本文件而不在远程服务器上复制它
- javascript - 使用 div 内容创建无限滚动循环
- jmeter - Jmeter - 如何实现与 jmeter 中的用户数相同的吞吐量