Hi,
I’m trying to terminate an ec2 instance but I’m getting the following error:
PLAY [Terminate instance] *****************************************************
GATHERING FACTS ***************************************************************
ok: [127.0.0.1]
TASK: [Terminate instances that were previously launched] *********************
failed: [127.0.0.1] => {“failed”: true, “parsed”: false}
invalid output was: Traceback (most recent call last):
File “/home/smartallocator/.ansible/tmp/ansible-1382099110.85-99795266100410/ec2”, line 1587, in
main()
File “/home/smartallocator/.ansible/tmp/ansible-1382099110.85-99795266100410/ec2”, line 637, in main
(changed, instance_dict_array, new_instance_ids) = terminate_instances(module, ec2, instance_ids)
File “/home/smartallocator/.ansible/tmp/ansible-1382099110.85-99795266100410/ec2”, line 543, in terminate_instances
for res in ec2.get_all_instances(instance_ids):
File “/usr/local/lib/python2.7/dist-packages/boto/ec2/connection.py”, line 539, in get_all_instances
filters=filters, dry_run=dry_run)
File “/usr/local/lib/python2.7/dist-packages/boto/ec2/connection.py”, line 609, in get_all_reservations
[(‘item’, Reservation)], verb=‘POST’)
File “/usr/local/lib/python2.7/dist-packages/boto/connection.py”, line 1117, in get_list
raise self.ResponseError(response.status, response.reason, body)
boto.exception.EC2ResponseError: EC2ResponseError: 400 Bad Request
InvalidInstanceID.Malformed
Invalid id: “[u’i-29333566’]”129f061b-da3e-4fa5-be80-9ad6493678f8
FATAL: all hosts have already failed – aborting
My play looks as follows:
- name: Terminate instance
hosts: localhost
connection: local
tasks: - name: Terminate instances that were previously launched
local_action:
module: ec2
state: ‘absent’
instance_ids: “{{ ec2.instance_ids }}”
region: eu-west-1
The example in the docs does not have quotes around the {{ ec2.instance_ids }} variable but if I omit the quotes then that errors too:
ERROR: Syntax Error while loading YAML script, site.yml
Note: The error may actually appear before this position: line 41, column 24
state: ‘absent’
instance_ids: {{ ec2.instance_ids }}
^
Any ideas? I’m running ansible 1.4 from source.
Thanks,
Marc