Actually "sg_facts | json_query('instances[*].groups[*])" spits out:
TASK [debug]
*******************************************************************
ok: [localhost] => (item={u'id': u'sg-828889fe', u'name': u'Default / EC2 /
Linux Ansible Clients'}) => {
"<type 'dict'>": "VARIABLE IS NOT DEFINED!",
"item": {
"id": "sg-828883fe",
"name": "Default / EC2 / Linux Ansible Clients"
}
}
ok: [localhost] => (item={u'id': u'sg-eb8b8087', u'name': u'Default / Linux
Admin Access / Port 22'}) => {
"<type 'dict'>": "VARIABLE IS NOT DEFINED!",
"item": {
"id": "sg-eb8b8087",
"name": "Default / Linux Admin Access / Port 22"
}
}
ok: [localhost] => (item={u'id': u'sg-0a2fea74', u'name': u'EC2 / ITS Shib
Prd'}) => {
"<type 'dict'>": "VARIABLE IS NOT DEFINED!",
"item": {
"id": "sg-0a2fea74",
"name": "EC2 / ITS Shib Prd"
}
}
Kenton Brede
On Sun, Mar 12, 2017 at 12:55 PM, Kenton Brede <[email protected]> wrote:
> 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') }}"
>
> Ansible 2.3 isn't in the yum repo yet or I could use ec2_group_facts,
> which would probably make this simpler...
>
>
> Kenton Brede
>
>
>
>
>
--
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%2BnSE38QfcYQ84d26KjSC1SSwAwD%3D4MN-jGLkTpfAtGVkGoLng%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.