cisco.dnac.inventory_playbook_config_generator module -- Generate YAML playbook input for 'inventory_workflow_manager' module.
Note
This module is part of the cisco.dnac collection (version 6.49.0).
To install it, use: ansible-galaxy collection install cisco.dnac.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: cisco.dnac.inventory_playbook_config_generator.
New in cisco.dnac 6.44.0
Synopsis
Generates YAML input files for
cisco.dnac.inventory_workflow_manager.Supports independent component generation for device details, SDA provisioning, interface details, and user-defined fields.
Supports global device filters by IP, hostname, serial number, and MAC address.
In non-auto mode, provide
component_specific_filters.components_listto control which component sections are generated.
Requirements
The below requirements are needed on the host that executes this module.
dnacentersdk >= 2.10.10
python >= 3.9
Parameters
Parameter |
Comments |
|---|---|
A list of filters for generating YAML playbook compatible with the 'inventory_workflow_manager' module. Filters specify which devices and credentials to include in the YAML configuration file. If "components_list" is specified, only those components are included, regardless of the filters. |
|
Filters to specify which components and device attributes to include in the YAML configuration file. If "components_list" is specified, only those components are included. Additional filters can be applied to narrow down device selection based on role, type, etc. |
|
List of components to include in the YAML configuration file. Valid values are "device_details", "provision_device", "interface_details", and "user_defined_fields". If not specified, all components are included. Choices: |
|
Filters for device configuration generation. Accepts a dict or a list of dicts. List behavior OR between dict entries. Dict behavior AND between filter keys. Supported keys include type, role, snmp_version, and cli_transport. Type options: NETWORK_DEVICE, COMPUTE_DEVICE, MERAKI_DASHBOARD, THIRD_PARTY_DEVICE, FIREPOWER_MANAGEMENT_SYSTEM. Role options: ACCESS, CORE, DISTRIBUTION, BORDER ROUTER, UNKNOWN. SNMP version options: v2, v2c, v3. CLI transport options: ssh or telnet. |
|
Filter devices by network role. Can be a single role string or a list of roles (matches any in the list). Valid values are ACCESS, CORE, DISTRIBUTION, BORDER ROUTER, UNKNOWN. Example: role="ACCESS" for single role or role=["ACCESS", "CORE"] for multiple roles. Choices: |
|
Component selector for auto-generated interface_details. Filters interface configurations based on device IP addresses and interface names. Interfaces are automatically discovered from matched devices using Catalyst Center API. |
|
Filter interfaces by name (optional). Can be a single interface name string or a list of interface names. When specified, only interfaces with matching names will be included. Matches use 'OR' logic; any interface matching any name in the list is included. Common interface names include Vlan100, Loopback0, GigabitEthernet1/0/1, or FortyGigabitEthernet1/1/1. If not specified, all discovered interfaces for matched devices are included. Example: interface_name="Vlan100" for single or interface_name=["Vlan100", "Loopback0"] for multiple. |
|
Specific filters for provision_device component. Filters the provision_wired_device configuration based on site assignment. No additional API calls are made; filtering is applied to existing provision data. |
|
Filter provision devices by site name (e.g., Global/India/Telangana/Hyderabad/BLD_1). |
|
Filters for user-defined fields (UDF) component generation. Supports filtering by UDF field name and/or UDF field value. Both List behavior uses OR logic (match any item in the list). |
|
Filter UDF output by field name. Accepts a single name string or a list of names. When specified, only matching UDF names are included. Example: name="Cisco Switches" or name=["Cisco Switches", "To_test_udf"]. |
|
Filter UDF output by field value. Accepts a single value string or a list of values. When specified, only UDFs with matching values are included. Example: value="2234" or value=["2234", "value12345"]. |
|
Controls how config is written to the YAML file.
Choices: |
|
Path where the YAML configuration file will be saved. If not provided, the file will be saved in the current working directory with a default file name For example, |
|
When set to True, automatically generates YAML configurations for all devices in Cisco Catalyst Center. This mode discovers all managed devices in Cisco Catalyst Center and extracts all device inventory configurations. When enabled, the config parameter becomes optional and will use default values if not provided. A default filename will be generated automatically if file_path is not specified. This is useful for complete infrastructure discovery and documentation. Note - Only devices with manageable software versions are included in the output. Choices: |
|
Global filters to apply when generating the YAML configuration file. These filters apply to all components unless overridden by component-specific filters. Supports filtering devices by IP address, hostname, serial number, or MAC address. |
|
List of device hostnames to include in the YAML configuration file. When specified, only devices with matching hostnames will be included. For example, ["switch-1", "router-1", "firewall-1"] |
|
List of device IP addresses to include in the YAML configuration file. When specified, only devices with matching management IP addresses will be included. For example, ["192.168.1.1", "192.168.1.2", "192.168.1.3"] |
|
List of device MAC addresses to include in the YAML configuration file. When specified, only devices with matching MAC addresses will be included. For example, ["e4:1f:7b:d7:bd:00", "a1:b2:c3:d4:e5:f6"] |
|
List of device serial numbers to include in the YAML configuration file. When specified, only devices with matching serial numbers will be included. For example, ["ABC123456789", "DEF987654321"] |
|
API task timeout in seconds. Default: :ansible-option-default:`1200` |
|
Enable debug logging. Choices: |
|
Cisco Catalyst Center hostname or IP address. |
|
Enable logging to file. Choices: |
|
Append to log file instead of overwriting. Choices: |
|
Path for debug log file. Default: :ansible-option-default:`"dnac.log"` |
|
Log level for module execution. Default: :ansible-option-default:`"WARNING"` |
|
Cisco Catalyst Center password. |
|
Cisco Catalyst Center port number. Default: :ansible-option-default:`"443"` |
|
Task poll interval in seconds. Default: :ansible-option-default:`2` |
|
Cisco Catalyst Center username. Default: :ansible-option-default:`"admin"` |
|
Verify SSL certificate for Cisco Catalyst Center. Choices: |
|
Cisco Catalyst Center version. Default: :ansible-option-default:`"2.2.3.3"` |
|
The desired state of Cisco Catalyst Center after module execution. Choices: |
|
Validate response schema from API. Choices: |
Notes
Note
SDK Methods used are - devices.Devices.get_device_list - devices.Devices.get_network_device_by_ip - devices.Devices.get_device_by_ip - licenses.Licenses.device_license_summary
API Endpoints used are GET /dna/intent/api/v2/devices (list all devices), GET /dna/intent/api/v2/network-device (get network device info), GET /dna/intent/api/v1/interface/ip-address/{ipAddress} (get interfaces for device IP), and GET /dna/intent/api/v1/licenses/device/summary (get device license and site info).
Device Consolidation: Devices are grouped and consolidated by their configuration hash. All interfaces from devices with identical configurations are grouped under a single device entry. This reduces redundancy when multiple physical devices share the same configuration.
Component Independence: Each component (device_details, provision_device, interface_details) is filtered independently. Global filters apply to all components unless overridden by component-specific filters. Interface details are automatically fetched based on matched device IPs.
Interface Discovery: Interfaces are discovered using the IP-to-interface API endpoint. Interface names can be optionally filtered using the interface_name parameter. When no interfaces match the filter criteria, no interface_details output is generated.
See Also
See also
- cisco.dnac.inventory_workflow_manager
Module for managing inventory configurations in Cisco Catalyst Center.
Examples
- name: Generate inventory playbook for all devices
cisco.dnac.inventory_playbook_config_generator:
dnac_host: "{{ dnac_host }}"
dnac_port: "{{ dnac_port }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_version: "{{ dnac_version }}"
dnac_debug: "{{ dnac_debug }}"
state: gathered
config:
generate_all_configurations: true
file_mode: "overwrite"
file_path: "./inventory_devices_all.yml"
- name: Generate inventory playbook for specific devices by IP address
cisco.dnac.inventory_playbook_config_generator:
dnac_host: "{{ dnac_host }}"
dnac_port: "{{ dnac_port }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_version: "{{ dnac_version }}"
dnac_debug: "{{ dnac_debug }}"
state: gathered
config:
global_filters:
ip_address_list:
- "10.195.225.40"
- "10.195.225.42"
file_mode: "overwrite"
file_path: "./inventory_devices_by_ip.yml"
- name: Generate inventory playbook for devices by hostname
cisco.dnac.inventory_playbook_config_generator:
dnac_host: "{{ dnac_host }}"
dnac_port: "{{ dnac_port }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_version: "{{ dnac_version }}"
dnac_debug: "{{ dnac_debug }}"
state: gathered
config:
global_filters:
hostname_list:
- "cat9k_1"
- "cat9k_2"
- "switch_1"
file_mode: "overwrite"
file_path: "./inventory_devices_by_hostname.yml"
- name: Generate inventory playbook for devices by serial number
cisco.dnac.inventory_playbook_config_generator:
dnac_host: "{{ dnac_host }}"
dnac_port: "{{ dnac_port }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_version: "{{ dnac_version }}"
dnac_debug: "{{ dnac_debug }}"
state: gathered
config:
global_filters:
serial_number_list:
- "FCW2147L0AR1"
- "FCW2147L0AR2"
file_mode: "overwrite"
file_path: "./inventory_devices_by_serial.yml"
- name: Generate inventory playbook for mixed device filtering
cisco.dnac.inventory_playbook_config_generator:
dnac_host: "{{ dnac_host }}"
dnac_port: "{{ dnac_port }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_version: "{{ dnac_version }}"
dnac_debug: "{{ dnac_debug }}"
state: gathered
config:
global_filters:
ip_address_list:
- "10.195.225.40"
hostname_list:
- "cat9k_1"
file_mode: "overwrite"
file_path: "./inventory_devices_mixed_filter.yml"
- name: Generate inventory playbook with default file path
cisco.dnac.inventory_playbook_config_generator:
dnac_host: "{{ dnac_host }}"
dnac_port: "{{ dnac_port }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_version: "{{ dnac_version }}"
dnac_debug: "{{ dnac_debug }}"
state: gathered
config:
global_filters:
ip_address_list:
- "10.195.225.40"
file_mode: "overwrite"
- name: Generate inventory playbook for multiple devices
cisco.dnac.inventory_playbook_config_generator:
dnac_host: "{{ dnac_host }}"
dnac_port: "{{ dnac_port }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_version: "{{ dnac_version }}"
dnac_debug: "{{ dnac_debug }}"
state: gathered
config:
global_filters:
ip_address_list:
- "10.195.225.40"
- "10.195.225.41"
- "10.195.225.42"
- "10.195.225.43"
file_mode: "overwrite"
file_path: "./inventory_devices_multiple.yml"
- name: Generate inventory playbook for ACCESS role devices only
cisco.dnac.inventory_playbook_config_generator:
dnac_host: "{{ dnac_host }}"
dnac_port: "{{ dnac_port }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_version: "{{ dnac_version }}"
dnac_debug: "{{ dnac_debug }}"
state: gathered
config:
component_specific_filters:
components_list: ["device_details"]
device_details:
- role: "ACCESS"
file_mode: "overwrite"
file_path: "./inventory_access_role_devices.yml"
- name: Generate inventory playbook with auto-populated provision_wired_device
cisco.dnac.inventory_playbook_config_generator:
dnac_host: "{{ dnac_host }}"
dnac_port: "{{ dnac_port }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_version: "{{ dnac_version }}"
dnac_debug: "{{ dnac_debug }}"
state: gathered
config:
generate_all_configurations: true
file_mode: "overwrite"
file_path: "./inventory_with_provisioning.yml"
- name: Generate inventory playbook with interface filtering
cisco.dnac.inventory_playbook_config_generator:
dnac_host: "{{ dnac_host }}"
dnac_port: "{{ dnac_port }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_version: "{{ dnac_version }}"
dnac_debug: "{{ dnac_debug }}"
state: gathered
config:
global_filters:
ip_address_list:
- "10.195.225.40"
- "10.195.225.42"
component_specific_filters:
interface_details:
interface_name:
- "Vlan100"
- "GigabitEthernet1/0/1"
file_mode: "overwrite"
file_path: "./inventory_interface_filtered.yml"
- name: Generate inventory playbook for specific interface on single device
cisco.dnac.inventory_playbook_config_generator:
dnac_host: "{{ dnac_host }}"
dnac_port: "{{ dnac_port }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_version: "{{ dnac_version }}"
dnac_debug: "{{ dnac_debug }}"
state: gathered
config:
global_filters:
ip_address_list:
- "10.195.225.40"
component_specific_filters:
interface_details:
interface_name: "Loopback0"
file_mode: "overwrite"
file_path: "./inventory_loopback_interface.yml"
- name: Generate complete inventory with all components and interface filter
cisco.dnac.inventory_playbook_config_generator:
dnac_host: "{{ dnac_host }}"
dnac_port: "{{ dnac_port }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_version: "{{ dnac_version }}"
dnac_debug: "{{ dnac_debug }}"
state: gathered
config:
component_specific_filters:
components_list: ["device_details", "provision_device", "interface_details"]
device_details:
role: "ACCESS"
interface_details:
interface_name:
- "GigabitEthernet1/0/1"
- "GigabitEthernet1/0/2"
- "GigabitEthernet1/0/3"
file_mode: "overwrite"
file_path: "./inventory_access_with_interfaces.yml"
- name: Generate UDF output filtered by name (single string)
cisco.dnac.inventory_playbook_config_generator:
dnac_host: "{{ dnac_host }}"
dnac_port: "{{ dnac_port }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_version: "{{ dnac_version }}"
dnac_debug: "{{ dnac_debug }}"
state: gathered
config:
component_specific_filters:
components_list: ["user_defined_fields"]
user_defined_fields:
name: "Cisco Switches"
file_mode: "overwrite"
file_path: "./inventory_udf_name_single.yml"
- name: Generate UDF output filtered by name (list)
cisco.dnac.inventory_playbook_config_generator:
dnac_host: "{{ dnac_host }}"
dnac_port: "{{ dnac_port }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_version: "{{ dnac_version }}"
dnac_debug: "{{ dnac_debug }}"
state: gathered
config:
component_specific_filters:
components_list: ["user_defined_fields"]
user_defined_fields:
name: ["Cisco Switches", "To_test_udf"]
file_mode: "overwrite"
file_path: "./inventory_udf_name_list.yml"
- name: Generate UDF output filtered by value (single string)
cisco.dnac.inventory_playbook_config_generator:
dnac_host: "{{ dnac_host }}"
dnac_port: "{{ dnac_port }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_version: "{{ dnac_version }}"
dnac_debug: "{{ dnac_debug }}"
state: gathered
config:
component_specific_filters:
components_list: ["user_defined_fields"]
user_defined_fields:
value: "2234"
file_mode: "overwrite"
file_path: "./inventory_udf_value_single.yml"
- name: Generate UDF output filtered by value (list)
cisco.dnac.inventory_playbook_config_generator:
dnac_host: "{{ dnac_host }}"
dnac_port: "{{ dnac_port }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_version: "{{ dnac_version }}"
dnac_debug: "{{ dnac_debug }}"
state: gathered
config:
component_specific_filters:
components_list: ["user_defined_fields"]
user_defined_fields:
value: ["2234", "value12345", "value321"]
file_mode: "overwrite"
file_path: "./inventory_udf_value_list.yml"
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
A dictionary with the response returned by the Cisco Catalyst Center Python SDK Returned: success |
|
A string with the error message returned by the Cisco Catalyst Center Python SDK Returned: on failure |