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_manager module 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 config is 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

config

dictionary

A dictionary of filters for generating YAML playbook compatible with the 'discovery_workflow_manager' module.

If config is provided, global_filters is mandatory.

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

dictionary / required

Global filters to apply when generating the YAML configuration file.

These filters identify which discovery tasks to extract configurations from.

Mandatory when config is provided.

discovery_name_list

list / elements=string

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"]

discovery_type_list

list / elements=string

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:

dnac_api_task_timeout

integer

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`

dnac_debug

boolean

Indicates whether debugging is enabled in the Cisco Catalyst Center SDK.

Choices:

dnac_host

string / required

The hostname of the Cisco Catalyst Center.

dnac_log

boolean

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:

dnac_log_append

boolean

Determines the mode of the file. Set to True for 'append' mode. Set to False for 'write' mode.

Choices:

dnac_log_file_path

string

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"`

dnac_log_level

string

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"`

dnac_password

string

The password for authentication at the Cisco Catalyst Center.

dnac_port

string

Specifies the port number associated with the Cisco Catalyst Center.

Default: :ansible-option-default:`"443"`

dnac_task_poll_interval

integer

Specifies the interval in seconds between successive calls to the API to retrieve task details.

Default: :ansible-option-default:`2`

dnac_username

aliases: user

string

The username for authentication at the Cisco Catalyst Center.

Default: :ansible-option-default:`"admin"`

dnac_verify

boolean

Flag to enable or disable SSL certificate verification.

Choices:

dnac_version

string

Specifies the version of the Cisco Catalyst Center that the SDK should use.

Default: :ansible-option-default:`"2.2.3.3"`

file_mode

string

File write mode for YAML output.

Relevant only when file_path is provided.

Choices:

file_path

string

Path where the YAML configuration file will be saved.

If not provided, a default filename is generated.

state

string

The desired state for the module operation.

Only gathered state is supported to generate YAML playbooks from existing configurations.

Choices:

validate_response_schema

boolean

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_manager module 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_log and dnac_log_level parameters 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_mode

  • The 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

response_1

dictionary

response_2

dictionary

response_3

dictionary

Authors

  • Megha Kandari (@mekandar)

  • Madhan Sankaranarayanan (@madhansansel)