I’m working on a playbook that will:
- Launch n EC2 instances
- Tag each with a “meaningful” name
The name should look something like -<%02d> (e.g. dev-ws03 or prd-db01).
Step 1 works great, but applying the Name tag is failing and I can’t see my mistake:
- name: Instances | Tag each new instance with a name
ec2_tag:
aws_access_key: “{{ awscli.access_key }}”
aws_secret_key: “{{ awscli.secret_key }}”
region: “{{ aws.region }}”
resource: “{{ item }}”
state: present
tags:
Name: “{{ env_short }}-{{ ‘ws%02d’ | format(item.0) }}”
with_indexed_items: webservers.instance_ids
Note that the {{ webservers }} variable is registered by the ec2 module after the launch task completes. To my inexperienced eye, it looks like {{ item.0 }} contains the value rather than the index. Here’s the error:
failed: [localhost] => (item=(0, ‘i-8e0aaf32’)) => {“failed”: true, “item”: [0, “i-8e0aaf32”], “parsed”: false}
Traceback (most recent call last):
File “/Users/robwilkerson/.ansible/tmp/ansible-tmp-1446129334.17-9751906117513/ec2_tag”, line 1958, in
main()
File “/Users/robwilkerson/.ansible/tmp/ansible-tmp-1446129334.17-9751906117513/ec2_tag”, line 102, in main
gettags = ec2.get_all_tags(filters=filters)
File “/usr/local/Cellar/ansible/1.9.4/libexec/vendor/lib/python2.7/site-packages/boto/ec2/connection.py”, line 4179, in get_all_tags
[(‘item’, Tag)], verb=‘POST’)
File “/usr/local/Cellar/ansible/1.9.4/libexec/vendor/lib/python2.7/site-packages/boto/connection.py”, line 1170, in get_list
response = self.make_request(action, params, path, verb)
File “/usr/local/Cellar/ansible/1.9.4/libexec/vendor/lib/python2.7/site-packages/boto/connection.py”, line 1116, in make_request
return self._mexe(http_request)
File “/usr/local/Cellar/ansible/1.9.4/libexec/vendor/lib/python2.7/site-packages/boto/connection.py”, line 1028, in _mexe
raise BotoServerError(response.status, response.reason, body)
boto.exception.BotoServerError: BotoServerError: 500 Internal Server Error
InternalError
An internal error has occurred0774638d-6961-49f8-ad60-8be66316e2d3
Any help would be appreciated.