Conversation
| - vn_name: "VN3" | ||
| anycast_gateways: | ||
| - ip_pool_name: "Chennai-VN1-Pool2" | ||
| - vn_name: "Chennai_VN1" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
- 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 |
There was a problem hiding this comment.
- 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 |
There was a problem hiding this comment.
- 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 }}" |
There was a problem hiding this comment.
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"]
b956444 to
06f6389
Compare
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.