Sounds like you may wish to write a filter plugin.

If so, see if you need more information, if needed, we can provide some
pointers.



On Fri, Nov 21, 2014 at 12:23 PM, Ted Eiles <[email protected]> wrote:

> We are attempting to filter a set of AWS subnets for creating an ASG.
>
> In a VPC, we have some subnets tagged as "Network=private".  When creating
> an ASG for worker instances, we need to set the ASG's AZs and subnets to
> the AZs and subnets of all private subnets in the VPC.  So, being able to
> with_items over the subnets and filtering on tags "Network=private" is
> useful.
>
> For AWS work, filtering AWS entities (hosts, IAM roles, subnets, VPC',
> etc...) on one or more tags seems like it would be common.
>
> --- Ted
>
>
> On Tuesday, November 18, 2014 3:23:11 AM UTC-5, Torsten Reinhard wrote:
>>
>> Hi,
>>
>> it´s not about "hosts" filtering - in my case it´s always "hosts: cae".
>>
>> I have some files in
>> group_vars/cae-1.yml
>> group_vars/cae-2.yml
>> ..
>> group_vars/cae-xx.yml
>>
>>
>> according to the group(s) defined in my /inventory/hosts file.
>>
>> Inside these group_vars there´s a list of instances, running on that
>> machine:
>>
>> ---
>> cae_instance:
>> -
>>     index: _1_a
>>     port: 8700
>> ...
>> -
>>     index: _1_k
>>     port: 12700
>>
>>
>>
>> The question is now: how to filter that list ?
>>
>> I know I can iterate the list using the "with_items" expression - but I
>> want to "skip" or "filter" some items, lets say by using RegEx on one (or
>> more) attributes of the list items.
>>
>> Any solution for that ?
>>
>> Regards, Torsten
>>
>> Am Montag, 17. November 2014 22:13:54 UTC+1 schrieb Michael DeHaan:
>>>
>>> If you are attempting to talk to only certain instances, usage of the
>>> host group specifier "hosts:" is the way to do it.
>>>
>>> To talk to all instances ending in that pattern
>>>
>>> - hosts: *_k
>>>
>>> The docs also show how to combine patterns and negate them.
>>>
>>> (The group_by module can also be used to create groups of arbitrary
>>> criteria based on facts, but is not needed here)
>>>
>>>
>>>
>>>
>>>
>>> On Thu, Nov 13, 2014 at 6:12 AM, Torsten Reinhard <
>>> [email protected]> wrote:
>>>
>>>> Hi all,
>>>>
>>>> like probably most of you, we have multiple servers with multiple
>>>> application instances (Tomcat, Apache, ..) on it, for example
>>>> structured like this:
>>>>
>>>> [cae:children]
>>>> cae-1
>>>> cae-2
>>>>
>>>> [cae-1]
>>>> pbdelsweb001.mydomain.com
>>>> [cae-2]
>>>> pbdelsweb002.mydomain.com
>>>>
>>>>
>>>> For each group we have a *.yml file at group_vars directoy in the
>>>> inventory:
>>>>
>>>> cae-1.yml:
>>>> ---
>>>> cae_instance:
>>>> -
>>>>     index: _1_a
>>>>     port: 8700
>>>> -
>>>>     index: _1_b
>>>>     port: 9700
>>>> -
>>>>     index: _1_c
>>>>     port: 10700
>>>> -
>>>>     index: _1_k
>>>>     port: 12700
>>>>
>>>> All these instances are setup by a simple playbook:
>>>>
>>>> - hosts: cae
>>>>   user: myuser
>>>>
>>>>   vars_files:
>>>>     - vars/stage-{{stage}}.yml
>>>>
>>>>   roles:
>>>>     - { role: cae-tomcat, params: "{{ cae_instance }}" }
>>>>
>>>> This is all fine - but now I have to fullfill the requirement to be
>>>> able to address only the "_k" instances - or only the "_a" instances - that
>>>> meens one or more instances out of the complete list.
>>>>
>>>> Is there an option to "filter" the list of instances ? Something like
>>>>
>>>>   with_items
>>>>    - filter: (".*_k" )
>>>>
>>>> Do I have to write my own Iterator(s) for this ?
>>>>
>>>> Thanx for any hints, Torsten
>>>>
>>>>
>>>>
>>>>
>>>>  --
>>>> 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/fbbdc812-3908-43a8-921b-
>>>> f7705a6314cc%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/ansible-project/fbbdc812-3908-43a8-921b-f7705a6314cc%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/2838d5ad-7fb3-43b3-be51-18fd262832f8%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/2838d5ad-7fb3-43b3-be51-18fd262832f8%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/CA%2BnsWgyvS_fc%3DBRqChSf4WhMhUEoMFhKoGwoy%2BZ_nuSvM9dUtQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to