---
- 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
这是我运行但它显示以下错误
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}
答案 0 :(得分:1)
在这种情况下,您收到的错误消息相当不错:
robomongo
此处提供的凭据是您的AWS账户的凭据。特别是,您的AWS was not able to validate the provided access credentials
和aws_access_key
变量。
您只需要为这些变量获取正确的值,检查您对发布这些凭据的人所给予的内容以及您自己的备份所做的事情。