在ansible playbook中执行任务以启动ec2实例时发生异常

在ansible playbook中执行任务以启动ec2实例时发生异常,ansible,ansible-playbook,ansible-2.x,Ansible,Ansible Playbook,Ansible 2.x,这是我运行的,但它显示以下错误 --- - hosts: localhost gather_facts: false vars: keypair: id_rsa instance_type: t2.micro image: ami-6f68cf0f region: us-west-2 tasks: - name: launch ec2-instance ec2: key_name: "{{ keypair }}"

这是我运行的,但它显示以下错误

---
- hosts: localhost
  gather_facts: false
  vars:
    keypair: id_rsa
    instance_type: t2.micro
    image: ami-6f68cf0f
    region: us-west-2


  tasks:
    - name: launch ec2-instance
      ec2:
        key_name: "{{ keypair }}"
        instance_type: "{{ instance_type }}"
        image: ami-6f68cf0f
        wait: true
        group: wide-open
        region: "{{ region }}"
        aws_access_key: '************'
        aws_secret_key: '********************************'
      register: ec2

在这种情况下,您收到的错误消息相当不错:
AWS无法验证提供的访问凭据

这里讨论的凭据是您的AWS帐户的凭据。特别是,您的
aws\u access\u key
aws\u secret\u key
变量


您只需要为这些变量获取正确的值,对照颁发这些凭据的人给您的信息检查您拥有的信息/您的备份(如果是您自己)。错误消息:EC2ResponseError:401 Unauthorized AuthFailure AWS无法验证提供的访问凭据。你查过了吗?问题是。。。?
Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-tmp-1483922048.3-267705964376313/ec2", line 3628, in <module>
    main()
  File "/root/.ansible/tmp/ansible-tmp-1483922048.3-267705964376313/ec2", line 1413, in main
    (instance_dict_array, new_instance_ids, changed) = create_instances(module, ec2, vpc)
  File "/root/.ansible/tmp/ansible-tmp-1483922048.3-267705964376313/ec2", line 898, in create_instances
    grp_details = ec2.get_all_security_groups()
  File "/usr/lib/python2.6/site-packages/boto/ec2/connection.py", line 2984, in get_all_security_groups
    [('item', SecurityGroup)], verb='POST')
  File "/usr/lib/python2.6/site-packages/boto/connection.py", line 1186, in get_list
    raise self.ResponseError(response.status, response.reason, body)
boto.exception.EC2ResponseError: EC2ResponseError: 401 Unauthorized
<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>AuthFailure</Code><Message>AWS was not able to validate the provided access credentials</Message></Error></Errors><RequestID>5d241900-6b6e-4398-aba3-16d5738fb6d5</RequestID></Response>

fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_name": "ec2"}, "module_stderr": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-tmp-1483922048.3-267705964376313/ec2\", line 3628, in <module>\n    main()\n  File \"/root/.ansible/tmp/ansible-tmp-1483922048.3-267705964376313/ec2\", line 1413, in main\n    (instance_dict_array, new_instance_ids, changed) = create_instances(module, ec2, vpc)\n  File \"/root/.ansible/tmp/ansible-tmp-1483922048.3-267705964376313/ec2\", line 898, in create_instances\n    grp_details = ec2.get_all_security_groups()\n  File \"/usr/lib/python2.6/site-packages/boto/ec2/connection.py\", line 2984, in get_all_security_groups\n    [('item', SecurityGroup)], verb='POST')\n  File \"/usr/lib/python2.6/site-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>5d241900-6b6e-4398-aba3-16d5738fb6d5</RequestID></Response>\n", "module_stdout": "", "msg": "MODULE FAILURE", "parsed": false}