cisco.dnac.user_role_playbook_config_generator module -- Generate YAML playbook for user and role management.
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.user_role_playbook_config_generator.
New in cisco.dnac 6.44.0
Synopsis
Generates YAML configurations compatible with the
user_role_workflow_managermodule from existing Catalyst Center user and role configurations.Automates brownfield discovery by extracting current user accounts and custom role definitions into playbook format.
Reduces manual effort in creating Ansible playbooks for user and role management operations.
Supports selective extraction using filters for usernames, emails, and role names.
Generated YAML can be directly used with
user_role_workflow_managerfor configuration management and disaster recovery scenarios.
Requirements
The below requirements are needed on the host that executes this module.
dnacentersdk >= 2.7.2
python >= 3.9
Parameters
Parameter |
Comments |
|---|---|
A dictionary of filters for generating YAML playbook compatible with the If If Under |
|
Filters to specify which components to include in the YAML configuration file and criteria for filtering data. Mandatory when If If component filter blocks (for example If no component filter blocks are provided, Each component can have specific filters to select subset of configurations based on attributes. |
|
List of component names to include in the YAML output. Supported components are If component filter blocks are not specified, this option is mandatory and must be non-empty. If component filter blocks are specified, missing components are auto-added. Order in the list does not affect output structure. Invalid component names will cause module to fail with error message listing allowed components. Choices: |
|
List of filter parameter dictionaries to select specific roles for inclusion in YAML output. Multiple filter parameter sets use OR logic (any match includes the role). If not specified, all custom roles are included (system roles are always excluded). System roles (SUPER-ADMIN, NETWORK-ADMIN, OBSERVER) and roles with type 'default' or 'system' are automatically excluded. |
|
List of role names to filter roles by exact name match. Matching is case-sensitive for role names. Only custom roles matching these names will be included in output. System and default roles are excluded regardless of filter. Example |
|
List of filter parameter dictionaries to select specific users for inclusion in YAML output. Multiple filter parameter sets use OR logic (any match includes the user). Within a single filter parameter set, all criteria must match (AND logic). If not specified, all users are included (subject to All filter values are case-insensitive. |
|
List of email addresses to filter users by exact email match. Matching is case-insensitive. Users with email addresses in this list will be included in output. Example |
|
List of role names to filter users by assigned role. Matching is case-insensitive. Users having any of the specified roles will be included in output. Role names should match exactly as defined in Catalyst Center. Example |
|
List of usernames to filter users by exact username match. Matching is case-insensitive. Users with usernames in this list will be included in output. Example |
|
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 the generated YAML configuration file. The overwrite option replaces existing file content with new content. The append option adds new content to the end of existing file. Relevant only when Defaults to overwrite if not specified. Choices: |
|
Absolute or relative path where the YAML configuration file will be saved. If not provided, the file is saved in the current working directory with auto-generated filename. Default filename pattern is |
|
The desired state for the module operation. Only The Choices: |
|
Flag for Cisco Catalyst Center SDK to enable the validation of request bodies against a JSON schema. Choices: |
Notes
Note
Minimum supported Catalyst Center version is 2.3.5.3 which introduced user and role retrieval APIs.
System roles (SUPER-ADMIN, NETWORK-ADMIN, OBSERVER) are automatically excluded from role_details output.
Roles with type 'default' or 'system' are automatically excluded from output.
Generated YAML file structure matches the input format expected by
user_role_workflow_managermodule.Role permissions are transformed from API resourceTypes format to hierarchical permission structure with 9 categories.
User role assignments are transformed from role IDs to role names for readability.
All filter values are expected as lists of strings, even for single values.
Check mode is supported but does not generate files (dry-run).
SDK Methods used are - user_and_roles.UserandRoles.get_users_api - user_and_roles.UserandRoles.get_roles_api
Paths used are - GET /dna/system/api/v1/user - GET /dna/system/api/v1/role
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.user_role_workflow_manager
Module to manage users and roles using generated YAML.
Examples
- name: Generate YAML Configuration with File Path specified
cisco.dnac.user_role_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}}"
dnac_log: true
dnac_log_level: "{{dnac_log_level}}"
state: gathered
file_path: "/tmp/catc_user_role_config.yaml"
- name: Generate YAML Configuration with specific user components only
cisco.dnac.user_role_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}}"
dnac_log: true
dnac_log_level: "{{dnac_log_level}}"
state: gathered
file_path: "/tmp/catc_user_role_config.yaml"
file_mode: "overwrite"
config:
component_specific_filters:
components_list: ["user_details"]
- name: Generate YAML Configuration with specific role components only
cisco.dnac.user_role_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}}"
dnac_log: true
dnac_log_level: "{{dnac_log_level}}"
state: gathered
file_path: "/tmp/catc_user_role_config.yaml"
config:
component_specific_filters:
components_list: ["role_details"]
- name: Generate YAML Configuration for users with username filter
cisco.dnac.user_role_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}}"
dnac_log: true
dnac_log_level: "{{dnac_log_level}}"
state: gathered
file_path: "/tmp/catc_user_role_config.yaml"
config:
component_specific_filters:
components_list: ["user_details"]
user_details:
- username: ["testuser1", "testuser2"]
- name: Generate YAML Configuration for roles with role name filter
cisco.dnac.user_role_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}}"
dnac_log: true
dnac_log_level: "{{dnac_log_level}}"
state: gathered
file_path: "/tmp/catc_user_role_config.yaml"
config:
component_specific_filters:
components_list: ["role_details"]
role_details:
- role_name: ["Custom-Admin-Role", "Network-Operator-Role"]
- name: Generate YAML Configuration for all components with no filters
cisco.dnac.user_role_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}}"
dnac_log: true
dnac_log_level: "{{dnac_log_level}}"
state: gathered
file_path: "/tmp/catc_user_role_config.yaml"
config:
component_specific_filters:
components_list: ["user_details", "role_details"]
- name: Generate YAML for users with specific email addresses
cisco.dnac.user_role_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}}"
dnac_log: true
dnac_log_level: "{{dnac_log_level}}"
state: gathered
file_path: "/tmp/catc_users_by_email.yaml"
config:
component_specific_filters:
components_list: ["user_details"]
user_details:
- email: ["admin@example.com", "operator@example.com"]
- name: Append YAML for users with specific role assignments to existing file
cisco.dnac.user_role_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}}"
dnac_log: true
dnac_log_level: "{{dnac_log_level}}"
state: gathered
file_path: "/tmp/catc_admin_users.yaml"
file_mode: "append"
config:
component_specific_filters:
components_list: ["user_details"]
user_details:
- role_name: ["SUPER-ADMIN-ROLE", "Custom-Admin-Role"]
- name: Generate YAML with multiple filter criteria (OR logic)
cisco.dnac.user_role_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}}"
dnac_log: true
dnac_log_level: "{{dnac_log_level}}"
state: gathered
file_path: "/tmp/catc_filtered_users.yaml"
config:
component_specific_filters:
components_list: ["user_details"]
user_details:
- username: ["testuser1"]
- email: ["admin@example.com"]
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 Returned: always |
|
A dictionary with the response returned by the Cisco Catalyst Center Returned: always |