You could use the selectattr() filter, however it looks like the 'equalto'
test is new (it doesn't work in my version of jinja2, which is 2.7.x). But
it would looks something like this:

   - debug: msg="{{vpc.subnets | map(attribute='resource_tags') |
selectattr('tier', 'equalto', 'elb') | list}}"



On Fri, Sep 5, 2014 at 9:45 AM, itarchmerc <[email protected]> wrote:

> I got one step further.  Using this debug statement, I was able to get the
> list of resource_tags:
>
> debug: msg="{{vpc.subnets | map(attribute='resource_tags') |
> map(attribute='tier') | list}}"
>
> I'm not sure if this is the right way to go about getting this
> information, so please let me know if there is a better way.
>
> Unfortunately, I'm still having difficulty having the task only pull the
> subnet id for the subnets tagged as tier=elb.  Can I use something after
> the pipe instead of list to limit the results, or do I need to use
> with_items, with_dict?  Thanks.
>
> On Friday, September 5, 2014 8:32:02 AM UTC-4, itarchmerc wrote:
>>
>> That worked perfectly to get the list of subnets.  Thank you!
>>
>> The only issue I have now is limiting the returned values.  The syntax
>> below is returning all 6 subnets in my vpc, but I only want the 2 subnets
>> that I gave a resource tag of tier=elb.  I'm trying to use the when clause
>> with the ec2_elb_lb module, but I can't get the syntax right there.  I
>> tried:
>>
>> when: {{ vpc.subnets | map(attribute='tier') | list }} == 'elb'
>>
>> This generates a syntax error each time.  What should the format be in a
>> when clause and/or is this the right way to approach limiting the results,
>> or should I be using with_items or with_dict?  Thanks for the help!
>>
>> On Thursday, September 4, 2014 11:14:53 PM UTC-4, James Cammarata wrote:
>>>
>>> Hi. From the look of the above, you're using the "complex args"
>>> structure to pass the params to the module. In this case, the list should
>>> not be a comma-separated list but should instead just be the array of IDs.
>>> For example:
>>>
>>> subnets: "{{vpc.subnets | map(attribute='id') | list}}"
>>>
>>> The syntax you're using above would work if you were instead using
>>> key=value parameters, ie: subnets="{{ vpc.subnets | join(','
>>> attribute='id') }}"
>>>
>>>
>>> On Thu, Sep 4, 2014 at 2:41 PM, itarchmerc <[email protected]>
>>> wrote:
>>>
>>>> I have a playbook that creates a VPC with multiple subnets which works
>>>> fine.  I then have a playbook that tries to create an ELB and I need to set
>>>> the subnets to 2 of the subnets returned from the vpc creation.  There are
>>>> 6 total subnets within the VPC, but two of them have resource_tags set to
>>>> tier:elb.  I only want the 2 subnets with those tags.
>>>>
>>>> I saw a post <https://github.com/ansible/ansible/pull/7051> that said
>>>> the following would work, but I get an invalid subnet ID error.  (look for
>>>> the comments from @coop)
>>>>
>>>> subnets: "{{ vpc.subnets | join(',' attribute='id') }}"
>>>>
>>>> My playbook is almost exactly the same as @coop in the post above, but
>>>> I have 6 subnets instead of 1.  I feel like I should be able to use
>>>> something like the above with a when clause to only get subnets tagged as
>>>> elb.  Any help is appreciated.
>>>>
>>>> --
>>>> 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 [email protected].
>>>> To post to this group, send email to [email protected].
>>>> To view this discussion on the web visit https://groups.google.com/d/
>>>> msgid/ansible-project/a2e130f5-007e-49b3-965f-
>>>> 31810e866efa%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/ansible-project/a2e130f5-007e-49b3-965f-31810e866efa%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/2d35fff9-9df6-4afc-b571-557af330677c%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/2d35fff9-9df6-4afc-b571-557af330677c%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> 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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAMFyvFjYei5fbWNw-BG3i3WMeRg6_BSuVF_2xPvbB0r0WyMbtA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to