错误:> AWS在执行Ansible剧本时无法验证提供的访问凭证

时间:2019-02-25 07:16:12

标签: amazon-web-services ansible

我有一本可启动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

我不确定是什么问题?

0 个答案:

没有答案