how to filter an item list - with_items filter using RegEx ?

`
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:

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)

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:

`

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

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.