Hi all,
I’m creating an ASG in my playbook from which I launch the following instances:
TASK: [create auto scaling group] *********************************************
changed: [localhost]
TASK: [debug var=“{{ ec_asg_info.instances }}”] *******************************
ok: [localhost] => {
“var”: {
“[‘i-9abfff30’, ‘i-ee4ea517’, ‘i-08ec48a2’]”: “[‘i-9abfff30’, ‘i-ee4ea517’, ‘i-08ec48a2’]”
}
}
TASK: [debug var=“{{ item }}”] ************************************************
ok: [localhost] => (item=i-9abfff30) => {
“item”: “i-9abfff30”,
“var”: {
“i-9abfff30”: “i-9abfff30”
}
}
ok: [localhost] => (item=i-ee4ea517) => {
“item”: “i-ee4ea517”,
“var”: {
“i-ee4ea517”: “i-ee4ea517”
}
}
ok: [localhost] => (item=i-08ec48a2) => {
“item”: “i-08ec48a2”,
“var”: {
“i-08ec48a2”: “i-08ec48a2”
}
}
and then I pass the list of the create instances to the ec2_eip task:
- name: associate new elastic IPs with each of the instances
ec2_eip:
instance_id={{ item }}
region={{ vpc_region }}
in_vpc=yes
with_items: ec2_asg_info.instances
register: eip_info
which fails with the following error:
TASK: [associate new elastic IPs with each of the instances] ******************
failed: [localhost] => (item=ec2_asg_info.instances) => {“failed”: true, “item”: “ec2_asg_info.instances”}
msg: EC2ResponseError: 400 Bad Request
InvalidInstanceID.Malformed
Invalid id: "ec2_asg_info.instances"9c204182-d5b6-41e0-badb-c6e85a9bc8e5
FATAL: all hosts have already failed – aborting
Note the invalid ID message coming back which has the list name instead of the item set.
Which is strange since if I run another playbook with the ec2_eip module only in which I set the list manually (after I created the instances with the previous asg playbook of course):
- name: associate new elastic IPs with each of the instances:
ec2_eip:
instance_id={{ item }}
region={{ vpc_region }}
in_vpc=yes
with_items: “[‘i-9abfff30’, ‘i-ee4ea517’, ‘i-08ec48a2’]”
register: eip_info
the tasks executes fine:
TASK: [associate new elastic IPs with each of the instances] ******************
changed: [localhost] => (item=i-9abfff30)
changed: [localhost] => (item=i-ee4ea517)
changed: [localhost] => (item=i-08ec48a2)
What is going on here?
Thanks,
Igor