cisco.aci.aci_listify filter – Flattens the nested dictionaries representing the ACI model data.
Note
This filter plugin is part of the cisco.aci collection (version 2.10.1).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install cisco.aci
.
To use it in a playbook, specify: cisco.aci.aci_listify
.
Synopsis
This filter flattens and transforms the input data into a list.
See the Examples section below.
Keyword parameters
This describes keyword parameters of the filter. These are the values key1=value1
, key2=value2
and so on in the following
example: input | cisco.aci.aci_listify(key1=value1, key2=value2, ...)
Parameter |
Comments |
---|---|
This option represents the ACI model data which is a list of dictionaries or a dictionary with any level of nesting data. |
|
Comma separated keys of type string denoting the ACI objects. |
Examples
- name: Set vars
ansible.builtin.set_fact:
data:
tenant:
- name: ansible_test
description: Created using listify
app:
- name: app_test
epg:
- name: web
bd: web_bd
- name: app
bd: app_bd
bd:
- name: bd_test
subnet:
- name: 10.10.10.1
mask: 24
scope:
- public
- shared
vrf: vrf_test
- name: bd_test2
subnet:
- name: 20.20.20.1
mask: 24
scope: public
vrf: vrf_test
vrf:
- name: vrf_test
policies:
protocol:
bfd:
- name: BFD-ON
description: Enable BFD
admin_state: enabled
detection_multiplier: 3
min_tx_interval: 50
min_rx_interval: 50
echo_rx_interval: 50
echo_admin_state: enabled
sub_interface_optimization_state: enabled
ospf:
interface:
- name: OSPF-P2P-IntPol
network_type: p2p
priority: 1
- name: OSPF-Broadcast-IntPol
network_type: bcast
priority: 1
- name: Create tenants
cisco.aci.aci_tenant:
host: apic
username: admin
password: SomeSecretPassword
tenant: '{{ item.tenant_name }}'
description: '{{ item.tenant_description }}'
with_items: '{{ data|cisco.aci.aci_listify("tenant") }}'
- name: Create VRFs
cisco.aci.aci_vrf:
host: apic
username: admin
password: SomeSecretPassword
tenant: '{{ item.tenant_name }}'
vrf_name: '{{ item.tenant_vrf_name }}'
with_items: '{{ data|cisco.aci.aci_listify("tenant","vrf") }}'
- name: Create BDs
cisco.aci.aci_bd:
host: apic
username: admin
password: SomeSecretPassword
tenant: '{{ item.tenant_name }}'
vrf: '{{ item.tenant_bd_vrf }}'
bd: '{{ item.tenant_bd_name }}'
enable_routing: 'yes'
with_items: '{{ data|cisco.aci.aci_listify("tenant","bd") }}'
- name: Create BD subnets
cisco.aci.aci_bd_subnet:
host: apic
username: admin
password: SomeSecretPassword
tenant: '{{ item.tenant_name }}'
bd: '{{ item.tenant_bd_name }}'
gateway: '{{ item.tenant_bd_subnet_name }}'
mask: '{{ item.tenant_bd_subnet_mask }}'
scope: '{{ item.tenant_bd_subnet_scope }}'
with_items: '{{ data|cisco.aci.aci_listify("tenant","bd","subnet") }}'
- name: Create APs
cisco.aci.aci_ap:
host: apic
username: admin
password: SomeSecretPassword
tenant: '{{ item.tenant_name }}'
app_profile: '{{ item.tenant_app_name }}'
with_items: '{{ data|cisco.aci.aci_listify("tenant","app") }}'
- name: Create EPGs
cisco.aci.aci_epg:
host: apic
username: admin
password: SomeSecretPassword
tenant: '{{ item.tenant_name }}'
app_profile: '{{ item.tenant_app_name }}'
epg: '{{ item.tenant_app_epg_name }}'
bd: '{{ item.tenant_app_epg_bd }}'
with_items: '{{ data|cisco.aci.aci_listify("tenant","app","epg") }}'
Return Value
Key |
Description |
---|---|
The existing configuration from the APIC after the module has finished Returned: success Sample: |
|
The error information as returned from the APIC Returned: failure Sample: |
|
The filter string used for the request Returned: failure or debug Sample: |
|
The HTTP method used for the request to the APIC Returned: failure or debug Sample: |
|
The original configuration from the APIC before the module has started Returned: info Sample: |
|
The assembled configuration from the user-provided parameters Returned: info Sample: |
|
The raw output returned by the APIC REST API (xml or json) Returned: parse error Sample: |
|
The HTTP response from the APIC Returned: failure or debug Sample: |
|
The actual/minimal configuration pushed to the APIC Returned: info Sample: |
|
The HTTP status from the APIC Returned: failure or debug Sample: |
|
The HTTP url used for the request to the APIC Returned: failure or debug Sample: |
Hint
Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.