Weird issue with ec2_eip module

63 views
Skip to first unread message

Igor Cicimov

unread,
Jun 8, 2015, 11:38:30 PM6/8/15
to ansible...@googlegroups.com
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
<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>InvalidInstanceID.Malformed</Code><Message>Invalid id: "ec2_asg_info.instances"</Message></Error></Errors><RequestID>9c204182-d5b6-41e0-badb-c6e85a9bc8e5</RequestID></Response>

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

benno joy

unread,
Jun 9, 2015, 12:27:35 AM6/9/15
to ansible...@googlegroups.com
you have var="{{ ec_asg_info.instances }}"

and in with_items: ec2_asg_info   shouldnt it be : ec_asg_info


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/96f3764c-00e8-47b2-bf11-3ccbdc7936e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Igor Cicimov

unread,
Jun 9, 2015, 12:44:30 AM6/9/15
to ansible...@googlegroups.com
I expected to be some syntax error on my side but nothing that obvious and embarrassing :-(

I better go and check my eyes.

Thanks, Benno.
Igor
Reply all
Reply to author
Forward
0 new messages