I have a dict that looks like:

TASK [debug vpc_subnet_facts.subnets] 
*******************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": [
        {
            "assign_ipv6_address_on_creation": false,
            "availability_zone": "us-west-1a",
            "available_ip_address_count": 250,
            "cidr_block": "10.0.1.0/24",
            "default_for_az": false,
            "id": "subnet-030ff449eaea87042",
            "ipv6_cidr_block_association_set": [],
            "map_public_ip_on_launch": false,
            "state": "available",
            "subnet_id": "subnet-030ff449eaea87042",
            "tags": {
                "Name": "private-a"
            },
            "vpc_id": "vpc-0a8c42654fe5f4a2b"
        },
        {
            "assign_ipv6_address_on_creation": false,
            "availability_zone": "us-west-1a",
            "available_ip_address_count": 251,
            "cidr_block": "10.0.2.0/24",
            "default_for_az": false,
            "id": "subnet-0e2db57655e833a66",
            "ipv6_cidr_block_association_set": [],
            "map_public_ip_on_launch": false,
            "state": "available",
            "subnet_id": "subnet-0e2db57655e833a66",
            "tags": {
                "Name": "public-a"
            },
            "vpc_id": "vpc-0a8c42654fe5f4a2b"
        },
        {
            "assign_ipv6_address_on_creation": false,
            "availability_zone": "us-west-1c",
            "available_ip_address_count": 251,
            "cidr_block": "10.0.5.0/24",
            "default_for_az": false,
            "id": "subnet-060df17f2871364d2",
            "ipv6_cidr_block_association_set": [],
            "map_public_ip_on_launch": false,
            "state": "available",
            "subnet_id": "subnet-060df17f2871364d2",
            "tags": {
                "Name": "private-c"
            },
            "vpc_id": "vpc-0a8c42654fe5f4a2b"
        },
        {
            "assign_ipv6_address_on_creation": false,
            "availability_zone": "us-west-1c",
            "available_ip_address_count": 251,
            "cidr_block": "10.0.6.0/24",
            "default_for_az": false,
            "id": "subnet-0dd9ab6af6ec05f83",
            "ipv6_cidr_block_association_set": [],
            "map_public_ip_on_launch": false,
            "state": "available",
            "subnet_id": "subnet-0dd9ab6af6ec05f83",
            "tags": {
                "Name": "public-c"
            },
            "vpc_id": "vpc-0a8c42654fe5f4a2b"
        }
    ]
}

and I'm attempting to extract subnet_id for only public subnets like so:

- name: set public vpc subnets
  set_fact:
    vpc_public_subnet_ids: "{{ item | selectattr('Name', 'search', 
'public.+') | map(attribute='subnet_id') | list }}"
  loop: "{{ vpc_subnet_facts.subnets }}"

I've tried a number of ways to filter out this information but to no avail. 
The most common error is *"Unexpected templating type error occurred on ({{ 
item | selectattr('Name', 'search', 'public.+') | 
map(attribute='subnet_id') | list }}): expected string or buffer"}"*
I feel as if I'm making some rather basic mistake here. 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/37a72f53-19b8-414e-8256-4b924d2c4c7d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to