Hi,
Apologies if this has already been asked previously - I couldn’t seem to find the relevant information I required.
I’m having issues running a playbook to launch a EC2 instance in AWS China. The same playbook works in non-China AWS accounts.
The error I am receiving is the following:
TASK [Launch instance] *********************************************************
ESTABLISH LOCAL CONNECTION FOR USER: ubuntu
127.0.0.1 EXEC ()
127.0.0.1 PUT
127.0.0.1 EXEC LANG=C LC_MESSAGES=C LC_CTYPE=C > /dev/null 2>&1
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File “/Users/Etherdaemon/.ansible/tmp/ansible-tmp-1445294739.44-143915179278919/ec2”, line 3429, in
main()
File “/Users/Etherdaemon/.ansible/tmp/ansible-tmp-1445294739.44-143915179278919/ec2”, line 1392, in main
(tagged_instances, instance_dict_array, new_instance_ids, changed) = enforce_count(module, ec2, vpc)
File “/Users/Etherdaemon/.ansible/tmp/ansible-tmp-1445294739.44-143915179278919/ec2”, line 771, in enforce_count
reservations, instances = find_running_instances_by_count_tag(module, ec2, count_tag, zone)
File “/Users/Etherdaemon/.ansible/tmp/ansible-tmp-1445294739.44-143915179278919/ec2”, line 558, in find_running_instances_by_count_tag
reservations = get_reservations(module, ec2, tags=count_tag, state=“running”, zone=zone)
File “/Users/Etherdaemon/.ansible/tmp/ansible-tmp-1445294739.44-143915179278919/ec2”, line 617, in get_reservations
results = ec2.get_all_instances(filters=filters)
File “/usr/local/lib/python2.7/site-packages/boto/ec2/connection.py”, line 585, in get_all_instances
max_results=max_results)
File “/usr/local/lib/python2.7/site-packages/boto/ec2/connection.py”, line 681, in get_all_reservations
[(‘item’, Reservation)], verb=‘POST’)
File “/usr/local/lib/python2.7/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"?>
AuthFailure
AWS was not able to validate the provided access credentials88e083e5-bdcf-4bf0-95ba-740ceb5ec790fatal: [localhost]: FAILED! => {“changed”: false, “failed”: true, “parsed”: false}
My playbook looks like this:
- name: Create an All In One Environment
hosts: localhost
vars_files:
- “…/variable_files/{{ env }}_vars.yml”
gather_facts: False
tags:
- create
tasks:
include: tasks/iam.yml
name: Launch instance
ec2:
key_name: “{{ key_name }}”
group: “{{ security_group }}”
instance_type: “{{ instance_type }}”
image: “{{ image }}”
wait: true
region: “{{ region }}”
vpc_subnet_id: “{{ subnet_id }}”
assign_public_ip: no
instance_tags:
Name: “{{ role }}{{ ‘%02d’|format(instance_count|int) }}.{{ env }}.aws-{{ region_shortname }}.{{ tld_name_internal }}”
Environment: “{{ environment_name }}”
Role: “{{ role }}”
exact_count: “{{ instance_count }}”
count_tag:
Environment: “{{ environment_name }}”
Role: “{{ role }}”
instance_profile_name: “{{ game }}_{{ env }}_ec2_role”
volumes:
- device_name: /dev/xvdb
ephemeral: ephemeral0
- device_name: /dev/xvdc
ephemeral: ephemeral1
user_data: “{{ lookup(‘file’, ‘files/userdata.txt’) }}”
register: ec2
- name: Add new instance to host group
add_host: hostname={{ item.public_ip }} groupname=“{{ environment_name }}”
with_items: ec2.instances
- name: Wait for SSH to come up
wait_for: host={{ item.public_dns_name }} port=22 delay=60 timeout=320 state=started
with_items: ec2.instances
-
I am running Ansible from source - v2.0.0-0.3.beta1
-
I am also running boto (2.38.0) and boto3 (1.1.4)
-
I am using /.boto config with a profile named china
-
If I run the ec2.py inventory script by itself using the boto profile and credentials it runs correctly with no errors
-
If I run from a local inventory instead - the same error occurs
-
I have checked my IAM credentials and it has full access
-
I suspect the issue is around boto using the get_all_instances command
Can anyone advise if they have Ansible running in AWS China atm or if anyone has an idea on what the issue is?
Any help greatly appreciated.
Cheers
Karen