Skip to content

Added Playbook Examples#411

Merged
madhansansel merged 3 commits intomainfrom
add_playbook_examples
Apr 13, 2026
Merged

Added Playbook Examples#411
madhansansel merged 3 commits intomainfrom
add_playbook_examples

Conversation

@shatagopasunil
Copy link
Copy Markdown

@shatagopasunil shatagopasunil commented Apr 13, 2026

I accidentally committed the playbook file after modifying it for testing a bug fix.

I have restored all the playbook examples to their earlier state.

- vn_name: "VN3"
anycast_gateways:
- ip_pool_name: "Chennai-VN1-Pool2"
- vn_name: "Chennai_VN1"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove all the below lines.. not required?

- "credentials.yml"
tasks:
# Example 1: Generate all configurations with default file path
- name: Generate the playbook config for all Fabric VLANs, Virtual Networks, and Anycast Gateways in Cisco Catalyst Center
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- name: Generate playbook config for all components using default file path

# No config provided - generates all configurations

# Example 2: Generate all configurations with custom file path
- name: Generate the playbook config for all Fabric VLANs, Virtual Networks, and Anycast Gateways in Cisco Catalyst Center
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- name: Generate playbook config for all components with custom file path and overwrite mode

components_list: ["anycast_gateways"]

# Example 6: Generate all components with custom file path
- name: Generate the playbook config for Fabric VLANs, Virtual Networks, and Anycast Gateways in Cisco Catalyst Center
Copy link
Copy Markdown
Collaborator

@madhansansel madhansansel Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- name: Generate all components by explicitly listing all in components_list (equivalent to no config)

dnac_port: "{{ dnac_port }}"
dnac_version: "{{ dnac_version }}"
dnac_debug: "{{ dnac_debug }}"
dnac_log_level: DEBUG
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        dnac_log: "{{ dnac_log | default(true) }}"
        dnac_log_level: "{{ dnac_log_level | default('DEBUG') }}"

First dnac_log and then log_level..
May be we can update for other plays as well ...

file_path: "tmp/anycast_gateways_vn.yml"
config:
component_specific_filters:
components_list: ["anycast_gateways"] # This line is optional
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While YAML technically supports # inline comments, mixing them with flow-sequence values can be fragile. Move the comment to its own line:

            # components_list is optional when component-specific filters are provided
            components_list: ["anycast_gateways"]

# Example 6: Generate all components with custom file path
- name: Generate the playbook config for Fabric VLANs, Virtual Networks, and Anycast Gateways in Cisco Catalyst Center
cisco.dnac.sda_fabric_virtual_networks_playbook_config_generator:
dnac_host: "{{ dnac_host }}"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of writing dnac_*, we can either you YAML anchors, module_defaults or a block: would reduce duplication and improve maintainability.

Ansible's module_defaults lets you set default parameters for a specific module across all tasks in the play:

For Example..

---
- name: Generates Fabric VLANs, Virtual Networks, and Anycast Gateways for SDA in Cisco Catalyst Center
  hosts: localhost
  connection: local
  gather_facts: false
  vars_files:
    - "credentials.yml"

  module_defaults:
    cisco.dnac.sda_fabric_virtual_networks_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_level: "{{ dnac_log_level | default('INFO') }}"
      dnac_log: "{{ dnac_log | default(true) }}"
      state: gathered

  tasks:
    - name: Generate playbook config for all components using default file path
      cisco.dnac.sda_fabric_virtual_networks_playbook_config_generator:
        # All dnac_* params and state inherited automatically

    - name: Generate playbook config for all components with custom file path
      cisco.dnac.sda_fabric_virtual_networks_playbook_config_generator:
        file_path: "tmp/all_configurations.yml"
        file_mode: "overwrite"

    - name: Generate playbook config for Fabric VLANs only
      cisco.dnac.sda_fabric_virtual_networks_playbook_config_generator:
        file_path: "tmp/all_fabric_vlans.yml"
        file_mode: "append"
        config:
          component_specific_filters:
            components_list: ["fabric_vlan"]


@shatagopasunil shatagopasunil force-pushed the add_playbook_examples branch from b956444 to 06f6389 Compare April 13, 2026 15:24
@madhansansel madhansansel merged commit 8d7d2d3 into main Apr 13, 2026
12 of 13 checks passed
@shatagopasunil shatagopasunil deleted the add_playbook_examples branch April 13, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants