Hi all,
I need to try to map multiple attributes from an ACI vrf query output.
---
- name: Test Play
hosts: mgtapic
gather_facts: no
tasks:
- name: Query all VRFs
aci_vrf:
host: "{{ ansible_host }}"
username: "{{ ansible_user }}"
password: "{{ ansible_password }}"
validate_certs: no
###################
state: query
delegate_to: localhost
register: vrf_query
- debug:
msg:
- "{{ vrf_query }}"
- "{{ vrf_query.current[:] |
map(attribute='fvCtx.attributes.name') | list }}"
- "{{ vrf_query.current[:] | map(attribute='fvCtx.attributes.dn')
| list }}"
I can get the single requested output for <vrf_query>, <name> & <dn>,
[root@localhost ]# ansible-playbook aci_test.yml
PLAY [Test Play]
***********************************************************************************************************************************************************************************************************************
TASK [Query all VRFs]
******************************************************************************************************************************************************************************************************************
Thursday 02 July 2020 13:08:42 +0100 (0:00:00.026) 0:00:00.026
*********
ok: [mgtapic01 -> localhost]
TASK [debug]
***************************************************************************************************************************************************************************************************************************
Thursday 02 July 2020 13:08:43 +0100 (0:00:00.694) 0:00:00.721
*********
ok: [mgtapic01] =>
msg:
- changed: false
current:
- fvCtx:
attributes:
annotation: ''
bdEnforcedEnable: 'no'
childAction: ''
descr: ''
dn: uni/tn-mgmt/ctx-oob
extMngdBy: ''
ipDataPlaneLearning: enabled
knwMcastAct: permit
lcOwn: local
modTs: '2020-06-29T08:53:32.087+00:00'
monPolDn: uni/tn-common/monepg-default
name: oob
nameAlias: ''
ownerKey: ''
ownerTag: ''
pcEnfDir: ingress
pcEnfDirUpdated: 'yes'
pcEnfPref: enforced
pcTag: '32770'
scope: '2981888'
seg: '2981888'
status: ''
uid: '0'
- fvCtx:
attributes:
annotation: ''
bdEnforcedEnable: 'no'
childAction: ''
descr: ''
dn: uni/tn-mgmt/ctx-inb
extMngdBy: ''
ipDataPlaneLearning: enabled
knwMcastAct: permit
lcOwn: local
modTs: '2020-06-29T08:53:32.087+00:00'
monPolDn: uni/tn-common/monepg-default
name: inb
nameAlias: ''
ownerKey: ''
ownerTag: ''
pcEnfDir: ingress
pcEnfDirUpdated: 'yes'
pcEnfPref: enforced
pcTag: '32770'
scope: '2686976'
seg: '2686976'
status: ''
uid: '0'
- fvCtx:
attributes:
annotation: ''
bdEnforcedEnable: 'no'
childAction: ''
descr: ''
dn: uni/tn-common/ctx-default
extMngdBy: ''
ipDataPlaneLearning: enabled
knwMcastAct: permit
lcOwn: local
modTs: '2020-06-29T08:53:31.783+00:00'
monPolDn: uni/tn-common/monepg-default
name: default
nameAlias: ''
ownerKey: ''
ownerTag: ''
pcEnfDir: ingress
pcEnfDirUpdated: 'yes'
pcEnfPref: enforced
pcTag: '49153'
scope: '2883584'
seg: '2883584'
status: ''
uid: '0'
- fvCtx:
attributes:
annotation: ''
bdEnforcedEnable: 'no'
childAction: ''
descr: ''
dn: uni/tn-infra/ctx-overlay-1
extMngdBy: ''
ipDataPlaneLearning: enabled
knwMcastAct: permit
lcOwn: local
modTs: '2020-06-29T08:53:30.437+00:00'
monPolDn: uni/tn-common/monepg-default
name: overlay-1
nameAlias: ''
ownerKey: ''
ownerTag: ''
pcEnfDir: ingress
pcEnfDirUpdated: 'yes'
pcEnfPref: enforced
pcTag: '49153'
scope: '16777199'
seg: '16777199'
status: ''
uid: '0'
- fvCtx:
attributes:
annotation: ''
bdEnforcedEnable: 'no'
childAction: ''
descr: ''
dn: uni/tn-common/ctx-copy
extMngdBy: ''
ipDataPlaneLearning: enabled
knwMcastAct: permit
lcOwn: local
modTs: '2020-06-29T08:53:31.783+00:00'
monPolDn: uni/tn-common/monepg-default
name: copy
nameAlias: ''
ownerKey: ''
ownerTag: ''
pcEnfDir: ingress
pcEnfDirUpdated: 'yes'
pcEnfPref: enforced
pcTag: '16386'
scope: '3047424'
seg: '3047424'
status: ''
uid: '0'
- fvCtx:
attributes:
annotation: orchestrator:msc
bdEnforcedEnable: 'no'
childAction: ''
descr: ''
dn: uni/tn-tn-ncsd/ctx-v38-aci
extMngdBy: ''
ipDataPlaneLearning: enabled
knwMcastAct: permit
lcOwn: local
modTs: '2020-06-29T08:58:27.856+00:00'
monPolDn: uni/tn-common/monepg-default
name: v38-aci
nameAlias: ''
ownerKey: ''
ownerTag: ''
pcEnfDir: ingress
pcEnfDirUpdated: 'yes'
pcEnfPref: enforced
pcTag: '32770'
scope: '2916352'
seg: '2916352'
status: ''
uid: '15374'
- - oob
- inb
- ave-ctrl
- default
- overlay-1
- copy
- v38-aci
- - uni/tn-mgmt/ctx-oob
- uni/tn-mgmt/ctx-inb
- uni/tn-infra/ctx-ave-ctrl
- uni/tn-common/ctx-default
- uni/tn-infra/ctx-overlay-1
- uni/tn-common/ctx-copy
- uni/tn-tn-ncsd/ctx-v38-aci
PLAY RECAP
*****************************************************************************************************************************************************************************************************************************
mgtapic01 : ok=2 changed=0 unreachable=0 failed=0
skipped=0 rescued=0 ignored=0
Thursday 02 July 2020 13:08:43 +0100 (0:00:00.154) 0:00:00.875
*********
===============================================================================
Query all VRFs
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0.70s
debug
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0.15s
but would like to try & capture the output as
<name>:
tenant: <dn> (removing the "uni/tn-" & the "/ctx...."
v38-aci:
tenant: tn-ncsd
Still learning here so any advise would be great. Would it be using Jinja2
filters or creating a new python script to filter?
Thanks in Advance
Albert Short
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/36d5f9b9-d13d-4ba5-a73b-f420efeaad55o%40googlegroups.com.