On Sunday, April 22, 2018 at 7:30:15 PM UTC-4, Gregory Mirsky wrote:
>
> I've been trying to extract the values for subnet_id from the dictionary
> subnet_facts but keep getting undefined (3 times instead of the values) as
> a return value. I should be getting [subnet-fd6bfa95, subnet-7c8bb031,
> subnet-7c8bb031]
>
> Any ideas?
>
> Below is the local host testbed playbook i've been using trying to get
> this jinja filter to work.
>
'subnets' is a list (observe the [ ].)
> "subnets": [
>> {
>> "assign_ipv6_address_on_creation":
>> false,
>> "availability_zone": "us-east-2b",
>> "available_ip_address_count": 251,
>> "cidr_block": "10.0.2.0/24",
>> "default_for_az": false,
>> "id": "subnet-6ad01910",
>> "ipv6_cidr_block_association_set":
>> [],
>> "map_public_ip_on_launch": true,
>> "state": "available",
>> "subnet_id": "subnet-6ad01910",
>> "tags": {
>> "DeleteTag": "
>> [email protected] <javascript:>",
>> "Name":
>> "test-subnet-us-east-2b-public",
>> "SubnetType": "public"
>> },
>> "vpc_id": "vpc-1227b97a"
>> }
>> ]
>>
>>
> var: "{{ subnet_facts | selectattr('results.subnets.id') | list }}"
>>
>
Here, you appear to be trying to get the 'id' attribute of 'subnets'. It
doesn't have one, because it's a list.
var: "subnet_facts.results | map(attribute='subnets') | flatten |
map(attribute='id') | list"
(The `flatten` filter is new in Ansible 2.5; on older versions you'd need
to use the `flatten` lookup.)
--
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/1e8c11c4-622e-42f7-8c91-913a0666ec65%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.