This Ansible playbook automates the process of backing up device configurations in your network inventory. It is designed to work with Catalyst Center Release version 2.3.7.6 or later.
The device configuration backup workflow in Cisco Catalyst Center focuses on creating backups of device configurations. The primary function of this workflow is to ensure that device configurations are backed up and stored securely for future reference or restoration.
- Back up device configurations using host names.
- Back up device configurations without requiring passwords.
- Back up device configurations for all devices.
- Back up device configurations using site names.
- Ensure the Catalyst Center version is compatible.
- Carefully configure inventory and input variables.
- Validate input using yamale to prevent errors.
- Review execution logs for troubleshooting.
2.3.7.6 and above
config specifies the devices and their details to include in the backup.
Refer to the official documentation for detailed information on defining workflows: https://galaxy.ansible.com/ui/repo/published/cisco/dnac/content/module/device_configs_backup_workflow_manager
Install Ansible if you haven't already Ensure you have network connectivity to your Catalyst Center instance. Checkout the project and playbooks: git@github.com:cisco-en-programmability/catalyst-center-ansible-iac.git
The host_inventory_dnac1/hosts.yml file specifies the connection details (IP address, credentials, etc.) for your Catalyst Center instance. Make sure the dnac_version in this file matches your actual Catalyst Center version.
catalyst_center_hosts:
hosts:
catalyst_center220:
dnac_host: xx.xx.xx.xx.
dnac_password: XXXXXXXX
dnac_port: 443
dnac_timeout: 60
dnac_username: admin
dnac_verify: false
dnac_version: 2.3.7.6
dnac_debug: true
dnac_log_level: INFO
dnac_log: trueThe workflows/device_config_backup/vars device_config_backup_workflow_input.yml file stores the sites details you want to configure
This step involves preparing the input data for creating or managing device configuration backup and validating your setup.
Define Input Variables: Create variable files (e.g., vars/device_config_backup_workflow_input.yml) that define the desired state of your device backup configurations.
| Parameter | Type | Required | Default Value | Description |
|---|---|---|---|---|
collection_status |
String | No | N/A | Device collection status (e.g., Managed, Unmanaged). |
family |
String | No | N/A | Device family (e.g., Switches and Hubs, Routers). |
file_password |
String | No | N/A | Password to encrypt the backup file. |
file_path |
String | Yes | N/A | Directory path where backup files will be stored. |
hostname_list |
List | No | N/A | List of device hostnames to backup. |
ip_address_list |
List | No | N/A | List of device IP addresses to backup. |
mac_address_list |
List | No | N/A | List of device MAC addresses to backup. |
serial_number_list |
List | No | N/A | List of device serial numbers to backup. |
series |
String | No | N/A | Device series (e.g., Cisco Catalyst 9300 Series Switches). |
site_list |
List | No | N/A | List of site names to backup devices from. |
type |
String | No | N/A | Device type filter for backup. |
unzip_backup |
Boolean | No | false | Whether to unzip the backup file after download. |
The workflows/device_config_backup/vars/device_config_backup_workflow_input.yml file should be configured with device details Refer to the full workflow specification for detailed instructions on available options and their configuration structure: https://galaxy.ansible.com/ui/repo/published/cisco/dnac/content/module/device_configs_backup_workflow_manager
Validate the input with schema using yamale
yamale -s workflows/device_config_backup/schema/device_config_backup_workflow_schema.yml workflows/device_config_backup/vars/device_config_backup_workflow_input.ymlansible-playbook -i host_inventory_dnac1/hosts.yml workflows/device_config_backup/playbook/device_config_backup_workflow_playbook.yml \
--e VARS_FILE_PATH=../vars/device_config_backup_workflow_input.yml -vvvv- The config parameter within this task corresponds to the Provision > Inventory > Actions > Export Inventory" action in the Cisco Catalyst Center UI.

- Enter password and click Export

hostname:
- file_password: qsaA12!asdasd
hostname_list: ['DC-T-9300','SJ-IM-1-9300','SJ-EN-10-9300']
file_path: "./"
- file_password: The password used to encrypt the backup file.
- hostname_list: A list of hostnames for which the device configurations will be backed up.
- file_path: The directory path where the backup files will be stored.
device_configs_backup_details:
- hostname_list: ['DC-T-9300.cisco.local']
file_path: "./"
- hostname_list: A list of hostnames for which the device configurations will be backed up.
- file_path: The directory path where the backup files will be stored.
- The config parameter within this task corresponds to the Provision > Inventory > Actions > Export Inventory" action in the Cisco Catalyst Center UI.
- Enter password and click Export
device_configs_backup_details:
- ip_address_list: [204.1.2.5]
file_path: "./"
unzip_backup: true
- ip_address_list: A list of IP address for which the device configurations will be backed up.
- file_path: The directory path where the backup files will be stored.
- The config parameter within this task corresponds to the Provision > Inventory > Actions > Export Inventory" action in the Cisco Catalyst Center UI.
- Enter password and click Export
device_configs_backup_details:
- collection_status_list: [Managed]
file_path: "./"
- collection_status_list: A list of manage status for which the device configurations will be backed up.
- file_path: The directory path where the backup files will be stored.
- The config parameter within this task corresponds to the Provision > Inventory > Actions > Export Inventory" action in the Cisco Catalyst Center UI.
- Enter password and click Export
device_configs_backup_details:
- family_list: [Switches and Hubs]
file_path: "./"
- family_list: A list of family list for which the device configurations will be backed up.
- file_path: The directory path where the backup files will be stored.
- The config parameter within this task corresponds to the Provision > Inventory > Actions > Export Inventory" action in the Cisco Catalyst Center UI.
- Enter password and click Export
device_configs_backup_details:
- mac_address_list: ['34:88:18:f0:a1:80']
file_path: "./"
- mac_address_list: A list of MAC Address for which the device configurations will be backed up.
- file_path: The directory path where the backup files will be stored.
- The config parameter within this task corresponds to the Provision > Inventory > Actions > Export Inventory" action in the Cisco Catalyst Center UI.
- Enter password and click Export
device_configs_backup_details:
- serial_number_list: ['FJC272127LW]'
file_path: "./"
- serial_number_list: A list of serial number for which the device configurations will be backed up.
- file_path: The directory path where the backup files will be stored.
- The config parameter within this task corresponds to the Provision > Inventory > Actions > Export Inventory" action in the Cisco Catalyst Center UI.
- Enter password and click Export
device_configs_backup_details:
- series_list: ['Cisco Catalyst 9300 Series Switches']
file_path: "./"
- series_list: A list of series list for which the device configurations will be backed up.
- file_path: The directory path where the backup files will be stored.
- The config parameter within this task corresponds to the Provision > Inventory > Actions > Export Inventory" action in the Cisco Catalyst Center UI.
- Enter password and click Export
device_configs_backup_details:
- site_list: ['Global']
file_path: "./"
- site_list: A list of sites for which the device configurations will be backed up.
- file_path: The directory path where the backup files will be stored.
- The config parameter within this task corresponds to the Provision > Inventory > Actions > Export Inventory" action in the Cisco Catalyst Center UI.
- Enter password and click Export
device_configs_backup_details:
- ip_address_list: [204.1192.3.40]
hostname_list:["DC-FR-9300.cisco.local"]
collection_status: Managed
file_path: "./"
unzip_backup: false
Note: The environment is used for the references in the above instructions.
ansible: 9.9.0
ansible-core: 2.16.10
ansible-runner: 2.4.0
dnacentersdk: 2.8.3
cisco.dnac: 6.29.0
ansible.utils: 5.1.2
flowchart TD
A[Start] --> B[Step 1: Create virtual env and install dependencies]
B --> C[Step 2: Provide workflow inputs]
C --> D{Choose input location}
D -->|Option A| E[Update inventory hosts.yaml]
D -->|Option B| F[Update vars input file]
E --> G[Step 3: Export env vars]
F --> G
G --> H[Run ansible-playbook]
H --> I[Review playbook summary output]
I --> J[Done]
- Create and activate a Python virtual environment, then install dependencies.
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
ansible-galaxy collection install cisco.dnac --force-
Provide workflow inputs in either inventory (
inventory/demo_lab/hosts.yaml) or the workflowvars/file. -
Export Catalyst Center environment variables and run the playbook.
export HOSTIP=<catalyst-center-ip-or-fqdn>
export CATALYST_CENTER_USERNAME=<username>
export CATALYST_CENTER_PASSWORD='<password>'
ansible-playbook -i ./inventory/demo_lab/hosts.yaml ./workflows/device_config_backup/playbook/device_config_backup_workflow_playbook.yml -vvvv







