Discussion:
[ansible-project] Constructing a List.
r***@gmail.com
2015-07-22 08:57:34 UTC
Permalink
Hi,

Using a 'shell' task I'm obtaining a list of subnet id's from Amazon, these
subnet id's I want to pass in to the ec2_elb_lb task.
However this task accepts a list for Subnets only, so is there a way to
dynamically construct a list out of the id's that I obtained?

Thanks,
Nico
--
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-project+***@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/c8cefbae-55f2-48ea-a051-f894137131da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jon Hadfield
2015-07-22 17:05:09 UTC
Permalink
Hi,

Instead of using shell, you could use a lookup plugin that will query the
ids by name for you.
So when creating the subnets, give them a name and also store them in a
list, e.g.
mysubnets:
- subnet1
- subnet2

You can then define your ELB like this:

ec2_elb_lb:
...
subnets: "{{ lookup('aws_subnet_ids_from_names', (region,
mysubnets)) }}"

Where region is a variable containing a region name, i.e. 'eu-west-1'.
This will return a list of the subnet ids that the ec2_elb_lb module
expects.
To use this, just copy the lookup plugin from here
<https://github.com/jonhadfield/ansible-lookups> into a directory called
lookup_plugins in the root of your project.

Jon
--
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-project+***@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/2b5850e9-5e1f-4886-9775-bfbe458801c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Igor Homyakov
2015-07-23 07:26:30 UTC
Permalink
Hi Jon,

That is awesome. Thank you for sharing.

-- Best, Igor
Post by Jon Hadfield
Hi,
Instead of using shell, you could use a lookup plugin that will query the
ids by name for you.
So when creating the subnets, give them a name and also store them in a
list, e.g.
- subnet1
- subnet2
...
subnets: "{{ lookup('aws_subnet_ids_from_names', (region,
mysubnets)) }}"
Where region is a variable containing a region name, i.e. 'eu-west-1'.
This will return a list of the subnet ids that the ec2_elb_lb module
expects.
To use this, just copy the lookup plugin from here into a directory called
lookup_plugins in the root of your project.
Jon
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/2b5850e9-5e1f-4886-9775-bfbe458801c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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-project+***@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/CAGuanspb4dv2U-qPScGk-PKZ2m51%2B39QA%3DX6cLYVtVAJapuHKw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...