I’m trying to get the id of the security group that doesn’t have ‘Default’ in the name. In other words grab “sg-0a2fea74.”
This is what “sg_facts | json_query('instances[].groups[])” spits out:
“groups”: [
{
“id”: “sg-828889fe”,
“name”: “Default / EC2 / Linux Ansible Clients”
},
{
“id”: “sg-0a2fea74”,
“name”: “EC2 / Shib Prd”
},
{
“id”: “sg-eb8b8087”,
“name”: “Default / Linux Admin Access”
}
],
My with_items filter below is not working but illustrates what I’m trying to do. Anyone know how I can get this done? – Thanks
- name: Gather facts
ec2_remote_facts:
region: us-east-1
filters:
“tag:Resource_group_id”: “{{ resource_group_id_tag }}”
register: sg_facts
- debug: var={{ item }}
with_items: “{{ sg_facts | json_query(‘instances[].groups[].[?name !~ ‘Default’].id’) }}”