cisco.dnac.discovery_playbook_config_generator module -- Generate YAML configurations playbook for 'discovery_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.discovery_playbook_config_generator.
New in cisco.dnac 6.44.0
Synopsis
Generates YAML playbooks compatible with the
discovery_workflow_managermodule by extracting existing discovery configurations from Cisco Catalyst Center.Reduces manual effort by programmatically retrieving discovery tasks including IP ranges, credential mappings, discovery types, protocol orders, and task-specific settings.
Supports selective filtering by discovery name, discovery type, or discovery status to generate targeted playbooks.
Enables complete infrastructure discovery through internal auto-discovery mode when
configis not provided.Resolves credential IDs to human-readable descriptions and usernames for generated playbooks.
Requires Cisco Catalyst Center version 2.3.7.9 or higher for discovery API support.
Requirements
The below requirements are needed on the host that executes this module.
dnacentersdk >= 2.4.5
python >= 3.9
Cisco Catalyst Center >= 2.3.7.9
Parameters
Parameter |
Comments |
|---|---|
A dictionary of filters for generating YAML playbook compatible with the 'discovery_workflow_manager' module. If config is provided, If config is omitted, module runs in internal auto-discovery mode. Global filters identify target discoveries by name or discovery type. Component-specific filters remain supported internally. |
|
Global filters to apply when generating the YAML configuration file. These filters identify which discovery tasks to extract configurations from. Mandatory when |
|
List of discovery task names to extract configurations from. HIGHEST PRIORITY - If provided, discovery types will be ignored. Discovery names must match those configured in Catalyst Center. Case-sensitive and must be exact matches. Example ["Multi_global", "Single IP Discovery", "CDP_Test_1"] |
|
List of discovery types to filter by. LOWER PRIORITY - Only used if discovery_name_list is not provided. Valid values are Single, Range, CDP, LLDP, CIDR. Will include all discoveries matching any of the specified types. Example ["CDP", "LLDP"] Choices: |
|
Defines the timeout in seconds for API calls to retrieve task details. If the task details are not received within this period, the process will end, and a timeout notification will be logged. Default: :ansible-option-default:`1200` |
|
Indicates whether debugging is enabled in the Cisco Catalyst Center SDK. Choices: |
|
The hostname of the Cisco Catalyst Center. |
|
Flag to enable/disable playbook execution logging. When true and dnac_log_file_path is provided, - Create the log file at the execution location with the specified name. When true and dnac_log_file_path is not provided, - Create the log file at the execution location with the name 'dnac.log'. When false, - Logging is disabled. If the log file doesn't exist, - It is created in append or write mode based on the "dnac_log_append" flag. If the log file exists, - It is overwritten or appended based on the "dnac_log_append" flag. Choices: |
|
Determines the mode of the file. Set to True for 'append' mode. Set to False for 'write' mode. Choices: |
|
Governs logging. Logs are recorded if dnac_log is True. If path is not specified, - When 'dnac_log_append' is True, 'dnac.log' is generated in the current Ansible directory; logs are appended. - When 'dnac_log_append' is False, 'dnac.log' is generated; logs are overwritten. If path is specified, - When 'dnac_log_append' is True, the file opens in append mode. - When 'dnac_log_append' is False, the file opens in write (w) mode. - In shared file scenarios, without append mode, content is overwritten after each module execution. - For a shared log file, set append to False for the 1st module (to overwrite); for subsequent modules, set append to True. Default: :ansible-option-default:`"dnac.log"` |
|
Sets the threshold for log level. Messages with a level equal to or higher than this will be logged. Levels are listed in order of severity [CRITICAL, ERROR, WARNING, INFO, DEBUG]. CRITICAL indicates serious errors halting the program. Displays only CRITICAL messages. ERROR indicates problems preventing a function. Displays ERROR and CRITICAL messages. WARNING indicates potential future issues. Displays WARNING, ERROR, CRITICAL messages. INFO tracks normal operation. Displays INFO, WARNING, ERROR, CRITICAL messages. DEBUG provides detailed diagnostic info. Displays all log messages. Default: :ansible-option-default:`"WARNING"` |
|
The password for authentication at the Cisco Catalyst Center. |
|
Specifies the port number associated with the Cisco Catalyst Center. Default: :ansible-option-default:`"443"` |
|
Specifies the interval in seconds between successive calls to the API to retrieve task details. Default: :ansible-option-default:`2` |
|
The username for authentication at the Cisco Catalyst Center. Default: :ansible-option-default:`"admin"` |
|
Flag to enable or disable SSL certificate verification. Choices: |
|
Specifies the version of the Cisco Catalyst Center that the SDK should use. Default: :ansible-option-default:`"2.2.3.3"` |
|
File write mode for YAML output. Relevant only when Choices: |
|
Path where the YAML configuration file will be saved. If not provided, a default filename is generated. |
|
The desired state for the module operation. Only Choices: |
|
Flag for Cisco Catalyst Center SDK to enable the validation of request bodies against a JSON schema. Choices: |
Notes
Note
Requires minimum Cisco Catalyst Center version 2.3.7.9 for discovery API support.
Module will fail with an error if connected to an unsupported version.
Generated playbooks are compatible with the
discovery_workflow_managermodule for discovery task operations.Credential IDs are automatically resolved to descriptions and usernames using global credentials API.
Discovery-specific credentials are excluded from generated playbooks for security reasons.
The module operates in check mode but does not make any changes to Cisco Catalyst Center.
Use
dnac_loganddnac_log_levelparameters for detailed operation logging and troubleshooting.SDK Methods used are - discovery.Discovery.get_discoveries_by_range - discovery.Discovery.get_discovery_by_id - discovery.Discovery.get_all_global_credentials - discovery.Discovery.get_all_global_credentials_v2 - discovery.Discovery.get_discovered_network_devices_by_discovery_id
Paths used are - GET /dna/intent/api/v1/discovery/{startIndex}/{recordsToReturn} - GET /dna/intent/api/v1/discovery/{id} - GET /dna/intent/api/v1/global-credential - GET /dna/intent/api/v2/global-credential - GET /dna/intent/api/v1/discovery/{id}/network-device
Does not support
check_modeThe plugin runs on the control node and does not use any ansible connection plugins instead embedded connection manager from Cisco Catalyst Center SDK
The parameters starting with dnac_ are used by the Cisco Catalyst Center Python SDK to establish the connection
See Also
See also
- cisco.dnac.discovery_workflow_manager
Manage discovery workflows in Cisco Catalyst Center.
Examples
# Generate YAML configurations for all discovery tasks
- name: Generate all discovery configurations
cisco.dnac.discovery_playbook_config_generator:
dnac_host: "{{ dnac_host }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_port: "{{ dnac_port }}"
dnac_version: "{{ dnac_version }}"
dnac_debug: "{{ dnac_debug }}"
state: gathered
# Generate configurations for specific discovery tasks by name
- name: Generate specific discovery configurations by name
cisco.dnac.discovery_playbook_config_generator:
dnac_host: "{{ dnac_host }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_port: "{{ dnac_port }}"
dnac_version: "{{ dnac_version }}"
dnac_debug: "{{ dnac_debug }}"
state: gathered
file_path: "/tmp/specific_discoveries.yml"
file_mode: overwrite
config:
global_filters:
discovery_name_list:
- "Multi_global"
- "Single IP Discovery"
- "CDP_Test_1"
# Generate configurations for specific discovery types with append mode
- name: Generate configurations by discovery type
cisco.dnac.discovery_playbook_config_generator:
dnac_host: "{{ dnac_host }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_port: "{{ dnac_port }}"
dnac_version: "{{ dnac_version }}"
dnac_debug: "{{ dnac_debug }}"
state: gathered
file_path: "/tmp/cdp_lldp_discoveries.yml"
file_mode: append
config:
global_filters:
discovery_type_list:
- "CDP"
- "LLDP"
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
A dictionary with the details of the generated YAML configuration Returned: always |
|
A dictionary indicating no discoveries were found Returned: when no discoveries match the filtering criteria |
|
A dictionary with error details Returned: when an error occurs during generation |