From fc0d91eb31da67b14ad45a090901b8ec241f7457 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Wed, 3 Sep 2025 19:11:11 -0400 Subject: [PATCH 01/65] Performance Updates --- plugins/action/common/run_map.py | 5 + plugins/action/dtc/diff_interface.py | 116 +++++++++ .../tasks/common/ndfc_interface_all.yml | 11 +- roles/dtc/common/tasks/sub_main_external.yml | 1 + roles/dtc/common/tasks/sub_main_isn.yml | 1 + roles/dtc/common/tasks/sub_main_vxlan.yml | 1 + roles/dtc/create/tasks/common/interfaces.yml | 230 +++++++++--------- roles/dtc/remove/tasks/common/interfaces.yml | 6 +- roles/validate/tasks/cleanup_model_files.yml | 40 +++ .../tasks/manage_model_files_current.yml | 30 +++ 10 files changed, 323 insertions(+), 118 deletions(-) create mode 100644 plugins/action/dtc/diff_interface.py create mode 100644 roles/validate/tasks/cleanup_model_files.yml diff --git a/plugins/action/common/run_map.py b/plugins/action/common/run_map.py index a8460f475..8b1e17c64 100644 --- a/plugins/action/common/run_map.py +++ b/plugins/action/common/run_map.py @@ -82,6 +82,11 @@ def run(self, tmp=None, task_vars=None): updated_run_map['role_deploy_completed'] = True elif stage == 'role_remove_completed': updated_run_map['role_remove_completed'] = True + elif stage == 'role_all_completed': + updated_run_map['role_validate_completed'] = True + updated_run_map['role_create_completed'] = True + updated_run_map['role_deploy_completed'] = True + updated_run_map['role_remove_completed'] = True with open(run_map_file_path, 'w') as outfile: outfile.write("### This File Is Auto Generated, Do Not Edit ###\n") diff --git a/plugins/action/dtc/diff_interface.py b/plugins/action/dtc/diff_interface.py new file mode 100644 index 000000000..3374c4e1c --- /dev/null +++ b/plugins/action/dtc/diff_interface.py @@ -0,0 +1,116 @@ +# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +# the Software, and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# SPDX-License-Identifier: MIT + +from __future__ import absolute_import, division, print_function + +import yaml +from ansible.utils.display import Display +from ansible.plugins.action import ActionBase +import logging + +display = Display() + +class ActionModule(ActionBase): + """ + Action plugin to compare existing links with new links for a fabric. + Identifies new/modified, removed, and unchanged items. + """ + def run(self, tmp=None, task_vars=None): + """ + Run the action plugin. + """ + results = super(ActionModule, self).run(tmp, task_vars) + results['interface_all'] = {} + + self.old_file_path = self._task.args['old_file'] + self.new_file_path = self._task.args['new_file'] + + old_items = [] + new_items = [] + + try: + old_items = self.load_yaml(self.old_file_path) + except (FileNotFoundError, IOError): + display.warning(f"Old file not found: {self.old_file_path}, using empty list") + + try: + new_items = self.load_yaml(self.new_file_path) + except (FileNotFoundError, IOError): + display.warning(f"New file not found: {self.new_file_path}, using empty list") + + updated_items, removed_items, equal_items = self.compare_items(old_items, new_items) + + display.v("New or Modified Items:\n%s", yaml.dump(updated_items, default_flow_style=False)) + display.v("---------------------------------") + display.v("Remove Items:\n%s", yaml.dump(removed_items, default_flow_style=False)) + display.v("---------------------------------") + display.v("Unchanged Items:\n%s", yaml.dump(equal_items, default_flow_style=False)) + + from time import sleep ; sleep(10) + + results['interface_all'] = {"updated": updated_items, "removed": removed_items, "equal": equal_items} + return results['interface_all'] + + def load_yaml(self, filename): + """ + Load YAML data from a file. + """ + with open(filename, 'r', encoding='utf-8') as f: + return yaml.safe_load(f) or [] + + def dict_key(self, item): + """ + Return the unique key for an item (e.g., interface name). + """ + if self.new_file_path.endswith('ndfc_interface_all.yml'): + return item.get('name') + elif self.new_file_path.endswith('ndfc_underlay_ip_address.yml'): + return item.get('entity_name') + elif self.new_file_path.endswith('ndfc_attach_vrfs.yml'): + return item.get('vrf_name') + else: + return None + + def compare_items(self, old_items, new_items): + """ + Compare old and new items, returning updated, removed, and equal items. + """ + old_dict = {self.dict_key(item): item for item in old_items} + new_dict = {self.dict_key(item): item for item in new_items} + + updated_items = [] # Updated items in new file + removed_items = [] # Items removed in new file + equal_items = [] # Items unchanged + + for key, new_item in new_dict.items(): + old_item = old_dict.get(key) + if old_item is None: + updated_items.append(new_item) + elif old_item != new_item: + updated_items.append(new_item) + else: + equal_items.append(new_item) + + for key, old_item in old_dict.items(): + if key not in new_dict: + removed_items.append(old_item) + + return updated_items, removed_items, equal_items diff --git a/roles/dtc/common/tasks/common/ndfc_interface_all.yml b/roles/dtc/common/tasks/common/ndfc_interface_all.yml index 078d561bf..260db2a5c 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_all.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_all.yml @@ -80,7 +80,16 @@ mode: preserve delegate_to: localhost -- name: Diff Previous and Current Data Files +- name: Build Interface Diff Between Previous and Current Run + # This task must be run before the next task because + # dtc.diff_model_changes deletes the .old file if it exists + cisco.nac_dc_vxlan.dtc.diff_interface: + old_file: "{{ path_name }}{{ file_name }}.old" + new_file: "{{ path_name }}{{ file_name }}" + register: interface_diff_result + delegate_to: localhost + +- name: Get MD5 Diff For Previous and Current Data Files cisco.nac_dc_vxlan.dtc.diff_model_changes: file_name_previous: "{{ path_name }}{{ file_name }}.old" file_name_current: "{{ path_name }}{{ file_name }}" diff --git a/roles/dtc/common/tasks/sub_main_external.yml b/roles/dtc/common/tasks/sub_main_external.yml index d7e9854ea..d723a31ad 100644 --- a/roles/dtc/common/tasks/sub_main_external.yml +++ b/roles/dtc/common/tasks/sub_main_external.yml @@ -184,6 +184,7 @@ interface_access_po: "{{ interface_access_po }}" interface_access: "{{ interface_access }}" interface_all: "{{ interface_all }}" + interface_diff_result: "{{ interface_diff_result }}" int_loopback_config: "{{ int_loopback_config }}" interface_po_routed: "{{ interface_po_routed }}" interface_routed: "{{ interface_routed }}" diff --git a/roles/dtc/common/tasks/sub_main_isn.yml b/roles/dtc/common/tasks/sub_main_isn.yml index 25e9b64c7..9192ef2e0 100644 --- a/roles/dtc/common/tasks/sub_main_isn.yml +++ b/roles/dtc/common/tasks/sub_main_isn.yml @@ -184,6 +184,7 @@ interface_access_po: "{{ interface_access_po }}" interface_access: "{{ interface_access }}" interface_all: "{{ interface_all }}" + interface_diff_result: "{{ interface_diff_result }}" int_loopback_config: "{{ int_loopback_config }}" interface_po_routed: "{{ interface_po_routed }}" interface_routed: "{{ interface_routed }}" diff --git a/roles/dtc/common/tasks/sub_main_vxlan.yml b/roles/dtc/common/tasks/sub_main_vxlan.yml index 4abf9ae5f..cf4ce2af4 100644 --- a/roles/dtc/common/tasks/sub_main_vxlan.yml +++ b/roles/dtc/common/tasks/sub_main_vxlan.yml @@ -242,6 +242,7 @@ interface_access_po: "{{ interface_access_po }}" interface_access: "{{ interface_access }}" interface_all: "{{ interface_all }}" + interface_diff_result: "{{ interface_diff_result }}" int_loopback_config: "{{ int_loopback_config }}" interface_po_routed: "{{ interface_po_routed }}" interface_routed: "{{ interface_routed }}" diff --git a/roles/dtc/create/tasks/common/interfaces.yml b/roles/dtc/create/tasks/common/interfaces.yml index 08671612d..971c39b42 100644 --- a/roles/dtc/create/tasks/common/interfaces.yml +++ b/roles/dtc/create/tasks/common/interfaces.yml @@ -45,142 +45,142 @@ - "+ Manage Fabric Interfaces {{ MD_Extended.vxlan.fabric.name }}" - "----------------------------------------------------------------" -# ---------------------------------------------------------------------- -# Manage Interface Breakout Configuration in Nexus Dashboard -# ---------------------------------------------------------------------- +# # ---------------------------------------------------------------------- +# # Manage Interface Breakout Configuration in Nexus Dashboard +# # ---------------------------------------------------------------------- -- name: Manage Interface Breakout in Nexus Dashboard - cisco.dcnm.dcnm_interface: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - state: replaced - config: "{{ vars_common_local.interface_breakout }}" - when: MD_Extended.vxlan.topology.interfaces.modes.breakout.count > 0 - -# ---------------------------------------------------------------------- -# Manage Interface Trunk Configuration in Nexus Dashboard -# ---------------------------------------------------------------------- - -- name: Manage Interface Trunk in Nexus Dashboard - cisco.dcnm.dcnm_interface: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - state: replaced - config: "{{ vars_common_local.interface_trunk }}" - when: MD_Extended.vxlan.topology.interfaces.modes.trunk.count > 0 +# - name: Manage Interface Breakout in Nexus Dashboard +# cisco.dcnm.dcnm_interface: +# fabric: "{{ MD_Extended.vxlan.fabric.name }}" +# state: replaced +# config: "{{ vars_common_local.interface_breakout }}" +# when: MD_Extended.vxlan.topology.interfaces.modes.breakout.count > 0 -# ---------------------------------------------------------------------- -# Manage Interface Access Configuration in Nexus Dashboard -# ---------------------------------------------------------------------- +# # ---------------------------------------------------------------------- +# # Manage Interface Trunk Configuration in Nexus Dashboard +# # ---------------------------------------------------------------------- -- name: Manage Interface Access in Nexus Dashboard - cisco.dcnm.dcnm_interface: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - state: replaced - config: "{{ vars_common_local.interface_access }}" - when: MD_Extended.vxlan.topology.interfaces.modes.access.count > 0 +# - name: Manage Interface Trunk in Nexus Dashboard +# cisco.dcnm.dcnm_interface: +# fabric: "{{ MD_Extended.vxlan.fabric.name }}" +# state: replaced +# config: "{{ vars_common_local.interface_trunk }}" +# when: MD_Extended.vxlan.topology.interfaces.modes.trunk.count > 0 -# ---------------------------------------------------------------------- -# Manage Interface Access Port-Channel Configuration in Nexus Dashboard -# ---------------------------------------------------------------------- +# # ---------------------------------------------------------------------- +# # Manage Interface Access Configuration in Nexus Dashboard +# # ---------------------------------------------------------------------- -- name: Manage Access Port-Channel Interface in Nexus Dashboard - cisco.dcnm.dcnm_interface: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - state: replaced - config: "{{ vars_common_local.interface_access_po }}" - when: MD_Extended.vxlan.topology.interfaces.modes.access_po.count > 0 +# - name: Manage Interface Access in Nexus Dashboard +# cisco.dcnm.dcnm_interface: +# fabric: "{{ MD_Extended.vxlan.fabric.name }}" +# state: replaced +# config: "{{ vars_common_local.interface_access }}" +# when: MD_Extended.vxlan.topology.interfaces.modes.access.count > 0 -# ---------------------------------------------------------------------- -# Manage Interface Trunk Port-Channel Configuration in Nexus Dashboard -# ---------------------------------------------------------------------- +# # ---------------------------------------------------------------------- +# # Manage Interface Access Port-Channel Configuration in Nexus Dashboard +# # ---------------------------------------------------------------------- -- name: Manage Trunk Port-Channel Interface in Nexus Dashboard - cisco.dcnm.dcnm_interface: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - state: replaced - config: "{{ vars_common_local.interface_trunk_po }}" - when: MD_Extended.vxlan.topology.interfaces.modes.trunk_po.count > 0 +# - name: Manage Access Port-Channel Interface in Nexus Dashboard +# cisco.dcnm.dcnm_interface: +# fabric: "{{ MD_Extended.vxlan.fabric.name }}" +# state: replaced +# config: "{{ vars_common_local.interface_access_po }}" +# when: MD_Extended.vxlan.topology.interfaces.modes.access_po.count > 0 -# ---------------------------------------------------------------------- -# Manage Interface Routed Configuration in Nexus Dashboard -# ---------------------------------------------------------------------- +# # ---------------------------------------------------------------------- +# # Manage Interface Trunk Port-Channel Configuration in Nexus Dashboard +# # ---------------------------------------------------------------------- -- name: Manage Interface Routed in Nexus Dashboard - cisco.dcnm.dcnm_interface: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - state: replaced - config: "{{ vars_common_local.interface_routed }}" - when: MD_Extended.vxlan.topology.interfaces.modes.routed.count > 0 +# - name: Manage Trunk Port-Channel Interface in Nexus Dashboard +# cisco.dcnm.dcnm_interface: +# fabric: "{{ MD_Extended.vxlan.fabric.name }}" +# state: replaced +# config: "{{ vars_common_local.interface_trunk_po }}" +# when: MD_Extended.vxlan.topology.interfaces.modes.trunk_po.count > 0 -# ---------------------------------------------------------------------- -# Manage Sub-Interface Routed Configuration in Nexus Dashboard -# ---------------------------------------------------------------------- +# # ---------------------------------------------------------------------- +# # Manage Interface Routed Configuration in Nexus Dashboard +# # ---------------------------------------------------------------------- -- name: Manage Sub-Interface Routed in Nexus Dashboard - cisco.dcnm.dcnm_interface: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - state: replaced - config: "{{ vars_common_local.sub_interface_routed }}" - when: MD_Extended.vxlan.topology.interfaces.modes.routed_sub.count > 0 +# - name: Manage Interface Routed in Nexus Dashboard +# cisco.dcnm.dcnm_interface: +# fabric: "{{ MD_Extended.vxlan.fabric.name }}" +# state: replaced +# config: "{{ vars_common_local.interface_routed }}" +# when: MD_Extended.vxlan.topology.interfaces.modes.routed.count > 0 -# ---------------------------------------------------------------------- -# Manage Interface Port-Channel Routed Configuration in Nexus Dashboard -# ---------------------------------------------------------------------- +# # ---------------------------------------------------------------------- +# # Manage Sub-Interface Routed Configuration in Nexus Dashboard +# # ---------------------------------------------------------------------- -- name: Manage Interface Port-Channel Routed in Nexus Dashboard - cisco.dcnm.dcnm_interface: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - state: replaced - config: "{{ vars_common_local.interface_po_routed }}" - when: MD_Extended.vxlan.topology.interfaces.modes.routed_po.count > 0 +# - name: Manage Sub-Interface Routed in Nexus Dashboard +# cisco.dcnm.dcnm_interface: +# fabric: "{{ MD_Extended.vxlan.fabric.name }}" +# state: replaced +# config: "{{ vars_common_local.sub_interface_routed }}" +# when: MD_Extended.vxlan.topology.interfaces.modes.routed_sub.count > 0 -# ---------------------------------------------------------------------- -# Manage Interface Loopback Configuration in Nexus Dashboard -# ---------------------------------------------------------------------- +# # ---------------------------------------------------------------------- +# # Manage Interface Port-Channel Routed Configuration in Nexus Dashboard +# # ---------------------------------------------------------------------- -- name: Manage Interface Loopback in Nexus Dashboard - cisco.dcnm.dcnm_interface: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - state: replaced - config: "{{ vars_common_local.int_loopback_config }}" - when: > - (MD_Extended.vxlan.topology.interfaces.modes.loopback.count > 0) or - (MD_Extended.vxlan.topology.interfaces.modes.fabric_loopback.count > 0) or - (MD_Extended.vxlan.topology.interfaces.modes.mpls_loopback.count > 0) +# - name: Manage Interface Port-Channel Routed in Nexus Dashboard +# cisco.dcnm.dcnm_interface: +# fabric: "{{ MD_Extended.vxlan.fabric.name }}" +# state: replaced +# config: "{{ vars_common_local.interface_po_routed }}" +# when: MD_Extended.vxlan.topology.interfaces.modes.routed_po.count > 0 -# ---------------------------------------------------------------------- -# Manage Interface Dot1q Configuration in Nexus Dashboard -# ---------------------------------------------------------------------- +# # ---------------------------------------------------------------------- +# # Manage Interface Loopback Configuration in Nexus Dashboard +# # ---------------------------------------------------------------------- -- name: Manage Interface Dot1q in Nexus Dashboard - cisco.dcnm.dcnm_interface: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - state: replaced - config: "{{ vars_common_local.interface_dot1q }}" - when: MD_Extended.vxlan.topology.interfaces.modes.dot1q.count > 0 +# - name: Manage Interface Loopback in Nexus Dashboard +# cisco.dcnm.dcnm_interface: +# fabric: "{{ MD_Extended.vxlan.fabric.name }}" +# state: replaced +# config: "{{ vars_common_local.int_loopback_config }}" +# when: > +# (MD_Extended.vxlan.topology.interfaces.modes.loopback.count > 0) or +# (MD_Extended.vxlan.topology.interfaces.modes.fabric_loopback.count > 0) or +# (MD_Extended.vxlan.topology.interfaces.modes.mpls_loopback.count > 0) -# ---------------------------------------------------------------------- -# Manage Interface vPC Configuration in Nexus Dashboard -# ---------------------------------------------------------------------- +# # ---------------------------------------------------------------------- +# # Manage Interface Dot1q Configuration in Nexus Dashboard +# # ---------------------------------------------------------------------- -- name: Manage Interface vPC in Nexus Dashboard - cisco.dcnm.dcnm_interface: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - state: replaced - config: "{{ vars_common_local.interface_vpc }}" - when: MD_Extended.vxlan.topology.interfaces.modes.access_vpc.count > 0 or MD_Extended.vxlan.topology.interfaces.modes.trunk_vpc.count > 0 +# - name: Manage Interface Dot1q in Nexus Dashboard +# cisco.dcnm.dcnm_interface: +# fabric: "{{ MD_Extended.vxlan.fabric.name }}" +# state: replaced +# config: "{{ vars_common_local.interface_dot1q }}" +# when: MD_Extended.vxlan.topology.interfaces.modes.dot1q.count > 0 -## Will discuss with team and switchover to the below code and remove the above code -# # -------------------------------------------------------------------- -# # Manage Interface All Configuration in Nexus Dashboard -# # -------------------------------------------------------------------- +# # ---------------------------------------------------------------------- +# # Manage Interface vPC Configuration in Nexus Dashboard +# # ---------------------------------------------------------------------- -# - name: Manage Interface All in Nexus Dashboard +# - name: Manage Interface vPC in Nexus Dashboard # cisco.dcnm.dcnm_interface: # fabric: "{{ MD_Extended.vxlan.fabric.name }}" # state: replaced -# config: "{{ vars_common_local.interface_all }}" -# vars: -# ansible_command_timeout: 3000 -# ansible_connect_timeout: 3000 -# when: MD_Extended.vxlan.topology.interfaces.modes.all.count > 0 -# delegate_to: localhost +# config: "{{ vars_common_local.interface_vpc }}" +# when: MD_Extended.vxlan.topology.interfaces.modes.access_vpc.count > 0 or MD_Extended.vxlan.topology.interfaces.modes.trunk_vpc.count > 0 + +# Will discuss with team and switchover to the below code and remove the above code +# -------------------------------------------------------------------- +# Manage Interface All Configuration in Nexus Dashboard +# -------------------------------------------------------------------- + +- name: Manage Interface All in Nexus Dashboard + cisco.dcnm.dcnm_interface: + fabric: "{{ MD_Extended.vxlan.fabric.name }}" + state: replaced + # config: "{{ vars_common_local.interface_all }}" + config: "{{ vars_common_local.interface_diff_result.updated }}" + vars: + ansible_command_timeout: 5000 + ansible_connect_timeout: 5000 + when: MD_Extended.vxlan.topology.interfaces.modes.all.count > 0 diff --git a/roles/dtc/remove/tasks/common/interfaces.yml b/roles/dtc/remove/tasks/common/interfaces.yml index e977007f0..80afba978 100644 --- a/roles/dtc/remove/tasks/common/interfaces.yml +++ b/roles/dtc/remove/tasks/common/interfaces.yml @@ -47,8 +47,9 @@ - name: Remove Unmanaged Fabric Interfaces in Nexus Dashboard cisco.dcnm.dcnm_interface: fabric: "{{ MD_Extended.vxlan.fabric.name }}" - state: overridden - config: "{{ vars_common_local.interface_all }}" + state: deleted + # config: "{{ vars_common_local.interface_all }}" + config: "{{ vars_common_local.interface_diff_result.removed }}" # deploy: false vars: ansible_command_timeout: 3000 @@ -56,6 +57,7 @@ register: int_data when: - switch_list.response.DATA | length > 0 + - vars_common_local.interface_diff_result.removed | length > 0 - (interface_delete_mode is defined) and (interface_delete_mode is true|bool) # - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} after removing or defaulting interfaces diff --git a/roles/validate/tasks/cleanup_model_files.yml b/roles/validate/tasks/cleanup_model_files.yml new file mode 100644 index 000000000..3e40d43c7 --- /dev/null +++ b/roles/validate/tasks/cleanup_model_files.yml @@ -0,0 +1,40 @@ +# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +# the Software, and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# SPDX-License-Identifier: MIT + +--- + +- debug: msg="{{ MD_Extended.vxlan.fabric.name }}_service_model*.json" + +- name: Remove Service Model JSON Files + ansible.builtin.find: + paths: "{{ role_path }}/files/" + patterns: "{{ MD_Extended.vxlan.fabric.name }}_service_model*.json" + file_type: file + recurse: false + register: files_to_delete + delegate_to: localhost + +- name: Delete the found files + ansible.builtin.file: + path: "{{ item.path }}" + state: absent + loop: "{{ files_to_delete.files }}" + delegate_to: localhost \ No newline at end of file diff --git a/roles/validate/tasks/manage_model_files_current.yml b/roles/validate/tasks/manage_model_files_current.yml index 38af3dca6..509f98425 100644 --- a/roles/validate/tasks/manage_model_files_current.yml +++ b/roles/validate/tasks/manage_model_files_current.yml @@ -50,5 +50,35 @@ ansible.utils.fact_diff: before: "{{ smd_golden_previous }}" after: "{{ smd_golden_current }}" + register: smd_golden_diff when: check_roles['save_previous'] delegate_to: localhost + +- name: Mark All Stages Completed When No Model Changes Detected + cisco.nac_dc_vxlan.common.run_map: + model_data: "{{ MD_Extended }}" + stage: role_all_completed + when: + - check_roles['save_previous'] + - smd_golden_diff.diff_lines | length == 0 + - smd_golden_diff.diff_text | length == 0 + - ((force_run_all is defined) and (force_run_all is false|bool)) + delegate_to: localhost + +- name: No Model Changes Detected + ansible.builtin.meta: end_play + when: + - check_roles['save_previous'] + - smd_golden_diff.diff_lines | length == 0 + - smd_golden_diff.diff_text | length == 0 + - ((force_run_all is defined) and (force_run_all is false|bool)) + delegate_to: localhost + +# ------------------------------------------------------------------------ +# Remove all files from the previous run if force_run_all is true +# ------------------------------------------------------------------------ +- name: Cleanup Files from Previous Run if run_map requires it + ansible.builtin.import_tasks: cleanup_model_files.yml + when: + - ((force_run_all is defined) and (force_run_all is true|bool)) + delegate_to: localhost \ No newline at end of file From 89fb871c57a17089acb37e68e185a90c41626a10 Mon Sep 17 00:00:00 2001 From: ccoueffe Date: Tue, 23 Sep 2025 10:02:22 +0100 Subject: [PATCH 02/65] update diff script for interfaces, underlay, vrfs, networks, vpc_peering and vpc_domain_id Signed-off-by: ccoueffe --- plugins/action/dtc/diff_interface.py | 67 ++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 14 deletions(-) diff --git a/plugins/action/dtc/diff_interface.py b/plugins/action/dtc/diff_interface.py index 3374c4e1c..5dbc1f7dc 100644 --- a/plugins/action/dtc/diff_interface.py +++ b/plugins/action/dtc/diff_interface.py @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates +# Copyright (c) 2025 Cisco Systems, Inc. and its affiliates # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -24,10 +24,10 @@ import yaml from ansible.utils.display import Display from ansible.plugins.action import ActionBase -import logging display = Display() + class ActionModule(ActionBase): """ Action plugin to compare existing links with new links for a fabric. @@ -64,7 +64,8 @@ def run(self, tmp=None, task_vars=None): display.v("---------------------------------") display.v("Unchanged Items:\n%s", yaml.dump(equal_items, default_flow_style=False)) - from time import sleep ; sleep(10) + from time import sleep; + sleep(10) results['interface_all'] = {"updated": updated_items, "removed": removed_items, "equal": equal_items} return results['interface_all'] @@ -76,19 +77,57 @@ def load_yaml(self, filename): with open(filename, 'r', encoding='utf-8') as f: return yaml.safe_load(f) or [] + KEY_MAPPING = { + 'ndfc_interface_all.yml': 'name', + 'ndfc_underlay_ip_address.yml': 'entity_name', + 'ndfc_attach_vrfs.yml': 'vrf_name', + 'ndfc_attach_networks.yml': 'net_name', + 'ndfc_vpc_domain_id_resource.yml': 'entity_name', + 'ndfc_vpc_peering.yml': 'peerOneId' +} + + def _create_fabric_link_key(self, item): + """ + Create a unique key for fabric links from multiple attributes. + + Args: + item (dict): The fabric link item containing link details + + Returns: + str: A unique key for the fabric link or None if required fields are missing + """ + required_fields = ['dst_fabric', 'src_device', 'src_interface', 'dst_interface'] + if not all(item.get(field) for field in required_fields): + return None + + return '_'.join([item.get(field) for field in required_fields]) + def dict_key(self, item): """ - Return the unique key for an item (e.g., interface name). + Return the unique key for an item based on its type. + + Args: + item (dict): The item to generate a key for + + Returns: + str: The unique key for the item, or None if no key could be generated """ - if self.new_file_path.endswith('ndfc_interface_all.yml'): - return item.get('name') - elif self.new_file_path.endswith('ndfc_underlay_ip_address.yml'): - return item.get('entity_name') - elif self.new_file_path.endswith('ndfc_attach_vrfs.yml'): - return item.get('vrf_name') - else: + if not isinstance(item, dict): return None + filename = self._task['new_file'] + + # Handle fabric links specially due to composite key + if filename.endswith('ndfc_fabric_links.yml'): + return self._create_fabric_link_key(item) + + # Find matching file type and return corresponding key + for file_type, key_attr in self.KEY_MAPPING.items(): + if filename.endswith(file_type): + return item.get(key_attr) + + return None + def compare_items(self, old_items, new_items): """ Compare old and new items, returning updated, removed, and equal items. @@ -96,9 +135,9 @@ def compare_items(self, old_items, new_items): old_dict = {self.dict_key(item): item for item in old_items} new_dict = {self.dict_key(item): item for item in new_items} - updated_items = [] # Updated items in new file - removed_items = [] # Items removed in new file - equal_items = [] # Items unchanged + updated_items = [] # Updated items in new file + removed_items = [] # Items removed in new file + equal_items = [] # Items unchanged for key, new_item in new_dict.items(): old_item = old_dict.get(key) From a40844acf76da4dcb14c0f37b4dc2a6d1617a8a0 Mon Sep 17 00:00:00 2001 From: ccoueffe Date: Tue, 23 Sep 2025 10:11:11 +0100 Subject: [PATCH 03/65] rename diff_interface to diff_compare + fix sanity Signed-off-by: ccoueffe --- .../{diff_interface.py => diff_compare.py} | 2 +- .../tasks/common/ndfc_interface_all.yml | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) rename plugins/action/dtc/{diff_interface.py => diff_compare.py} (99%) diff --git a/plugins/action/dtc/diff_interface.py b/plugins/action/dtc/diff_compare.py similarity index 99% rename from plugins/action/dtc/diff_interface.py rename to plugins/action/dtc/diff_compare.py index 5dbc1f7dc..137114cc6 100644 --- a/plugins/action/dtc/diff_interface.py +++ b/plugins/action/dtc/diff_compare.py @@ -64,7 +64,7 @@ def run(self, tmp=None, task_vars=None): display.v("---------------------------------") display.v("Unchanged Items:\n%s", yaml.dump(equal_items, default_flow_style=False)) - from time import sleep; + from time import sleep sleep(10) results['interface_all'] = {"updated": updated_items, "removed": removed_items, "equal": equal_items} diff --git a/roles/dtc/common/tasks/common/ndfc_interface_all.yml b/roles/dtc/common/tasks/common/ndfc_interface_all.yml index 260db2a5c..78ee3babc 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_all.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_all.yml @@ -56,6 +56,23 @@ interface_all: [] delegate_to: localhost + +- name: Debug All Interface Variables + ansible.builtin.debug: + msg: | + Interface Types: + Breakout: {{ interface_breakout | default([]) }} + Access: {{ interface_access | default([]) }} + Access Port-Channel: {{ interface_access_po | default([]) }} + Trunk: {{ interface_trunk | default([]) }} + Trunk Port-Channel: {{ interface_trunk_po | default([]) }} + Routed: {{ interface_routed | default([]) }} + Port-Channel Routed: {{ interface_po_routed | default([]) }} + Sub-Interface Routed: {{ sub_interface_routed | default([]) }} + VPC: {{ interface_vpc | default([]) }} + Loopback: {{ int_loopback_config | default([]) }} + Dot1Q: {{ interface_dot1q | default([]) }} + - name: Set interface_all Var ansible.builtin.set_fact: interface_all: "{{ @@ -83,7 +100,7 @@ - name: Build Interface Diff Between Previous and Current Run # This task must be run before the next task because # dtc.diff_model_changes deletes the .old file if it exists - cisco.nac_dc_vxlan.dtc.diff_interface: + cisco.nac_dc_vxlan.dtc.diff_compare: old_file: "{{ path_name }}{{ file_name }}.old" new_file: "{{ path_name }}{{ file_name }}" register: interface_diff_result From a44598a5cc227a21e5679d2eaf44db052bfc3aad Mon Sep 17 00:00:00 2001 From: ccoueffe Date: Tue, 23 Sep 2025 10:16:32 +0100 Subject: [PATCH 04/65] fix pep8 Signed-off-by: ccoueffe --- plugins/action/dtc/diff_compare.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/action/dtc/diff_compare.py b/plugins/action/dtc/diff_compare.py index 137114cc6..eac70402d 100644 --- a/plugins/action/dtc/diff_compare.py +++ b/plugins/action/dtc/diff_compare.py @@ -78,13 +78,13 @@ def load_yaml(self, filename): return yaml.safe_load(f) or [] KEY_MAPPING = { - 'ndfc_interface_all.yml': 'name', - 'ndfc_underlay_ip_address.yml': 'entity_name', - 'ndfc_attach_vrfs.yml': 'vrf_name', - 'ndfc_attach_networks.yml': 'net_name', - 'ndfc_vpc_domain_id_resource.yml': 'entity_name', - 'ndfc_vpc_peering.yml': 'peerOneId' -} + 'ndfc_interface_all.yml': 'name', + 'ndfc_underlay_ip_address.yml': 'entity_name', + 'ndfc_attach_vrfs.yml': 'vrf_name', + 'ndfc_attach_networks.yml': 'net_name', + 'ndfc_vpc_domain_id_resource.yml': 'entity_name', + 'ndfc_vpc_peering.yml': 'peerOneId' + } def _create_fabric_link_key(self, item): """ From f18ef9f14b8302c0c32c17e6825aeac95615bd65 Mon Sep 17 00:00:00 2001 From: ccoueffe Date: Tue, 23 Sep 2025 10:27:48 +0100 Subject: [PATCH 05/65] update sanity Signed-off-by: ccoueffe --- .../tasks/common/ndfc_interface_all.yml | 27 ++++++++++--------- tests/sanity/ignore-2.14.txt | 1 + tests/sanity/ignore-2.15.txt | 1 + tests/sanity/ignore-2.16.txt | 1 + tests/sanity/ignore-2.17.txt | 1 + 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/roles/dtc/common/tasks/common/ndfc_interface_all.yml b/roles/dtc/common/tasks/common/ndfc_interface_all.yml index 78ee3babc..a6bf32458 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_all.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_all.yml @@ -59,19 +59,20 @@ - name: Debug All Interface Variables ansible.builtin.debug: - msg: | - Interface Types: - Breakout: {{ interface_breakout | default([]) }} - Access: {{ interface_access | default([]) }} - Access Port-Channel: {{ interface_access_po | default([]) }} - Trunk: {{ interface_trunk | default([]) }} - Trunk Port-Channel: {{ interface_trunk_po | default([]) }} - Routed: {{ interface_routed | default([]) }} - Port-Channel Routed: {{ interface_po_routed | default([]) }} - Sub-Interface Routed: {{ sub_interface_routed | default([]) }} - VPC: {{ interface_vpc | default([]) }} - Loopback: {{ int_loopback_config | default([]) }} - Dot1Q: {{ interface_dot1q | default([]) }} + msg: + - "----------------------------------------------------------------" + - "Interface Types:" + - " Breakout: {{ interface_breakout | default([]) }}" + - " Access: {{ interface_access | default([]) }}" + - " Access Port-Channel: {{ interface_access_po | default([]) }}" + - " Trunk: {{ interface_trunk | default([]) }}" + - " Trunk Port-Channel: {{ interface_trunk_po | default([]) }}" + - " Routed: {{ interface_routed | default([]) }}" + - " Port-Channel Routed: {{ interface_po_routed | default([]) }}" + - " Sub-Interface Routed: {{ sub_interface_routed | default([]) }}" + - " VPC: {{ interface_vpc | default([]) }}" + - " Loopback: {{ int_loopback_config | default([]) }}" + - " Dot1Q: {{ interface_dot1q | default([]) }}" - name: Set interface_all Var ansible.builtin.set_fact: diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index a35fe069a..0ff9746ad 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -44,3 +44,4 @@ plugins/action/common/run_map.py import-3.10!skip plugins/action/common/read_run_map.py import-3.10!skip plugins/action/dtc/diff_model_changes.py import-3.10!skip plugins/filter/version_compare.py import-3.10!skip +plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index a35fe069a..2e4740fd8 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -44,3 +44,4 @@ plugins/action/common/run_map.py import-3.10!skip plugins/action/common/read_run_map.py import-3.10!skip plugins/action/dtc/diff_model_changes.py import-3.10!skip plugins/filter/version_compare.py import-3.10!skip +plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation \ No newline at end of file diff --git a/tests/sanity/ignore-2.16.txt b/tests/sanity/ignore-2.16.txt index a35fe069a..2e4740fd8 100644 --- a/tests/sanity/ignore-2.16.txt +++ b/tests/sanity/ignore-2.16.txt @@ -44,3 +44,4 @@ plugins/action/common/run_map.py import-3.10!skip plugins/action/common/read_run_map.py import-3.10!skip plugins/action/dtc/diff_model_changes.py import-3.10!skip plugins/filter/version_compare.py import-3.10!skip +plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation \ No newline at end of file diff --git a/tests/sanity/ignore-2.17.txt b/tests/sanity/ignore-2.17.txt index a35fe069a..2e4740fd8 100644 --- a/tests/sanity/ignore-2.17.txt +++ b/tests/sanity/ignore-2.17.txt @@ -44,3 +44,4 @@ plugins/action/common/run_map.py import-3.10!skip plugins/action/common/read_run_map.py import-3.10!skip plugins/action/dtc/diff_model_changes.py import-3.10!skip plugins/filter/version_compare.py import-3.10!skip +plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation \ No newline at end of file From 8bad04b879d0be926d9539f0a739889b18100a07 Mon Sep 17 00:00:00 2001 From: ccoueffe Date: Tue, 23 Sep 2025 11:21:37 +0100 Subject: [PATCH 06/65] update diff_compare Signed-off-by: ccoueffe --- plugins/action/dtc/diff_compare.py | 36 +++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/plugins/action/dtc/diff_compare.py b/plugins/action/dtc/diff_compare.py index eac70402d..129633c68 100644 --- a/plugins/action/dtc/diff_compare.py +++ b/plugins/action/dtc/diff_compare.py @@ -33,15 +33,38 @@ class ActionModule(ActionBase): Action plugin to compare existing links with new links for a fabric. Identifies new/modified, removed, and unchanged items. """ + def __init__(self, *args, **kwargs): + super(ActionModule, self).__init__(*args, **kwargs) + self.old_file_path = None + self.new_file_path = None + def run(self, tmp=None, task_vars=None): """ Run the action plugin. + + Args: + tmp: Temporary directory for file operations + task_vars: Variables available to the task + + Returns: + dict: Results containing the comparison of items """ + if task_vars is None: + task_vars = {} + results = super(ActionModule, self).run(tmp, task_vars) - results['interface_all'] = {} + results['compare'] = {} + + # Validate required arguments + try: + self.old_file_path = self._task.args.get('old_file') + self.new_file_path = self._task.args.get('new_file') - self.old_file_path = self._task.args['old_file'] - self.new_file_path = self._task.args['new_file'] + if not self.old_file_path or not self.new_file_path: + raise ValueError("Both old_file and new_file arguments are required") + + except (AttributeError, KeyError) as e: + return {'failed': True, 'msg': f'Missing required argument: {str(e)}'} old_items = [] new_items = [] @@ -67,8 +90,8 @@ def run(self, tmp=None, task_vars=None): from time import sleep sleep(10) - results['interface_all'] = {"updated": updated_items, "removed": removed_items, "equal": equal_items} - return results['interface_all'] + results['compare'] = {"updated": updated_items, "removed": removed_items, "equal": equal_items} + return results['compare'] def load_yaml(self, filename): """ @@ -115,7 +138,7 @@ def dict_key(self, item): if not isinstance(item, dict): return None - filename = self._task['new_file'] + filename = self.new_file_path # Handle fabric links specially due to composite key if filename.endswith('ndfc_fabric_links.yml'): @@ -132,6 +155,7 @@ def compare_items(self, old_items, new_items): """ Compare old and new items, returning updated, removed, and equal items. """ + old_dict = {self.dict_key(item): item for item in old_items} new_dict = {self.dict_key(item): item for item in new_items} From 7b2427cdb498597369890ccef0ca5e6afaa8619a Mon Sep 17 00:00:00 2001 From: ccoueffe Date: Tue, 23 Sep 2025 11:31:53 +0100 Subject: [PATCH 07/65] update underlay_ip_address for diff Signed-off-by: ccoueffe --- .../tasks/common/ndfc_underlay_ip_address.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml b/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml index 278a1cd44..04e45085b 100644 --- a/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml +++ b/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml @@ -62,7 +62,7 @@ underlay_ip_address: [] delegate_to: localhost -- name: Set inv_config Var +- name: Set underlay_ip_address Var ansible.builtin.set_fact: underlay_ip_address: "{{ lookup('file', path_name + file_name) | from_yaml }}" when: @@ -71,7 +71,16 @@ - vxlan.underlay.general.manual_underlay_allocation delegate_to: localhost -- name: Diff Previous and Current Data Files +- name: Build underlay_ip_address Diff Between Previous and Current Run + # This task must be run before the next task because + # dtc.diff_model_changes deletes the .old file if it exists + cisco.nac_dc_vxlan.dtc.diff_compare: + old_file: "{{ path_name }}{{ file_name }}.old" + new_file: "{{ path_name }}{{ file_name }}" + register: underlay_ip_address_diff_result + delegate_to: localhost + +- name: Get MD5 Diff For Previous and Current Data Files cisco.nac_dc_vxlan.dtc.diff_model_changes: file_name_previous: "{{ path_name }}{{ file_name }}.old" file_name_current: "{{ path_name }}{{ file_name }}" From 962d2f527e8fdea1acf01975da76af5a5a116bcf Mon Sep 17 00:00:00 2001 From: ccoueffe Date: Tue, 23 Sep 2025 18:14:16 +0100 Subject: [PATCH 08/65] update in create role underlay_ip, vpc_domain_id, vpc_peering + update condition in deploy Signed-off-by: ccoueffe --- plugins/action/dtc/diff_compare.py | 3 --- .../common/ndfc_vpc_domain_id_resource.yml | 11 +++++++++- .../tasks/common/ndfc_vpc_peering_pairs.yml | 11 +++++++++- roles/dtc/common/tasks/sub_main_vxlan.yml | 3 +++ .../create/tasks/common/devices_discovery.yml | 3 ++- roles/dtc/create/tasks/common/vpc_peering.yml | 22 +++++++++++++++---- roles/dtc/create/tasks/main.yml | 3 ++- roles/dtc/create/tasks/sub_main_vxlan.yml | 2 +- roles/dtc/deploy/tasks/main.yml | 3 ++- 9 files changed, 48 insertions(+), 13 deletions(-) diff --git a/plugins/action/dtc/diff_compare.py b/plugins/action/dtc/diff_compare.py index 129633c68..593f2deec 100644 --- a/plugins/action/dtc/diff_compare.py +++ b/plugins/action/dtc/diff_compare.py @@ -87,9 +87,6 @@ def run(self, tmp=None, task_vars=None): display.v("---------------------------------") display.v("Unchanged Items:\n%s", yaml.dump(equal_items, default_flow_style=False)) - from time import sleep - sleep(10) - results['compare'] = {"updated": updated_items, "removed": removed_items, "equal": equal_items} return results['compare'] diff --git a/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml b/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml index 44d857bb1..a5c4a397a 100644 --- a/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml +++ b/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml @@ -69,7 +69,16 @@ when: MD_Extended.vxlan.topology.vpc_peers | length > 0 delegate_to: localhost -- name: Diff Previous and Current Data Files +- name: Build vPC Domain ID Diff Between Previous and Current Run + # This task must be run before the next task because + # dtc.diff_model_changes deletes the .old file if it exists + cisco.nac_dc_vxlan.dtc.diff_compare: + old_file: "{{ path_name }}{{ file_name }}.old" + new_file: "{{ path_name }}{{ file_name }}" + register: vpc_domain_id_resource_diff_result + delegate_to: localhost + +- name: Get MD5 Diff Previous and Current Data Files cisco.nac_dc_vxlan.dtc.diff_model_changes: file_name_previous: "{{ path_name }}{{ file_name }}.old" file_name_current: "{{ path_name }}{{ file_name }}" diff --git a/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml b/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml index 8d0f479f2..068b6bf5e 100644 --- a/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml +++ b/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml @@ -69,7 +69,16 @@ when: MD_Extended.vxlan.topology.vpc_peers | length > 0 delegate_to: localhost -- name: Diff Previous and Current Data Files +- name: Build vPC Peering Diff Between Previous and Current Run + # This task must be run before the next task because + # dtc.diff_model_changes deletes the .old file if it exists + cisco.nac_dc_vxlan.dtc.diff_compare: + old_file: "{{ path_name }}{{ file_name }}.old" + new_file: "{{ path_name }}{{ file_name }}" + register: vpc_peering_diff_result + delegate_to: localhost + +- name: Get MD5 Diff Previous and Current Data Files cisco.nac_dc_vxlan.dtc.diff_model_changes: file_name_previous: "{{ path_name }}{{ file_name }}.old" file_name_current: "{{ path_name }}{{ file_name }}" diff --git a/roles/dtc/common/tasks/sub_main_vxlan.yml b/roles/dtc/common/tasks/sub_main_vxlan.yml index 99c013eb7..01a76bbe5 100644 --- a/roles/dtc/common/tasks/sub_main_vxlan.yml +++ b/roles/dtc/common/tasks/sub_main_vxlan.yml @@ -268,10 +268,13 @@ updated_inv_config: "{{ updated_inv_config }}" updated_inv_config_no_bootstrap: "{{ updated_inv_config_no_bootstrap }}" vpc_peering: "{{ vpc_peering }}" + vpc_peering_diff_result: "{{ vpc_peering_diff_result }}" vpc_domain_id_resource: "{{ vpc_domain_id_resource }}" + vpc_domain_id_resource_diff_result: "{{ vpc_domain_id_resource_diff_result }}" vrf_config: "{{ vrf_config }}" vrf_attach_config: "{{ vrf_attach_config }}" underlay_ip_address: "{{ underlay_ip_address }}" + underlay_ip_address_diff_result: "{{ underlay_ip_address_diff_result }}" - name: Run Diff Flags ansible.builtin.debug: diff --git a/roles/dtc/create/tasks/common/devices_discovery.yml b/roles/dtc/create/tasks/common/devices_discovery.yml index 14b6de95c..c46301ae0 100644 --- a/roles/dtc/create/tasks/common/devices_discovery.yml +++ b/roles/dtc/create/tasks/common/devices_discovery.yml @@ -60,7 +60,8 @@ cisco.dcnm.dcnm_resource_manager: state: merged fabric: "{{ MD_Extended.vxlan.fabric.name }}" - config: "{{ vars_common_vxlan.underlay_ip_address }}" + # config: "{{ vars_common_vxlan.underlay_ip_address }}" + config: "{{ vars_common_vxlan.underlay_ip_address_diff_result.updated }}" when: - MD_Extended.vxlan.underlay.general.manual_underlay_allocation is defined - MD_Extended.vxlan.underlay.general.manual_underlay_allocation diff --git a/roles/dtc/create/tasks/common/vpc_peering.yml b/roles/dtc/create/tasks/common/vpc_peering.yml index 57465bbc9..303e2dbdf 100644 --- a/roles/dtc/create/tasks/common/vpc_peering.yml +++ b/roles/dtc/create/tasks/common/vpc_peering.yml @@ -53,14 +53,20 @@ # Manage vPC Domain ID # -------------------------------------------------------------------- +- name: Debug Domain ID + ansible.builtin.debug: + msg: + - "{{ vars_common_vxlan.vpc_domain_id_resource_diff_result }}" + - name: Manage vPC Domain ID Resource in Nexus Dashboard cisco.dcnm.dcnm_resource_manager: state: merged fabric: "{{ MD_Extended.vxlan.fabric.name }}" - config: "{{ vars_common_vxlan.vpc_domain_id_resource }}" + # config: "{{ vars_common_vxlan.vpc_domain_id_resource }}" + config: "{{ vars_common_vxlan.vpc_domain_id_resource_diff_result.updated }}" when: - - vars_common_vxlan.vpc_domain_id_resource is defined - - vars_common_vxlan.vpc_domain_id_resource | length > 0 + - vars_common_vxlan.vpc_domain_id_resource_diff_result is defined + - vars_common_vxlan.vpc_domain_id_resource_diff_result.updated | length > 0 # -------------------------------------------------------------------- # Manage Intra Fabric Links for vPC Peering in Nexus Dashboard @@ -80,9 +86,17 @@ # Manage vPC Peering in Nexus Dashboard # -------------------------------------------------------------------- +- name: Debug vPC Peering + ansible.builtin.debug: + msg: + # - "{{ vars_common_vxlan }}" + - "{{ vars_common_local.vpc_peering_diff_result }}" + - name: Manage vPC Peering in Nexus Dashboard cisco.dcnm.dcnm_vpc_pair: src_fabric: "{{ MD_Extended.vxlan.fabric.name }}" deploy: false state: replaced - config: "{{ vars_common_local.vpc_peering }}" + # config: "{{ vars_common_local.vpc_peering }}" + config: "{{ vars_common_local.vpc_peering_diff_result.updated }}" + when: vars_common_local.vpc_peering_diff_result is defined and vars_common_local.vpc_peering_diff_result.updated | length > 0 diff --git a/roles/dtc/create/tasks/main.yml b/roles/dtc/create/tasks/main.yml index 0afdf633d..af55fdef4 100644 --- a/roles/dtc/create/tasks/main.yml +++ b/roles/dtc/create/tasks/main.yml @@ -35,7 +35,8 @@ (vars_common_vxlan.changes_detected_policy) or (vars_common_vxlan.changes_detected_edge_connections) or (vars_common_vxlan.changes_detected_fabric_links) or - (vars_common_vxlan.changes_detected_underlay_ip_address) + (vars_common_vxlan.changes_detected_underlay_ip_address) or + (vars_common_vxlan.changes_detected_vpc_domain_id_resource) - name: Import eBGP VXLAN Fabric Role Tasks ansible.builtin.import_tasks: sub_main_ebgp_vxlan.yml diff --git a/roles/dtc/create/tasks/sub_main_vxlan.yml b/roles/dtc/create/tasks/sub_main_vxlan.yml index 9f8d7ef24..c924a0490 100644 --- a/roles/dtc/create/tasks/sub_main_vxlan.yml +++ b/roles/dtc/create/tasks/sub_main_vxlan.yml @@ -54,7 +54,7 @@ ansible.builtin.import_tasks: common/vpc_peering.yml when: - MD_Extended.vxlan.topology.vpc_peers | length > 0 - - vars_common_vxlan.changes_detected_vpc_peering + - vars_common_vxlan.changes_detected_vpc_peering or vars_common_vxlan.changes_detected_vpc_domain_id_resource tags: "{{ nac_tags.create_vpc_peers }}" - name: Config-Save Block to Propagate vPC Changes to iBGP VXLAN Fabric in Nexus Dashboard diff --git a/roles/dtc/deploy/tasks/main.yml b/roles/dtc/deploy/tasks/main.yml index 3aea0c55c..25900c8ed 100644 --- a/roles/dtc/deploy/tasks/main.yml +++ b/roles/dtc/deploy/tasks/main.yml @@ -45,7 +45,8 @@ vars_common_vxlan.changes_detected_vpc_peering or vars_common_vxlan.changes_detected_vrfs or vars_common_vxlan.changes_detected_edge_connections or - vars_common_vxlan.changes_detected_underlay_ip_address) + vars_common_vxlan.changes_detected_underlay_ip_address or + vars_common_vxlan.changes_detected_vpc_domain_id_resource) - name: Import MSD Fabric Role Tasks ansible.builtin.import_tasks: sub_main_msd.yml From a5088bf1c1763c362b26396953d15199f4fb4b8d Mon Sep 17 00:00:00 2001 From: mwiebe Date: Tue, 23 Sep 2025 22:20:31 -0400 Subject: [PATCH 09/65] Fix interface diff bug and preserve backward compatability --- plugins/action/dtc/diff_compare.py | 32 +++++++++++++++++-- .../tasks/common/ndfc_interface_all.yml | 19 ++++++++--- roles/dtc/create/tasks/common/interfaces.yml | 20 ++++++++++-- roles/dtc/remove/tasks/common/interfaces.yml | 25 +++++++++++++-- roles/dtc/remove/tasks/sub_main_vxlan.yml | 32 +++++++++---------- .../tasks/manage_model_files_current.yml | 8 +++-- 6 files changed, 108 insertions(+), 28 deletions(-) diff --git a/plugins/action/dtc/diff_compare.py b/plugins/action/dtc/diff_compare.py index 593f2deec..d28c20a65 100644 --- a/plugins/action/dtc/diff_compare.py +++ b/plugins/action/dtc/diff_compare.py @@ -98,7 +98,6 @@ def load_yaml(self, filename): return yaml.safe_load(f) or [] KEY_MAPPING = { - 'ndfc_interface_all.yml': 'name', 'ndfc_underlay_ip_address.yml': 'entity_name', 'ndfc_attach_vrfs.yml': 'vrf_name', 'ndfc_attach_networks.yml': 'net_name', @@ -122,6 +121,31 @@ def _create_fabric_link_key(self, item): return '_'.join([item.get(field) for field in required_fields]) + def _create_interface_key(self, item): + """ + Create a unique key for interfaces from multiple attributes. + + Args: + item (dict): The interface item containing interface details + + Returns: + str: A unique key for the interface per switch or None if required fields are missing + """ + required_fields = ['name', 'switch'] + if not all(item.get(field) for field in required_fields): + return None + + switch_value = item.get('switch') + # Handle both string and list types for switch field + if isinstance(switch_value, list): + if not switch_value: # Empty list check + return None + switch_id = switch_value[0] + else: + switch_id = switch_value + + return f"{item.get('name')}_{switch_id}" + def dict_key(self, item): """ Return the unique key for an item based on its type. @@ -137,10 +161,14 @@ def dict_key(self, item): filename = self.new_file_path - # Handle fabric links specially due to composite key + # Special handling for fabric links due to composite key if filename.endswith('ndfc_fabric_links.yml'): return self._create_fabric_link_key(item) + # Special handling for interfaces due to composite key + if filename.endswith('ndfc_interface_all.yml'): + return self._create_interface_key(item) + # Find matching file type and return corresponding key for file_type, key_attr in self.KEY_MAPPING.items(): if filename.endswith(file_type): diff --git a/roles/dtc/common/tasks/common/ndfc_interface_all.yml b/roles/dtc/common/tasks/common/ndfc_interface_all.yml index 212d33c8b..80d612438 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_all.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_all.yml @@ -79,16 +79,16 @@ interface_all: "{{ interface_breakout + interface_breakout_preprov + + interface_trunk + interface_access + interface_access_po + - interface_trunk + interface_trunk_po + interface_routed + - interface_po_routed + sub_interface_routed + - interface_vpc + + interface_po_routed + int_loopback_config + - interface_dot1q }}" + interface_dot1q + + interface_vpc }}" when: > MD_Extended.vxlan.topology.interfaces.modes.breakout.count > 0 or MD_Extended.vxlan.topology.interfaces.modes.breakout_preprov.count > 0 or @@ -111,6 +111,17 @@ register: interface_diff_result delegate_to: localhost +- debug: msg="EQUAL {{ interface_diff_result['equal'] }}" +- debug: msg="REMOVED {{ interface_diff_result['removed'] }}" +- debug: msg="UPDATED {{ interface_diff_result['updated'] }}" +- debug: msg="EQUAL {{ interface_diff_result['equal'] | length }}" +- debug: msg="REMOVED {{ interface_diff_result['removed'] | length }}" +- debug: msg="UPDATED {{ interface_diff_result['updated'] | length }}" +- name: Sleep for 10 seconds + ansible.builtin.pause: + seconds: 10 + delegate_to: localhost + - name: Get MD5 Diff For Previous and Current Data Files cisco.nac_dc_vxlan.dtc.diff_model_changes: file_name_previous: "{{ path_name }}{{ file_name }}.old" diff --git a/roles/dtc/create/tasks/common/interfaces.yml b/roles/dtc/create/tasks/common/interfaces.yml index 6b61ab1cf..00d6e0145 100644 --- a/roles/dtc/create/tasks/common/interfaces.yml +++ b/roles/dtc/create/tasks/common/interfaces.yml @@ -178,12 +178,28 @@ # Manage Interface All Configuration in Nexus Dashboard # -------------------------------------------------------------------- +- name: Initialize Interface Config List to All Interfaces + set_fact: + interface_config_list: "{{ vars_common_local.interface_all }}" + +- name: Override Interface Config List Based On Diff Run Settings + set_fact: + interface_config_list: "{{ vars_common_local.interface_diff_result.updated }}" + when: + - run_map_read_result.diff_run is true|bool + +- debug: msg="{{ run_map_read_result }}" +- debug: msg="{{ interface_config_list }}" + +- name: Sleep for 10 seconds + ansible.builtin.pause: + seconds: 10 + - name: Manage Interface All in Nexus Dashboard cisco.dcnm.dcnm_interface: fabric: "{{ MD_Extended.vxlan.fabric.name }}" state: replaced - # config: "{{ vars_common_local.interface_all }}" - config: "{{ vars_common_local.interface_diff_result.updated }}" + config: "{{ interface_config_list }}" vars: ansible_command_timeout: 5000 ansible_connect_timeout: 5000 diff --git a/roles/dtc/remove/tasks/common/interfaces.yml b/roles/dtc/remove/tasks/common/interfaces.yml index 00f3564d4..5f9f3c519 100644 --- a/roles/dtc/remove/tasks/common/interfaces.yml +++ b/roles/dtc/remove/tasks/common/interfaces.yml @@ -46,11 +46,10 @@ - switch_list.response.DATA | length > 0 - (interface_delete_mode is defined) and (interface_delete_mode is true|bool) -- name: Remove Unmanaged Fabric Interfaces in Nexus Dashboard +- name: Remove Unmanaged Fabric Interfaces in Nexus Dashboard - Diff Run True cisco.dcnm.dcnm_interface: fabric: "{{ MD_Extended.vxlan.fabric.name }}" state: deleted - # config: "{{ vars_common_local.interface_all }}" config: "{{ vars_common_local.interface_diff_result.removed }}" # deploy: false vars: @@ -61,6 +60,28 @@ - switch_list.response.DATA | length > 0 - vars_common_local.interface_diff_result.removed | length > 0 - (interface_delete_mode is defined) and (interface_delete_mode is true|bool) + - run_map_read_result.diff_run is true|bool + - force_run_all is false|bool + +- name: Remove Unmanaged Fabric Interfaces in Nexus Dashboard - Diff Run False + cisco.dcnm.dcnm_interface: + fabric: "{{ MD_Extended.vxlan.fabric.name }}" + state: overridden + config: "{{ vars_common_local.interface_all }}" + # deploy: false + vars: + ansible_command_timeout: 3000 + ansible_connect_timeout: 3000 + register: int_data + when: + - switch_list.response.DATA | length > 0 + - (interface_delete_mode is defined) and (interface_delete_mode is true|bool) + - run_map_read_result.diff_run is false|bool or force_run_all is true|bool + +- debug: msg="{{ vars_common_local.interface_all | length }}" +- debug: msg="{{ interface_delete_mode }}" +- debug: msg="{{ run_map_read_result.diff_run }}" +- debug: msg="{{ force_run_all }}" # - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} after removing or defaulting interfaces # cisco.dcnm.dcnm_rest: diff --git a/roles/dtc/remove/tasks/sub_main_vxlan.yml b/roles/dtc/remove/tasks/sub_main_vxlan.yml index cf1d6a38e..f2a6c6b30 100644 --- a/roles/dtc/remove/tasks/sub_main_vxlan.yml +++ b/roles/dtc/remove/tasks/sub_main_vxlan.yml @@ -33,24 +33,24 @@ msg: "Configuring NXOS Devices using Nexus Dashboard (Direct to Controller)" tags: "{{ nac_tags.remove }}" -- name: Get List of iBGP VXLAN Fabric Switches from Nexus Dashboard - cisco.dcnm.dcnm_rest: - method: GET - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/inventory/switchesByFabric" - register: switch_list - tags: "{{ nac_tags.remove }}" +# - name: Get List of iBGP VXLAN Fabric Switches from Nexus Dashboard +# cisco.dcnm.dcnm_rest: +# method: GET +# path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/inventory/switchesByFabric" +# register: switch_list +# tags: "{{ nac_tags.remove }}" -- name: Remove iBGP VXLAN Fabric Edge Connections from Nexus Dashboard - ansible.builtin.import_tasks: common/edge_connections.yml - tags: "{{ nac_tags.remove_edge_connections }}" - when: - - vars_common_vxlan.changes_detected_edge_connections +# - name: Remove iBGP VXLAN Fabric Edge Connections from Nexus Dashboard +# ansible.builtin.import_tasks: common/edge_connections.yml +# tags: "{{ nac_tags.remove_edge_connections }}" +# when: +# - vars_common_vxlan.changes_detected_edge_connections -- name: Remove iBGP VXLAN Fabric Policy from Nexus Dashboard - ansible.builtin.import_tasks: common/policy.yml - tags: "{{ nac_tags.remove_policy }}" - when: - - vars_common_vxlan.changes_detected_policy +# - name: Remove iBGP VXLAN Fabric Policy from Nexus Dashboard +# ansible.builtin.import_tasks: common/policy.yml +# tags: "{{ nac_tags.remove_policy }}" +# when: +# - vars_common_vxlan.changes_detected_policy - name: Remove iBGP VXLAN Fabric Interfaces from Nexus Dashboard ansible.builtin.import_tasks: common/interfaces.yml diff --git a/roles/validate/tasks/manage_model_files_current.yml b/roles/validate/tasks/manage_model_files_current.yml index 509f98425..47440b775 100644 --- a/roles/validate/tasks/manage_model_files_current.yml +++ b/roles/validate/tasks/manage_model_files_current.yml @@ -62,16 +62,20 @@ - check_roles['save_previous'] - smd_golden_diff.diff_lines | length == 0 - smd_golden_diff.diff_text | length == 0 - - ((force_run_all is defined) and (force_run_all is false|bool)) + - run_map_read_result.diff_run is true|bool + - force_run_all is false|bool delegate_to: localhost +- debug: msg="{{ run_map_read_result}}" + - name: No Model Changes Detected ansible.builtin.meta: end_play when: - check_roles['save_previous'] - smd_golden_diff.diff_lines | length == 0 - smd_golden_diff.diff_text | length == 0 - - ((force_run_all is defined) and (force_run_all is false|bool)) + - run_map_read_result.diff_run is true|bool + - force_run_all is false|bool delegate_to: localhost # ------------------------------------------------------------------------ From 2d2072ca3e7db9f81bbb6355fe5f7bdd2b38e827 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Tue, 23 Sep 2025 22:43:39 -0400 Subject: [PATCH 10/65] Restore Commented out Lines --- roles/dtc/remove/tasks/sub_main_vxlan.yml | 32 +++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/roles/dtc/remove/tasks/sub_main_vxlan.yml b/roles/dtc/remove/tasks/sub_main_vxlan.yml index f2a6c6b30..cf1d6a38e 100644 --- a/roles/dtc/remove/tasks/sub_main_vxlan.yml +++ b/roles/dtc/remove/tasks/sub_main_vxlan.yml @@ -33,24 +33,24 @@ msg: "Configuring NXOS Devices using Nexus Dashboard (Direct to Controller)" tags: "{{ nac_tags.remove }}" -# - name: Get List of iBGP VXLAN Fabric Switches from Nexus Dashboard -# cisco.dcnm.dcnm_rest: -# method: GET -# path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/inventory/switchesByFabric" -# register: switch_list -# tags: "{{ nac_tags.remove }}" +- name: Get List of iBGP VXLAN Fabric Switches from Nexus Dashboard + cisco.dcnm.dcnm_rest: + method: GET + path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/inventory/switchesByFabric" + register: switch_list + tags: "{{ nac_tags.remove }}" -# - name: Remove iBGP VXLAN Fabric Edge Connections from Nexus Dashboard -# ansible.builtin.import_tasks: common/edge_connections.yml -# tags: "{{ nac_tags.remove_edge_connections }}" -# when: -# - vars_common_vxlan.changes_detected_edge_connections +- name: Remove iBGP VXLAN Fabric Edge Connections from Nexus Dashboard + ansible.builtin.import_tasks: common/edge_connections.yml + tags: "{{ nac_tags.remove_edge_connections }}" + when: + - vars_common_vxlan.changes_detected_edge_connections -# - name: Remove iBGP VXLAN Fabric Policy from Nexus Dashboard -# ansible.builtin.import_tasks: common/policy.yml -# tags: "{{ nac_tags.remove_policy }}" -# when: -# - vars_common_vxlan.changes_detected_policy +- name: Remove iBGP VXLAN Fabric Policy from Nexus Dashboard + ansible.builtin.import_tasks: common/policy.yml + tags: "{{ nac_tags.remove_policy }}" + when: + - vars_common_vxlan.changes_detected_policy - name: Remove iBGP VXLAN Fabric Interfaces from Nexus Dashboard ansible.builtin.import_tasks: common/interfaces.yml From 341c72c8877e78745736bf802ef5588cd676ae5f Mon Sep 17 00:00:00 2001 From: mwiebe Date: Tue, 23 Sep 2025 23:54:52 -0400 Subject: [PATCH 11/65] Updates --- roles/dtc/create/tasks/common/interfaces.yml | 5 ++++- roles/dtc/remove/tasks/common/interfaces.yml | 15 ++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/roles/dtc/create/tasks/common/interfaces.yml b/roles/dtc/create/tasks/common/interfaces.yml index 00d6e0145..0e0cfedd4 100644 --- a/roles/dtc/create/tasks/common/interfaces.yml +++ b/roles/dtc/create/tasks/common/interfaces.yml @@ -190,6 +190,7 @@ - debug: msg="{{ run_map_read_result }}" - debug: msg="{{ interface_config_list }}" +- debug: msg="{{ interface_config_list | length }}" - name: Sleep for 10 seconds ansible.builtin.pause: @@ -203,4 +204,6 @@ vars: ansible_command_timeout: 5000 ansible_connect_timeout: 5000 - when: MD_Extended.vxlan.topology.interfaces.modes.all.count > 0 + when: + - MD_Extended.vxlan.topology.interfaces.modes.all.count > 0 + - interface_config_list | length > 0 diff --git a/roles/dtc/remove/tasks/common/interfaces.yml b/roles/dtc/remove/tasks/common/interfaces.yml index 5f9f3c519..959a8a019 100644 --- a/roles/dtc/remove/tasks/common/interfaces.yml +++ b/roles/dtc/remove/tasks/common/interfaces.yml @@ -51,7 +51,7 @@ fabric: "{{ MD_Extended.vxlan.fabric.name }}" state: deleted config: "{{ vars_common_local.interface_diff_result.removed }}" - # deploy: false + deploy: false vars: ansible_command_timeout: 3000 ansible_connect_timeout: 3000 @@ -63,12 +63,15 @@ - run_map_read_result.diff_run is true|bool - force_run_all is false|bool +- debug: msg="Config {{ vars_common_local.interface_diff_result.removed }}" +- debug: msg="{{ vars_common_local.interface_diff_result.removed | length }}" + - name: Remove Unmanaged Fabric Interfaces in Nexus Dashboard - Diff Run False cisco.dcnm.dcnm_interface: fabric: "{{ MD_Extended.vxlan.fabric.name }}" state: overridden config: "{{ vars_common_local.interface_all }}" - # deploy: false + deploy: false vars: ansible_command_timeout: 3000 ansible_connect_timeout: 3000 @@ -78,10 +81,12 @@ - (interface_delete_mode is defined) and (interface_delete_mode is true|bool) - run_map_read_result.diff_run is false|bool or force_run_all is true|bool +- debug: msg="Config {{ vars_common_local.interface_all }}" - debug: msg="{{ vars_common_local.interface_all | length }}" -- debug: msg="{{ interface_delete_mode }}" -- debug: msg="{{ run_map_read_result.diff_run }}" -- debug: msg="{{ force_run_all }}" + +- debug: msg="INT DEL MODE {{ interface_delete_mode }}" +- debug: msg="RUN MAP {{ run_map_read_result.diff_run }}" +- debug: msg="FORCE RUN ALL {{ force_run_all }}" # - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} after removing or defaulting interfaces # cisco.dcnm.dcnm_rest: From a469a24eefac2fbebe268e4968bbabc777a2cb11 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Fri, 26 Sep 2025 23:50:03 -0400 Subject: [PATCH 12/65] Re-order int delete and add deploy after remove --- plugins/action/common/read_run_map.py | 4 +++ plugins/action/dtc/diff_compare.py | 28 +++++++++++++++++++ roles/common_global/defaults/main.yml | 1 + .../tasks/common/ndfc_interface_all.yml | 4 +-- roles/dtc/common/tasks/sub_main_vxlan.yml | 4 +-- roles/dtc/create/tasks/common/interfaces.yml | 4 +-- roles/dtc/remove/tasks/common/interfaces.yml | 5 +++- roles/dtc/remove/tasks/main.yml | 8 ++++++ .../tasks/manage_model_files_current.yml | 9 +++++- 9 files changed, 59 insertions(+), 8 deletions(-) diff --git a/plugins/action/common/read_run_map.py b/plugins/action/common/read_run_map.py index a0218ef6b..119ecd9d4 100644 --- a/plugins/action/common/read_run_map.py +++ b/plugins/action/common/read_run_map.py @@ -38,6 +38,7 @@ def run(self, tmp=None, task_vars=None): # self._supports_async = True results = super(ActionModule, self).run(tmp, task_vars) results['diff_run'] = True + results['validate_only_run'] = False model_data = self._task.args.get('model_data') play_tags = self._task.args.get('play_tags') @@ -69,8 +70,11 @@ def run(self, tmp=None, task_vars=None): if not previous_run_map.get(role): results['diff_run'] = False break + # All stages of the automation must run for the diff_run framework to be enabled if play_tags and 'all' not in play_tags: results['diff_run'] = False + if len(play_tags) == 1 and 'role_validate' in play_tags: + results['validate_only_run'] = True # If diff_run is false display an ansible warning message if not results['diff_run']: diff --git a/plugins/action/dtc/diff_compare.py b/plugins/action/dtc/diff_compare.py index d28c20a65..0a665529e 100644 --- a/plugins/action/dtc/diff_compare.py +++ b/plugins/action/dtc/diff_compare.py @@ -81,6 +81,9 @@ def run(self, tmp=None, task_vars=None): updated_items, removed_items, equal_items = self.compare_items(old_items, new_items) + if self.new_file_path.endswith('ndfc_interface_all.yml'): + removed_items = self.order_interface_remove(removed_items) + display.v("New or Modified Items:\n%s", yaml.dump(updated_items, default_flow_style=False)) display.v("---------------------------------") display.v("Remove Items:\n%s", yaml.dump(removed_items, default_flow_style=False)) @@ -202,3 +205,28 @@ def compare_items(self, old_items, new_items): removed_items.append(old_item) return updated_items, removed_items, equal_items + + def order_interface_remove(self, removed_items): + """ + Order interface removals to avoid dependency issues. + Ensures that port-channels are removed after their member interfaces. + + Args: + removed_items (list): List of interface items to be removed + + Returns: + list: Ordered list of interface items for removal (port-channels first, + then ethernet interfaces, then other interface types) + + Note: + This ordering helps prevent dependency conflicts during interface removal. + Port-channels should be removed before their member ethernet interfaces + to avoid configuration errors. + """ + # Separate port-channels and ethernet interfaces + port_channels = [item for item in removed_items if item.get('type') == 'pc'] + ethernet_interfaces = [item for item in removed_items if item.get('type') == 'eth'] + other_interfaces = [item for item in removed_items if item.get('type') not in ['pc', 'eth']] + + # Return ordered list: port-channels first, then ethernet interfaces, then others + return port_channels + ethernet_interfaces + other_interfaces diff --git a/roles/common_global/defaults/main.yml b/roles/common_global/defaults/main.yml index d18479b72..a93d46b01 100644 --- a/roles/common_global/defaults/main.yml +++ b/roles/common_global/defaults/main.yml @@ -31,6 +31,7 @@ # Parameter to force all roles/sections to run force_run_all: false +stage_remove: false # Parameters to enable/disable remove role tasks interface_delete_mode: false diff --git a/roles/dtc/common/tasks/common/ndfc_interface_all.yml b/roles/dtc/common/tasks/common/ndfc_interface_all.yml index 80d612438..5299fa382 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_all.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_all.yml @@ -117,9 +117,9 @@ - debug: msg="EQUAL {{ interface_diff_result['equal'] | length }}" - debug: msg="REMOVED {{ interface_diff_result['removed'] | length }}" - debug: msg="UPDATED {{ interface_diff_result['updated'] | length }}" -- name: Sleep for 10 seconds +- name: Sleep for 5 seconds ansible.builtin.pause: - seconds: 10 + seconds: 5 delegate_to: localhost - name: Get MD5 Diff For Previous and Current Data Files diff --git a/roles/dtc/common/tasks/sub_main_vxlan.yml b/roles/dtc/common/tasks/sub_main_vxlan.yml index 01a76bbe5..e659c3a2e 100644 --- a/roles/dtc/common/tasks/sub_main_vxlan.yml +++ b/roles/dtc/common/tasks/sub_main_vxlan.yml @@ -230,6 +230,7 @@ changes_detected_interface_breakout_preprov: "{{ changes_detected_interface_breakout_preprov }}" changes_detected_interface_po_routed: "{{ changes_detected_interface_po_routed }}" changes_detected_interface_routed: "{{ changes_detected_interface_routed }}" + changes_detected_sub_interface_routed: "{{ changes_detected_sub_interface_routed }}" changes_detected_interface_trunk_po: "{{ changes_detected_interface_trunk_po }}" changes_detected_interface_trunk: "{{ changes_detected_interface_trunk }}" changes_detected_interface_vpc: "{{ changes_detected_interface_vpc }}" @@ -238,7 +239,6 @@ changes_detected_link_vpc_peering: "{{ changes_detected_link_vpc_peering }}" changes_detected_networks: "{{ changes_detected_networks }}" changes_detected_policy: "{{ changes_detected_policy }}" - changes_detected_sub_interface_routed: "{{ changes_detected_sub_interface_routed }}" changes_detected_vpc_peering: "{{ changes_detected_vpc_peering }}" changes_detected_vpc_domain_id_resource: "{{ changes_detected_vpc_domain_id_resource }}" changes_detected_vrfs: "{{ changes_detected_vrfs }}" @@ -255,6 +255,7 @@ int_loopback_config: "{{ int_loopback_config }}" interface_po_routed: "{{ interface_po_routed }}" interface_routed: "{{ interface_routed }}" + sub_interface_routed: "{{ sub_interface_routed }}" interface_trunk_po: "{{ interface_trunk_po }}" interface_trunk: "{{ interface_trunk }}" interface_vpc: "{{ interface_vpc }}" @@ -264,7 +265,6 @@ net_config: "{{ net_config }}" poap_data: "{{ poap_data }}" policy_config: "{{ policy_config }}" - sub_interface_routed: "{{ sub_interface_routed }}" updated_inv_config: "{{ updated_inv_config }}" updated_inv_config_no_bootstrap: "{{ updated_inv_config_no_bootstrap }}" vpc_peering: "{{ vpc_peering }}" diff --git a/roles/dtc/create/tasks/common/interfaces.yml b/roles/dtc/create/tasks/common/interfaces.yml index 0e0cfedd4..de86858ab 100644 --- a/roles/dtc/create/tasks/common/interfaces.yml +++ b/roles/dtc/create/tasks/common/interfaces.yml @@ -192,9 +192,9 @@ - debug: msg="{{ interface_config_list }}" - debug: msg="{{ interface_config_list | length }}" -- name: Sleep for 10 seconds +- name: Sleep for 5 seconds ansible.builtin.pause: - seconds: 10 + seconds: 5 - name: Manage Interface All in Nexus Dashboard cisco.dcnm.dcnm_interface: diff --git a/roles/dtc/remove/tasks/common/interfaces.yml b/roles/dtc/remove/tasks/common/interfaces.yml index 959a8a019..838f02533 100644 --- a/roles/dtc/remove/tasks/common/interfaces.yml +++ b/roles/dtc/remove/tasks/common/interfaces.yml @@ -65,6 +65,9 @@ - debug: msg="Config {{ vars_common_local.interface_diff_result.removed }}" - debug: msg="{{ vars_common_local.interface_diff_result.removed | length }}" +- name: Sleep for 5 seconds + ansible.builtin.pause: + seconds: 5 - name: Remove Unmanaged Fabric Interfaces in Nexus Dashboard - Diff Run False cisco.dcnm.dcnm_interface: @@ -85,7 +88,7 @@ - debug: msg="{{ vars_common_local.interface_all | length }}" - debug: msg="INT DEL MODE {{ interface_delete_mode }}" -- debug: msg="RUN MAP {{ run_map_read_result.diff_run }}" +- debug: msg="DIFF RUN {{ run_map_read_result.diff_run }}" - debug: msg="FORCE RUN ALL {{ force_run_all }}" # - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} after removing or defaulting interfaces diff --git a/roles/dtc/remove/tasks/main.yml b/roles/dtc/remove/tasks/main.yml index 761b812a3..7e6e9216c 100644 --- a/roles/dtc/remove/tasks/main.yml +++ b/roles/dtc/remove/tasks/main.yml @@ -76,6 +76,14 @@ vars_common_ebgp_vxlan.changes_detected_networks) # Additional conditions to be added when needed: +- name: Log Stage Remove Without Deploy Setting + debug: msg="Stage Remove Without Deploy Is {{ stage_remove }}" + +- name: Deploy Remove Changes + ansible.builtin.include_role: + name: cisco.nac_dc_vxlan.dtc.deploy + when: stage_remove is false|bool + - name: Mark Stage Role Remove Completed cisco.nac_dc_vxlan.common.run_map: model_data: "{{ MD_Extended }}" diff --git a/roles/validate/tasks/manage_model_files_current.yml b/roles/validate/tasks/manage_model_files_current.yml index 47440b775..bbeb14a0f 100644 --- a/roles/validate/tasks/manage_model_files_current.yml +++ b/roles/validate/tasks/manage_model_files_current.yml @@ -62,10 +62,17 @@ - check_roles['save_previous'] - smd_golden_diff.diff_lines | length == 0 - smd_golden_diff.diff_text | length == 0 - - run_map_read_result.diff_run is true|bool + - run_map_read_result.diff_run is true - force_run_all is false|bool delegate_to: localhost +- name: Mark All Stages Completed When Only The Validate Role Is Run + cisco.nac_dc_vxlan.common.run_map: + model_data: "{{ MD_Extended }}" + stage: role_all_completed + when: run_map_read_result.validate_only_run is true|bool + delegate_to: localhost + - debug: msg="{{ run_map_read_result}}" - name: No Model Changes Detected From 8fd2df149577162daa438f413a568bfbd82fecc6 Mon Sep 17 00:00:00 2001 From: ccoueffe Date: Mon, 29 Sep 2025 15:51:36 +0200 Subject: [PATCH 13/65] update fabric_link, underlay_ip, vpc_domain_id, vpc_peering Signed-off-by: ccoueffe --- .../common/tasks/common/ndfc_fabric_links.yml | 20 +++++++++++- .../tasks/common/ndfc_underlay_ip_address.yml | 7 ++++ .../common/ndfc_vpc_domain_id_resource.yml | 7 ++++ .../tasks/common/ndfc_vpc_peering_pairs.yml | 7 ++++ .../create/tasks/common/devices_discovery.yml | 10 +++++- roles/dtc/create/tasks/common/links.yml | 5 ++- roles/dtc/remove/tasks/common/vpc_peers.yml | 32 ++++++++++++++++++- 7 files changed, 84 insertions(+), 4 deletions(-) diff --git a/roles/dtc/common/tasks/common/ndfc_fabric_links.yml b/roles/dtc/common/tasks/common/ndfc_fabric_links.yml index 646cd6f31..b05ff6b16 100644 --- a/roles/dtc/common/tasks/common/ndfc_fabric_links.yml +++ b/roles/dtc/common/tasks/common/ndfc_fabric_links.yml @@ -69,7 +69,25 @@ when: MD_Extended.vxlan.topology.fabric_links | length > 0 delegate_to: localhost -- name: Diff Previous and Current Data Files +- cisco.nac_dc_vxlan.dtc.diff_compare: + old_file: "{{ path_name }}{{ file_name }}.old" + new_file: "{{ path_name }}{{ file_name }}" + register: fabric_links_diff_result + delegate_to: localhost + +- debug: msg="EQUAL {{ fabric_links_diff_result['equal'] }}" +- debug: msg="REMOVED {{ fabric_links_diff_result['removed'] }}" +- debug: msg="UPDATED {{ fabric_links_diff_result['updated'] }}" +- debug: msg="EQUAL {{ fabric_links_diff_result['equal'] | length }}" +- debug: msg="REMOVED {{ fabric_links_diff_result['removed'] | length }}" +- debug: msg="UPDATED {{ fabric_links_diff_result['updated'] | length }}" + +- name: Sleep for 5 seconds + ansible.builtin.pause: + seconds: 5 + delegate_to: localhost + +- name: Get MD5 Diff Previous and Current Data Files cisco.nac_dc_vxlan.dtc.diff_model_changes: file_name_previous: "{{ path_name }}{{ file_name }}.old" file_name_current: "{{ path_name }}{{ file_name }}" diff --git a/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml b/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml index 04e45085b..8d888050b 100644 --- a/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml +++ b/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml @@ -80,6 +80,13 @@ register: underlay_ip_address_diff_result delegate_to: localhost +- debug: msg="EQUAL {{ underlay_ip_address_diff_result['equal'] }}" +- debug: msg="REMOVED {{ underlay_ip_address_diff_result['removed'] }}" +- debug: msg="UPDATED {{ underlay_ip_address_diff_result['updated'] }}" +- debug: msg="EQUAL {{ underlay_ip_address_diff_result['equal'] | length }}" +- debug: msg="REMOVED {{ underlay_ip_address_diff_result['removed'] | length }}" +- debug: msg="UPDATED {{ underlay_ip_address_diff_result['updated'] | length }}" + - name: Get MD5 Diff For Previous and Current Data Files cisco.nac_dc_vxlan.dtc.diff_model_changes: file_name_previous: "{{ path_name }}{{ file_name }}.old" diff --git a/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml b/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml index a5c4a397a..b62889665 100644 --- a/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml +++ b/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml @@ -78,6 +78,13 @@ register: vpc_domain_id_resource_diff_result delegate_to: localhost +- debug: msg="EQUAL {{ vpc_domain_id_resource_diff_result['equal'] }}" +- debug: msg="REMOVED {{ vpc_domain_id_resource_diff_result['removed'] }}" +- debug: msg="UPDATED {{ vpc_domain_id_resource_diff_result['updated'] }}" +- debug: msg="EQUAL {{ vpc_domain_id_resource_diff_result['equal'] | length }}" +- debug: msg="REMOVED {{ vpc_domain_id_resource_diff_result['removed'] | length }}" +- debug: msg="UPDATED {{ vpc_domain_id_resource_diff_result['updated'] | length }}" + - name: Get MD5 Diff Previous and Current Data Files cisco.nac_dc_vxlan.dtc.diff_model_changes: file_name_previous: "{{ path_name }}{{ file_name }}.old" diff --git a/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml b/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml index 068b6bf5e..3bccf69ab 100644 --- a/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml +++ b/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml @@ -78,6 +78,13 @@ register: vpc_peering_diff_result delegate_to: localhost +- debug: msg="EQUAL {{ vpc_peering_diff_result['equal'] }}" +- debug: msg="REMOVED {{ vpc_peering_diff_result['removed'] }}" +- debug: msg="UPDATED {{ vpc_peering_diff_result['updated'] }}" +- debug: msg="EQUAL {{ vpc_peering_diff_result['equal'] | length }}" +- debug: msg="REMOVED {{ vpc_peering_diff_result['removed'] | length }}" +- debug: msg="UPDATED {{ vpc_peering_diff_result['updated'] | length }}" + - name: Get MD5 Diff Previous and Current Data Files cisco.nac_dc_vxlan.dtc.diff_model_changes: file_name_previous: "{{ path_name }}{{ file_name }}.old" diff --git a/roles/dtc/create/tasks/common/devices_discovery.yml b/roles/dtc/create/tasks/common/devices_discovery.yml index c46301ae0..be209597e 100644 --- a/roles/dtc/create/tasks/common/devices_discovery.yml +++ b/roles/dtc/create/tasks/common/devices_discovery.yml @@ -56,6 +56,13 @@ - MD_Extended.vxlan.topology.switches | length > 0 - vars_common_local.changes_detected_inventory +- debug: msg="{{ vars_common_vxlan.underlay_ip_address_diff_result.updated }}" +- debug: msg="{{ vars_common_vxlan.underlay_ip_address_diff_result.updated | length }}" + +- name: Sleep for 5 seconds + ansible.builtin.pause: + seconds: 5 + - name: Allocate Underlay IP Address cisco.dcnm.dcnm_resource_manager: state: merged @@ -65,7 +72,8 @@ when: - MD_Extended.vxlan.underlay.general.manual_underlay_allocation is defined - MD_Extended.vxlan.underlay.general.manual_underlay_allocation - - (vars_common_local.changes_detected_underlay_ip_address is defined and vars_common_local.changes_detected_underlay_ip_address) + # - (vars_common_local.changes_detected_underlay_ip_address is defined and vars_common_local.changes_detected_underlay_ip_address) + - (vars_common_local.underlay_ip_address_diff_result is defined and vars_common_local.underlay_ip_address_diff_result.updated | length > 0) # With the addition of the Allocate Underlay IP Address change above we # cannot call cisco.dcnm.dcnm_inventory with save: true until after diff --git a/roles/dtc/create/tasks/common/links.yml b/roles/dtc/create/tasks/common/links.yml index 59d3b4984..d48950726 100644 --- a/roles/dtc/create/tasks/common/links.yml +++ b/roles/dtc/create/tasks/common/links.yml @@ -60,11 +60,14 @@ - name: Create a List of Links that Already Exist from Nexus Dashboard cisco.nac_dc_vxlan.dtc.existing_links_check: existing_links: "{{ result_links.response }}" - fabric_links: "{{ fabric_links }}" + # fabric_links: "{{ fabric_links }}" + fabric_links: "{{ fabric_links_diff_result.updated }}" switch_data_model: "{{ MD_Extended.vxlan.topology.switches }}" register: required_links when: result_links.response is defined +- debug: msg="{{ required_links }}" + # -------------------------------------------------------------------- # Manage Links Configuration in Nexus Dashboard # -------------------------------------------------------------------- diff --git a/roles/dtc/remove/tasks/common/vpc_peers.yml b/roles/dtc/remove/tasks/common/vpc_peers.yml index 03df440e9..54df2b129 100644 --- a/roles/dtc/remove/tasks/common/vpc_peers.yml +++ b/roles/dtc/remove/tasks/common/vpc_peers.yml @@ -43,7 +43,29 @@ - switch_list.response.DATA | length > 0 - (vpc_delete_mode is defined) and (vpc_delete_mode is true|bool) -- name: Remove Unmanaged vPC Peering from Nexus Dashboard +- name: Remove Unmanaged Fabric vPC Peering in Nexus Dashboard - Diff Run True + cisco.dcnm.dcnm_vpc_pair: + src_fabric: "{{ MD_Extended.vxlan.fabric.name }}" + deploy: true + state: deleted + config: "{{ vars_common_local.vpc_peering_diff_result.removed }}" + vars: + ansible_command_timeout: 1000 + ansible_connect_timeout: 1000 + when: + - switch_list.response.DATA | length > 0 + - vars_common_local.vpc_peering_diff_result.removed | length > 0 + - (vpc_delete_mode is defined) and (vpc_delete_mode is true|bool) + - run_map_read_result.diff_run is true|bool + - force_run_all is false|bool + +- debug: msg="Config {{ vars_common_local.vpc_peering_diff_result.removed }}" +- debug: msg="{{ vars_common_local.vpc_peering_diff_result.removed | length }}" +- name: Sleep for 5 seconds + ansible.builtin.pause: + seconds: 5 + +- name: Remove Unmanaged vPC Peering from Nexus Dashboard - Diff Run False cisco.dcnm.dcnm_vpc_pair: src_fabric: "{{ MD_Extended.vxlan.fabric.name }}" deploy: true @@ -55,6 +77,14 @@ when: - switch_list.response.DATA | length > 0 - (vpc_delete_mode is defined) and (vpc_delete_mode is true|bool) + - run_map_read_result.diff_run is false|bool or force_run_all is true|bool + +- debug: msg="Config {{ vars_common_local.vpc_peering }}" +- debug: msg="{{ vars_common_local.vpc_peering | length }}" + +- debug: msg="INT DEL MODE {{ interface_delete_mode }}" +- debug: msg="DIFF RUN {{ run_map_read_result.diff_run }}" +- debug: msg="FORCE RUN ALL {{ force_run_all }}" - name: Skip Remove Unmanaged vPC Peering Task If vpc_delete_mode is False ansible.builtin.debug: From 4640c994f898e9ce4218461b34df084637eb4cbf Mon Sep 17 00:00:00 2001 From: ccoueffe Date: Mon, 29 Sep 2025 16:50:01 +0200 Subject: [PATCH 14/65] initialize changes_detected_vpc_domain_id_resource Signed-off-by: ccoueffe --- roles/dtc/common/tasks/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/dtc/common/tasks/main.yml b/roles/dtc/common/tasks/main.yml index 6e403d010..a336dade1 100644 --- a/roles/dtc/common/tasks/main.yml +++ b/roles/dtc/common/tasks/main.yml @@ -46,6 +46,7 @@ changes_detected_policy: false changes_detected_sub_interface_routed: false changes_detected_vpc_peering: false + changes_detected_vpc_domain_id_resource: false changes_detected_vrfs: false changes_detected_underlay_ip_address: false vars_common_isn: From 070f6f5044b87015ff93130ceae7a85acb9cde7b Mon Sep 17 00:00:00 2001 From: mwiebe Date: Tue, 30 Sep 2025 14:53:57 -0400 Subject: [PATCH 15/65] Interface Remove and Deploy Updates --- plugins/action/dtc/diff_compare.py | 24 ++++++++++++-- roles/dtc/deploy/tasks/sub_main_vxlan.yml | 33 +++++++++++++++++++ .../common/308_topology_switch_duplex.py | 6 ++-- 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/plugins/action/dtc/diff_compare.py b/plugins/action/dtc/diff_compare.py index 0a665529e..fce60bacf 100644 --- a/plugins/action/dtc/diff_compare.py +++ b/plugins/action/dtc/diff_compare.py @@ -223,10 +223,28 @@ def order_interface_remove(self, removed_items): Port-channels should be removed before their member ethernet interfaces to avoid configuration errors. """ - # Separate port-channels and ethernet interfaces + # The order in which interfaces are configured matters during removal. + # Configuration Order: + # - Breakout Interfaces (Type: breakout) + # - Trunk Interfaces (Type: eth) + # - Access Interfaces (Type: eth) + # - Access Port-Channels (Type: pc) + # - Trunk Port-Channels (Type: pc) + # - Routed Interfaces (Type: eth) + # - Routed Sub-Interfaces (Type: sub_int) + # - Routed Port-Channels (Type: pc) + # - Loopback Interfaces (Type: lo) + # - Dot1Q Sub-Interfaces (Type: eth) + # - vPC Interfaces (Type: vpc) + + # Remove in the reverse order to avoid dependency issues + vpc_interfaces = [item for item in removed_items if item.get('type') == 'vpc'] + loopback_interfaces = [item for item in removed_items if item.get('type') == 'lo'] port_channels = [item for item in removed_items if item.get('type') == 'pc'] + routed_sub_interfaces = [item for item in removed_items if item.get('type') == 'sub_int'] ethernet_interfaces = [item for item in removed_items if item.get('type') == 'eth'] - other_interfaces = [item for item in removed_items if item.get('type') not in ['pc', 'eth']] + breakout_interfaces = [item for item in removed_items if item.get('type') == 'breakout'] # Return ordered list: port-channels first, then ethernet interfaces, then others - return port_channels + ethernet_interfaces + other_interfaces + all_interfaces = vpc_interfaces + loopback_interfaces + port_channels + routed_sub_interfaces + ethernet_interfaces + breakout_interfaces + return all_interfaces \ No newline at end of file diff --git a/roles/dtc/deploy/tasks/sub_main_vxlan.yml b/roles/dtc/deploy/tasks/sub_main_vxlan.yml index 34d6b42d9..dfa078759 100644 --- a/roles/dtc/deploy/tasks/sub_main_vxlan.yml +++ b/roles/dtc/deploy/tasks/sub_main_vxlan.yml @@ -94,3 +94,36 @@ - MD_Extended.vxlan.topology.switches is defined - MD_Extended.vxlan.topology.switches | length > 0 - results.changed + +- name: Check Switch Sync in iBGP VXLAN Fabric + cisco.nac_dc_vxlan.dtc.fabric_check_sync: + fabric: "{{ MD_Extended.vxlan.fabric.name }}" + register: results + when: > + (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) + +- name: Capture History Log On Failure for iBGP VXLAN Fabric + cisco.dcnm.dcnm_rest: + method: GET + path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/config/delivery/deployerHistoryByFabric/{{ MD_Extended.vxlan.fabric.name }}?sort=completedTime%3ADES&limit=5" + vars: + ansible_command_timeout: 3000 + ansible_connect_timeout: 3000 + when: + - MD_Extended.vxlan.topology.switches is defined + - MD_Extended.vxlan.topology.switches | length > 0 + - results.changed + register: history_log + +- name: Display Last 5 History Log Entries On Failure for iBGP VXLAN Fabric + ansible.builtin.debug: + msg: "{{ history_log.response.DATA | json_query('[0:2]') }}" + when: + - MD_Extended.vxlan.topology.switches is defined + - MD_Extended.vxlan.topology.switches | length > 0 + - results.changed + +- name: Fail On Failure for iBGP VXLAN Fabric + fail: + msg: "Deploy Failure Detected - Please see History Log For Full Details" + when: results.changed diff --git a/roles/validate/files/rules/common/308_topology_switch_duplex.py b/roles/validate/files/rules/common/308_topology_switch_duplex.py index 2d63334b1..7f81dafe2 100644 --- a/roles/validate/files/rules/common/308_topology_switch_duplex.py +++ b/roles/validate/files/rules/common/308_topology_switch_duplex.py @@ -28,21 +28,21 @@ def match(cls, data_model): if duplex and duplex != 'auto' and not speed: results.append( f"vxlan.topology.switches.interfaces.{interface_name}.duplex " - "is not supported without speed" + f"is not supported without speed on switch {switch.get('name')}" ) # Condition 2: duplex: 'half' or 'full' is not supported if speed == 'auto' if duplex in ['half', 'full'] and speed == 'auto': results.append( f"vxlan.topology.switches.interfaces.{interface_name}.duplex " - "'{duplex}' is not supported with speed 'auto'" + f"'{duplex}' is not supported with speed 'auto' on switch {switch.get('name')}" ) # Condition 3: duplex: 'half' is only supported with speed: '100mb' if duplex == 'half' and speed != '100mb': results.append( f"vxlan.topology.switches.interfaces.{interface_name}.duplex 'half' " - "is only supported with speed '100mb'" + f"is only supported with speed '100mb' on switch {switch.get('name')}" ) # Condition 4: duplex: 'auto' supports all speed values (or no speed at all) From ae7c2a46bf522c5e0ae6bc88541588533f2affe4 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Wed, 1 Oct 2025 14:59:06 -0400 Subject: [PATCH 16/65] Fix actions failure --- plugins/action/dtc/diff_compare.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/action/dtc/diff_compare.py b/plugins/action/dtc/diff_compare.py index fce60bacf..2c7a782bd 100644 --- a/plugins/action/dtc/diff_compare.py +++ b/plugins/action/dtc/diff_compare.py @@ -247,4 +247,4 @@ def order_interface_remove(self, removed_items): # Return ordered list: port-channels first, then ethernet interfaces, then others all_interfaces = vpc_interfaces + loopback_interfaces + port_channels + routed_sub_interfaces + ethernet_interfaces + breakout_interfaces - return all_interfaces \ No newline at end of file + return all_interfaces From f0373de3faf5a966cb10e6ffc25175a1129454e6 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Wed, 1 Oct 2025 15:20:16 -0400 Subject: [PATCH 17/65] Cleanup and add comments --- plugins/action/common/read_run_map.py | 4 + .../tasks/common/ndfc_interface_all.yml | 9 +- roles/dtc/create/tasks/common/interfaces.yml | 139 +----------------- roles/dtc/remove/tasks/common/interfaces.yml | 46 ++---- 4 files changed, 25 insertions(+), 173 deletions(-) diff --git a/plugins/action/common/read_run_map.py b/plugins/action/common/read_run_map.py index 119ecd9d4..4f0ea013c 100644 --- a/plugins/action/common/read_run_map.py +++ b/plugins/action/common/read_run_map.py @@ -73,6 +73,10 @@ def run(self, tmp=None, task_vars=None): # All stages of the automation must run for the diff_run framework to be enabled if play_tags and 'all' not in play_tags: results['diff_run'] = False + + # If only the role_validate tag is present then set validate_only_run to true + # This is used to prevent the diff_run map from being reset when the validate role + # gets run in isolation. if len(play_tags) == 1 and 'role_validate' in play_tags: results['validate_only_run'] = True diff --git a/roles/dtc/common/tasks/common/ndfc_interface_all.yml b/roles/dtc/common/tasks/common/ndfc_interface_all.yml index 5299fa382..aa9d14dd3 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_all.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_all.yml @@ -80,11 +80,11 @@ interface_breakout + interface_breakout_preprov + interface_trunk + - interface_access + - interface_access_po + - interface_trunk_po + interface_routed + sub_interface_routed + + interface_access + + interface_trunk_po + + interface_access_po + interface_po_routed + int_loopback_config + interface_dot1q + @@ -111,9 +111,6 @@ register: interface_diff_result delegate_to: localhost -- debug: msg="EQUAL {{ interface_diff_result['equal'] }}" -- debug: msg="REMOVED {{ interface_diff_result['removed'] }}" -- debug: msg="UPDATED {{ interface_diff_result['updated'] }}" - debug: msg="EQUAL {{ interface_diff_result['equal'] | length }}" - debug: msg="REMOVED {{ interface_diff_result['removed'] | length }}" - debug: msg="UPDATED {{ interface_diff_result['updated'] | length }}" diff --git a/roles/dtc/create/tasks/common/interfaces.yml b/roles/dtc/create/tasks/common/interfaces.yml index e440efb8b..36cec9f12 100644 --- a/roles/dtc/create/tasks/common/interfaces.yml +++ b/roles/dtc/create/tasks/common/interfaces.yml @@ -53,134 +53,15 @@ - "+ Manage Fabric Interfaces {{ MD_Extended.vxlan.fabric.name }}" - "----------------------------------------------------------------" -# # ---------------------------------------------------------------------- -# # Manage Interface Breakout Configuration in Nexus Dashboard -# # ---------------------------------------------------------------------- - -# - name: Manage Interface Breakout in Nexus Dashboard -# cisco.dcnm.dcnm_interface: -# fabric: "{{ MD_Extended.vxlan.fabric.name }}" -# state: replaced -# config: "{{ vars_common_local.interface_breakout }}" -# when: MD_Extended.vxlan.topology.interfaces.modes.breakout.count > 0 - -# # ---------------------------------------------------------------------- -# # Manage Interface Trunk Configuration in Nexus Dashboard -# # ---------------------------------------------------------------------- - -# - name: Manage Interface Trunk in Nexus Dashboard -# cisco.dcnm.dcnm_interface: -# fabric: "{{ MD_Extended.vxlan.fabric.name }}" -# state: replaced -# config: "{{ vars_common_local.interface_trunk }}" -# when: MD_Extended.vxlan.topology.interfaces.modes.trunk.count > 0 - -# # ---------------------------------------------------------------------- -# # Manage Interface Access Configuration in Nexus Dashboard -# # ---------------------------------------------------------------------- - -# - name: Manage Interface Access in Nexus Dashboard -# cisco.dcnm.dcnm_interface: -# fabric: "{{ MD_Extended.vxlan.fabric.name }}" -# state: replaced -# config: "{{ vars_common_local.interface_access }}" -# when: MD_Extended.vxlan.topology.interfaces.modes.access.count > 0 - -# # ---------------------------------------------------------------------- -# # Manage Interface Access Port-Channel Configuration in Nexus Dashboard -# # ---------------------------------------------------------------------- - -# - name: Manage Access Port-Channel Interface in Nexus Dashboard -# cisco.dcnm.dcnm_interface: -# fabric: "{{ MD_Extended.vxlan.fabric.name }}" -# state: replaced -# config: "{{ vars_common_local.interface_access_po }}" -# when: MD_Extended.vxlan.topology.interfaces.modes.access_po.count > 0 - -# # ---------------------------------------------------------------------- -# # Manage Interface Trunk Port-Channel Configuration in Nexus Dashboard -# # ---------------------------------------------------------------------- - -# - name: Manage Trunk Port-Channel Interface in Nexus Dashboard -# cisco.dcnm.dcnm_interface: -# fabric: "{{ MD_Extended.vxlan.fabric.name }}" -# state: replaced -# config: "{{ vars_common_local.interface_trunk_po }}" -# when: MD_Extended.vxlan.topology.interfaces.modes.trunk_po.count > 0 - -# # ---------------------------------------------------------------------- -# # Manage Interface Routed Configuration in Nexus Dashboard -# # ---------------------------------------------------------------------- - -# - name: Manage Interface Routed in Nexus Dashboard -# cisco.dcnm.dcnm_interface: -# fabric: "{{ MD_Extended.vxlan.fabric.name }}" -# state: replaced -# config: "{{ vars_common_local.interface_routed }}" -# when: MD_Extended.vxlan.topology.interfaces.modes.routed.count > 0 - -# # ---------------------------------------------------------------------- -# # Manage Sub-Interface Routed Configuration in Nexus Dashboard -# # ---------------------------------------------------------------------- - -# - name: Manage Sub-Interface Routed in Nexus Dashboard -# cisco.dcnm.dcnm_interface: -# fabric: "{{ MD_Extended.vxlan.fabric.name }}" -# state: replaced -# config: "{{ vars_common_local.sub_interface_routed }}" -# when: MD_Extended.vxlan.topology.interfaces.modes.routed_sub.count > 0 - -# # ---------------------------------------------------------------------- -# # Manage Interface Port-Channel Routed Configuration in Nexus Dashboard -# # ---------------------------------------------------------------------- - -# - name: Manage Interface Port-Channel Routed in Nexus Dashboard -# cisco.dcnm.dcnm_interface: -# fabric: "{{ MD_Extended.vxlan.fabric.name }}" -# state: replaced -# config: "{{ vars_common_local.interface_po_routed }}" -# when: MD_Extended.vxlan.topology.interfaces.modes.routed_po.count > 0 - -# # ---------------------------------------------------------------------- -# # Manage Interface Loopback Configuration in Nexus Dashboard -# # ---------------------------------------------------------------------- - -# - name: Manage Interface Loopback in Nexus Dashboard -# cisco.dcnm.dcnm_interface: -# fabric: "{{ MD_Extended.vxlan.fabric.name }}" -# state: replaced -# config: "{{ vars_common_local.int_loopback_config }}" -# when: > -# (MD_Extended.vxlan.topology.interfaces.modes.loopback.count > 0) or -# (MD_Extended.vxlan.topology.interfaces.modes.fabric_loopback.count > 0) or -# (MD_Extended.vxlan.topology.interfaces.modes.mpls_loopback.count > 0) - -# # ---------------------------------------------------------------------- -# # Manage Interface Dot1q Configuration in Nexus Dashboard -# # ---------------------------------------------------------------------- - -# - name: Manage Interface Dot1q in Nexus Dashboard -# cisco.dcnm.dcnm_interface: -# fabric: "{{ MD_Extended.vxlan.fabric.name }}" -# state: replaced -# config: "{{ vars_common_local.interface_dot1q }}" -# when: MD_Extended.vxlan.topology.interfaces.modes.dot1q.count > 0 - -# # ---------------------------------------------------------------------- -# # Manage Interface vPC Configuration in Nexus Dashboard -# # ---------------------------------------------------------------------- - -# - name: Manage Interface vPC in Nexus Dashboard -# cisco.dcnm.dcnm_interface: -# fabric: "{{ MD_Extended.vxlan.fabric.name }}" -# state: replaced -# config: "{{ vars_common_local.interface_vpc }}" -# when: MD_Extended.vxlan.topology.interfaces.modes.access_vpc.count > 0 or MD_Extended.vxlan.topology.interfaces.modes.trunk_vpc.count > 0 - -# Will discuss with team and switchover to the below code and remove the above code # -------------------------------------------------------------------- # Manage Interface All Configuration in Nexus Dashboard # -------------------------------------------------------------------- +# +# This section manages all of the interfaces based on the diff_run setting. +# +# When the diff_run feature is active we only manage the difference between +# the previous run and the current run, otherwise we manage all interfaces +# defined in the data model. - name: Initialize Interface Config List to All Interfaces set_fact: @@ -192,14 +73,6 @@ when: - run_map_read_result.diff_run is true|bool -- debug: msg="{{ run_map_read_result }}" -- debug: msg="{{ interface_config_list }}" -- debug: msg="{{ interface_config_list | length }}" - -- name: Sleep for 5 seconds - ansible.builtin.pause: - seconds: 5 - - name: Manage Interface All in Nexus Dashboard cisco.dcnm.dcnm_interface: fabric: "{{ MD_Extended.vxlan.fabric.name }}" diff --git a/roles/dtc/remove/tasks/common/interfaces.yml b/roles/dtc/remove/tasks/common/interfaces.yml index 9b0a2c4c7..6a8e14c5b 100644 --- a/roles/dtc/remove/tasks/common/interfaces.yml +++ b/roles/dtc/remove/tasks/common/interfaces.yml @@ -52,6 +52,15 @@ - switch_list.response.DATA | length > 0 - (interface_delete_mode is defined) and (interface_delete_mode is true|bool) +# ----------------------------------------------------------------------------- +# Remove Interfaces Using Diff Run Framework +# ----------------------------------------------------------------------------- +# +# The following conditions must be met for this task to execute: +# - The number of interfaces to be removed/defaulted as compared to the +# previous run must be non-zero. +# - The diff_run feature must be active +# Combination of the (diff_run flag and force_run_all_flag state) - name: Remove Unmanaged Fabric Interfaces in Nexus Dashboard - Diff Run True cisco.dcnm.dcnm_interface: fabric: "{{ MD_Extended.vxlan.fabric.name }}" @@ -69,12 +78,9 @@ - run_map_read_result.diff_run is true|bool - force_run_all is false|bool -- debug: msg="Config {{ vars_common_local.interface_diff_result.removed }}" -- debug: msg="{{ vars_common_local.interface_diff_result.removed | length }}" -- name: Sleep for 5 seconds - ansible.builtin.pause: - seconds: 5 - +# ----------------------------------------------------------------------------- +# Remove Interfaces Default Mode +# ----------------------------------------------------------------------------- - name: Remove Unmanaged Fabric Interfaces in Nexus Dashboard - Diff Run False cisco.dcnm.dcnm_interface: fabric: "{{ MD_Extended.vxlan.fabric.name }}" @@ -90,34 +96,6 @@ - (interface_delete_mode is defined) and (interface_delete_mode is true|bool) - run_map_read_result.diff_run is false|bool or force_run_all is true|bool -- debug: msg="Config {{ vars_common_local.interface_all }}" -- debug: msg="{{ vars_common_local.interface_all | length }}" - -- debug: msg="INT DEL MODE {{ interface_delete_mode }}" -- debug: msg="DIFF RUN {{ run_map_read_result.diff_run }}" -- debug: msg="FORCE RUN ALL {{ force_run_all }}" - -# - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} after removing or defaulting interfaces -# cisco.dcnm.dcnm_rest: -# method: POST -# path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" -# when: -# - int_data.changed is true -# - switch_list.response.DATA | length > 0 -# - (interface_delete_mode is defined) and (interface_delete_mode is true|bool) - -# - name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} after removing or defaulting interfaces -# cisco.dcnm.dcnm_rest: -# path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" -# method: POST -# vars: -# ansible_command_timeout: 3000 -# ansible_connect_timeout: 3000 -# when: -# - int_data.changed is true -# - switch_list.response.DATA | length > 0 -# - (interface_delete_mode is defined) and (interface_delete_mode is true|bool) - - name: Skip Remove Unmanaged Fabric Interfaces Task If interface_delete_mode is False ansible.builtin.debug: msg: From 10191de18e659e2027ca8c857a0f6f584baffe0f Mon Sep 17 00:00:00 2001 From: mwiebe Date: Wed, 1 Oct 2025 15:24:45 -0400 Subject: [PATCH 18/65] More cleanup --- roles/dtc/remove/tasks/main.yml | 3 ++- roles/validate/tasks/cleanup_model_files.yml | 2 +- roles/validate/tasks/manage_model_files_current.yml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/roles/dtc/remove/tasks/main.yml b/roles/dtc/remove/tasks/main.yml index 7e6e9216c..418418834 100644 --- a/roles/dtc/remove/tasks/main.yml +++ b/roles/dtc/remove/tasks/main.yml @@ -77,7 +77,8 @@ # Additional conditions to be added when needed: - name: Log Stage Remove Without Deploy Setting - debug: msg="Stage Remove Without Deploy Is {{ stage_remove }}" + ansible.builtin.debug: + msg: "Stage Remove Without Deploy Is {{ stage_remove }}" - name: Deploy Remove Changes ansible.builtin.include_role: diff --git a/roles/validate/tasks/cleanup_model_files.yml b/roles/validate/tasks/cleanup_model_files.yml index 3e40d43c7..609787fd9 100644 --- a/roles/validate/tasks/cleanup_model_files.yml +++ b/roles/validate/tasks/cleanup_model_files.yml @@ -37,4 +37,4 @@ path: "{{ item.path }}" state: absent loop: "{{ files_to_delete.files }}" - delegate_to: localhost \ No newline at end of file + delegate_to: localhost diff --git a/roles/validate/tasks/manage_model_files_current.yml b/roles/validate/tasks/manage_model_files_current.yml index bbeb14a0f..7d5aa847f 100644 --- a/roles/validate/tasks/manage_model_files_current.yml +++ b/roles/validate/tasks/manage_model_files_current.yml @@ -92,4 +92,4 @@ ansible.builtin.import_tasks: cleanup_model_files.yml when: - ((force_run_all is defined) and (force_run_all is true|bool)) - delegate_to: localhost \ No newline at end of file + delegate_to: localhost From 251c9fb34435a458f73db2bddc7705668cb3a989 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Wed, 1 Oct 2025 15:26:48 -0400 Subject: [PATCH 19/65] Update comment --- roles/dtc/remove/tasks/common/interfaces.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/dtc/remove/tasks/common/interfaces.yml b/roles/dtc/remove/tasks/common/interfaces.yml index 6a8e14c5b..24f1e4766 100644 --- a/roles/dtc/remove/tasks/common/interfaces.yml +++ b/roles/dtc/remove/tasks/common/interfaces.yml @@ -60,7 +60,7 @@ # - The number of interfaces to be removed/defaulted as compared to the # previous run must be non-zero. # - The diff_run feature must be active -# Combination of the (diff_run flag and force_run_all_flag state) +# Combination of the (diff_run flag and force_run_all_flag state) - name: Remove Unmanaged Fabric Interfaces in Nexus Dashboard - Diff Run True cisco.dcnm.dcnm_interface: fabric: "{{ MD_Extended.vxlan.fabric.name }}" From ad200240888c85c0b056cd372eea9821fe7163de Mon Sep 17 00:00:00 2001 From: mwiebe Date: Mon, 6 Oct 2025 19:21:44 -0400 Subject: [PATCH 20/65] Refactor changes_detected flags --- plugins/action/common/change_flag_manager.py | 335 ++++++++++++++++++ plugins/action/common/read_run_map.py | 3 + .../tasks/common/ndfc_edge_connections.yml | 25 +- roles/dtc/common/tasks/common/ndfc_fabric.yml | 25 +- .../common/tasks/common/ndfc_fabric_links.yml | 25 +- .../tasks/common/ndfc_interface_access.yml | 25 +- .../tasks/common/ndfc_interface_access_po.yml | 25 +- .../tasks/common/ndfc_interface_all.yml | 25 +- .../tasks/common/ndfc_interface_breakout.yml | 25 +- .../ndfc_interface_breakout_preprov.yml | 25 +- .../tasks/common/ndfc_interface_dot1q.yml | 25 +- .../tasks/common/ndfc_interface_loopback.yml | 25 +- .../tasks/common/ndfc_interface_po_routed.yml | 25 +- .../tasks/common/ndfc_interface_routed.yml | 25 +- .../tasks/common/ndfc_interface_trunk.yml | 25 +- .../tasks/common/ndfc_interface_trunk_po.yml | 25 +- .../tasks/common/ndfc_interface_vpc.yml | 25 +- .../common/tasks/common/ndfc_inventory.yml | 25 +- roles/dtc/common/tasks/common/ndfc_policy.yml | 25 +- .../common/ndfc_sub_interface_routed.yml | 25 +- .../tasks/common/ndfc_underlay_ip_address.yml | 26 +- .../common/ndfc_vpc_domain_id_resource.yml | 25 +- .../common/ndfc_vpc_fabric_peering_links.yml | 25 +- .../tasks/common/ndfc_vpc_peering_pairs.yml | 25 +- .../dtc/common/tasks/external/ndfc_fabric.yml | 13 + .../tasks/external/ndfc_interface_access.yml | 13 + .../external/ndfc_interface_access_po.yml | 13 + .../tasks/external/ndfc_interface_all.yml | 13 + .../external/ndfc_interface_loopback.yml | 13 + .../external/ndfc_interface_po_routed.yml | 13 + .../tasks/external/ndfc_interface_routed.yml | 13 + .../tasks/external/ndfc_interface_trunk.yml | 13 + .../external/ndfc_interface_trunk_po.yml | 13 + .../tasks/external/ndfc_interface_vpc.yml | 13 + .../dtc/common/tasks/external/ndfc_policy.yml | 13 + .../external/ndfc_sub_interface_routed.yml | 13 + .../tasks/external/ndfc_vpc_peering_pairs.yml | 13 + roles/dtc/common/tasks/main.yml | 202 ++++++----- .../common/tasks/msd/ndfc_bgw_anycast_vip.yml | 13 + .../dtc/common/tasks/msd/ndfc_child_vrfs.yml | 13 + roles/dtc/common/tasks/msd/ndfc_fabric.yml | 13 + roles/dtc/common/tasks/msd/ndfc_networks.yml | 13 + roles/dtc/common/tasks/msd/ndfc_vrfs.yml | 13 + .../dtc/common/tasks/sub_main_ebgp_vxlan.yml | 58 --- roles/dtc/common/tasks/sub_main_external.yml | 45 --- roles/dtc/common/tasks/sub_main_isn.yml | 45 --- roles/dtc/common/tasks/sub_main_msd.yml | 18 - roles/dtc/common/tasks/sub_main_vxlan.yml | 58 --- .../dtc/common/tasks/vxlan/ndfc_networks.yml | 13 + roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml | 13 + roles/dtc/create/tasks/common/interfaces.yml | 8 + roles/dtc/create/tasks/main.yml | 124 ++++--- .../dtc/create/tasks/sub_main_ebgp_vxlan.yml | 8 + roles/dtc/create/tasks/sub_main_external.yml | 8 + roles/dtc/create/tasks/sub_main_isn.yml | 8 + roles/dtc/create/tasks/sub_main_msd.yml | 8 + roles/dtc/create/tasks/sub_main_vxlan.yml | 8 + roles/dtc/deploy/tasks/main.yml | 198 ++++++----- .../dtc/deploy/tasks/sub_main_ebgp_vxlan.yml | 7 + roles/dtc/deploy/tasks/sub_main_external.yml | 7 + roles/dtc/deploy/tasks/sub_main_isn.yml | 7 + roles/dtc/deploy/tasks/sub_main_msd.yml | 7 + roles/dtc/deploy/tasks/sub_main_vxlan.yml | 7 + roles/dtc/remove/tasks/common/interfaces.yml | 12 +- roles/dtc/remove/tasks/main.yml | 110 ++++-- .../dtc/remove/tasks/sub_main_ebgp_vxlan.yml | 8 + roles/dtc/remove/tasks/sub_main_external.yml | 8 + roles/dtc/remove/tasks/sub_main_isn.yml | 8 + roles/dtc/remove/tasks/sub_main_msd.yml | 8 + roles/dtc/remove/tasks/sub_main_vxlan.yml | 8 + 70 files changed, 1533 insertions(+), 609 deletions(-) create mode 100644 plugins/action/common/change_flag_manager.py diff --git a/plugins/action/common/change_flag_manager.py b/plugins/action/common/change_flag_manager.py new file mode 100644 index 000000000..9d9f7f098 --- /dev/null +++ b/plugins/action/common/change_flag_manager.py @@ -0,0 +1,335 @@ +# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +# the Software, and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# SPDX-License-Identifier: MIT + +from __future__ import absolute_import, division, print_function + + +__metaclass__ = type + +from ansible.plugins.action import ActionBase +import json +import re +import inspect +import os + +class ChangeDetectionManager: + """Manages change detection flags for fabric configurations.""" + + def __init__(self, params): + self.class_name = self.__class__.__name__ + method_name = inspect.stack()[0][3] + + self.fabric_type = params['fabric_type'] + self.fabric_name = params['fabric_name'] + self.role_path = params['role_path'] + self.file_path = f"{self.role_path}/files/{self.fabric_name}_changes_detected_flags.json" + + def initialize_flags(self): + self.changes_detected_flags = {} + self.changes_detected_flags[self.fabric_name] = {} + self.changes_detected_flags[self.fabric_name][self.fabric_type] = {} + + # Supported Fabric Types VXLAN_EVPN, MSD, ISN, External, eBGP_VXLAN + if self.fabric_type == "VXLAN_EVPN": + self.changes_detected_flags[self.fabric_name][self.fabric_type] = { + 'changes_detected_fabric': False, + 'changes_detected_fabric_links': False, + 'changes_detected_edge_connections': False, + 'changes_detected_interface_dot1q': False, + 'changes_detected_interface_access_po': False, + 'changes_detected_interface_access': False, + 'changes_detected_interfaces': False, + 'changes_detected_interface_loopback': False, + 'changes_detected_interface_po_routed': False, + 'changes_detected_interface_routed': False, + 'changes_detected_interface_trunk_po': False, + 'changes_detected_interface_trunk': False, + 'changes_detected_interface_vpc': False, + 'changes_detected_interface_breakout': False, + 'changes_detected_interface_breakout_preprov': False, + 'changes_detected_inventory': False, + 'changes_detected_link_vpc_peering': False, + 'changes_detected_networks': False, + 'changes_detected_policy': False, + 'changes_detected_sub_interface_routed': False, + 'changes_detected_vpc_peering': False, + 'changes_detected_vpc_domain_id_resource': False, + 'changes_detected_vrfs': False, + 'changes_detected_underlay_ip_address': False, + 'changes_detected_any': False + } + if self.fabric_type == "ISN": + self.changes_detected_flags[self.fabric_name][self.fabric_type] = { + 'changes_detected_fabric': False, + # 'changes_detected_fabric_links': False, + 'changes_detected_edge_connections': False, + 'changes_detected_interface_dot1q': False, + 'changes_detected_interface_access_po': False, + 'changes_detected_interface_access': False, + 'changes_detected_interfaces': False, + 'changes_detected_interface_loopback': False, + 'changes_detected_interface_po_routed': False, + 'changes_detected_interface_routed': False, + 'changes_detected_interface_trunk_po': False, + 'changes_detected_interface_trunk': False, + 'changes_detected_interface_vpc': False, + 'changes_detected_interface_breakout': False, + 'changes_detected_interface_breakout_preprov': False, + 'changes_detected_inventory': False, + 'changes_detected_policy': False, + 'changes_detected_sub_interface_routed': False, + 'changes_detected_any': False + } + if self.fabric_type == "MSD": + self.changes_detected_flags[self.fabric_name][self.fabric_type] = { + 'changes_detected_fabric': False, + 'changes_detected_bgw_anycast_vip': False, + 'changes_detected_vrfs': False, + 'changes_detected_networks': False, + 'changes_detected_any': False + } + if self.fabric_type == "External": + self.changes_detected_flags[self.fabric_name][self.fabric_type] = { + 'changes_detected_inventory': False, + 'changes_detected_fabric': False, + 'changes_detected_edge_connections': False, + 'changes_detected_interface_dot1q': False, + 'changes_detected_interface_access_po': False, + 'changes_detected_interface_access': False, + 'changes_detected_interfaces': False, + 'changes_detected_interface_loopback': False, + 'changes_detected_interface_po_routed': False, + 'changes_detected_interface_routed': False, + 'changes_detected_interface_trunk_po': False, + 'changes_detected_interface_trunk': False, + 'changes_detected_interface_vpc': False, + 'changes_detected_interface_breakout': False, + 'changes_detected_interface_breakout_preprov': False, + 'changes_detected_sub_interface_routed': False, + 'changes_detected_vpc_peering': False, + 'changes_detected_policy': False, + 'changes_detected_any': False + } + if self.fabric_type == "eBGP_VXLAN": + self.changes_detected_flags[self.fabric_name][self.fabric_type] = { + 'changes_detected_fabric': False, + 'changes_detected_fabric_links': False, + 'changes_detected_edge_connections': False, + 'changes_detected_interface_dot1q': False, + 'changes_detected_interface_access_po': False, + 'changes_detected_interface_access': False, + 'changes_detected_interfaces': False, + 'changes_detected_interface_loopback': False, + 'changes_detected_interface_po_routed': False, + 'changes_detected_interface_routed': False, + 'changes_detected_interface_trunk_po': False, + 'changes_detected_interface_trunk': False, + 'changes_detected_interface_vpc': False, + 'changes_detected_interface_breakout': False, + 'changes_detected_interface_breakout_preprov': False, + 'changes_detected_inventory': False, + 'changes_detected_link_vpc_peering': False, + 'changes_detected_networks': False, + 'changes_detected_policy': False, + 'changes_detected_sub_interface_routed': False, + 'changes_detected_vpc_peering': False, + 'changes_detected_vrfs': False, + 'changes_detected_any': False + } + + def write_changes_detected_flags_to_file(self): + """Write changes_detected_flags dictionary to file in JSON format""" + + # Remove file if it exists + if os.path.exists(self.file_path): + os.remove(self.file_path) + + # Create directory if it doesn't exist + os.makedirs(os.path.dirname(self.file_path), exist_ok=True) + + # Write dictionary to file in JSON format + with open(self.file_path, 'w') as f: + json.dump(self.changes_detected_flags, f, indent=2) + + def read_changes_detected_flags_from_file(self): + """Read changes_detected_flags dictionary from JSON file""" + + if not os.path.exists(self.file_path): + return {} + + with open(self.file_path, 'r') as f: + return json.load(f) + + def update_change_detected_flag(self, flag_name, value): + """Update a specific change detected flag and write back to file""" + + # Update the flag in the changes_detected_flags dictionary + if self.fabric_name in self.changes_detected_flags: + if self.fabric_type in self.changes_detected_flags[self.fabric_name]: + if flag_name in self.changes_detected_flags[self.fabric_name][self.fabric_type]: + self.changes_detected_flags[self.fabric_name][self.fabric_type][flag_name] = value + + # Write updated flags back to file + self.write_changes_detected_flags_to_file() + return True + else: + print(f"Flag '{flag_name}' not found in fabric type '{self.fabric_type}' for fabric '{self.fabric_name}'") + return False + else: + print(f"Fabric type '{self.fabric_type}' not found in fabric '{self.fabric_name}'") + return False + else: + print(f"Fabric name '{self.fabric_name}' not found in flags dictionary") + return False + + def display_flag_values(self, task_vars): + """Display current flag values in a nicely formatted table""" + if not self.changes_detected_flags: + print("No change detection flags found.") + return + + # Display Execution Control Flags + print("\n\n") + print("-" * 40) + print("Stage Execution Control Flags:") + print("-" * 40) + + # Display run_map flag + run_map = task_vars.get('force_run_all', 'Not Available') + print(f"force_run_all | {run_map}") + + # Display diff_run flag from run_map_read_result + run_map_read_result = task_vars.get('run_map_read_result', {}) + diff_run = run_map_read_result.get('diff_run', 'Not Available') if isinstance(run_map_read_result, dict) else 'Not Available' + print(f"diff_run | {diff_run}") + + print("-" * 40) + + # Print header + print("\n" + "="*80) + print(f"Change Detection Flags for Fabric: {self.fabric_name}, Type: {self.fabric_type}") + print("="*80) + + if self.fabric_name in self.changes_detected_flags: + if self.fabric_type in self.changes_detected_flags[self.fabric_name]: + flags = self.changes_detected_flags[self.fabric_name][self.fabric_type] + + # Calculate column widths + max_flag_width = max(len(flag) for flag in flags.keys()) + flag_width = max(max_flag_width, 20) # Minimum width of 20 + + # Print table header + print(f"{'Flag Name':<{flag_width}} | {'Status':<8}") + print("-" * (flag_width + 11)) + + # Sort flags for consistent display + for flag_name in sorted(flags.keys()): + status = "TRUE" if flags[flag_name] else "FALSE" + status_color = status if not flags[flag_name] else f"**{status}**" + print(f"{flag_name:<{flag_width}} | {status_color:<8}") + + print("-" * (flag_width + 11)) + + # Summary + true_count = sum(1 for v in flags.values() if v) + total_count = len(flags) + print(f"Summary: {true_count}/{total_count} flags are TRUE") + else: + print(f"Fabric type '{self.fabric_type}' not found") + else: + print(f"Fabric '{self.fabric_name}' not found") + + print("="*80 + "\n") + +class ActionModule(ActionBase): + + def run(self, tmp=None, task_vars=None): + results = super(ActionModule, self).run(tmp, task_vars) + results['failed'] = False + + # Get data from Ansible task parameters + params = {} + params['fabric_type'] = self._task.args.get("fabric_type") + params['fabric_name'] = self._task.args.get("fabric_name") + params['role_path'] = self._task.args.get("role_path") + params['operation'] = self._task.args.get("operation") + params['change_flag'] = self._task.args.get("change_flag") + params['flag_value'] = self._task.args.get("flag_value") + + for key in ['fabric_type', 'fabric_name', 'role_path', 'operation']: + if params[key] is None: + results['failed'] = True + results['msg'] = f"Missing required parameter '{key}'" + return results + + if params['operation'] not in ['initialize', 'update', 'display']: + results['failed'] = True + results['msg'] = "Parameter 'operation' must be one of: initialize, update, display" + return results + + # Supported Operations (intialize, update) + change_detection_manager = ChangeDetectionManager(params) + + if params['operation'] == "initialize": + change_detection_manager.initialize_flags() + change_detection_manager.write_changes_detected_flags_to_file() + results['msg'] = f"Initialized change detection flags for fabric '{params['fabric_name']}' of type '{params['fabric_type']}'" + + if params['operation'] == "update": + if params['change_flag'] is None: + results['failed'] = True + results['msg'] = "Missing required parameter 'change_flag' for update operation" + return results + + if params['flag_value'] is None: + results['failed'] = True + results['msg'] = "Missing required parameter 'flag_value' for update operation" + return results + + if not isinstance(params['flag_value'], bool): + results['failed'] = True + results['msg'] = "Parameter 'flag_value' must be a boolean (True or False)" + return results + + change_detection_manager.changes_detected_flags = change_detection_manager.read_changes_detected_flags_from_file() + success = change_detection_manager.update_change_detected_flag(params['change_flag'], params['flag_value']) + + # If any of the flags are updated to be true then also set the changes_detected_any flag to true + if success and params['flag_value'] is True: + success = change_detection_manager.update_change_detected_flag('changes_detected_any', True) + self.process_write_result(success, 'changes_detected_any', True, params, results) + + self.process_write_result(success, params['change_flag'], params['flag_value'], params, results) + + if params['operation'] == "display": + change_detection_manager.changes_detected_flags = change_detection_manager.read_changes_detected_flags_from_file() + change_detection_manager.display_flag_values(task_vars) + from time import sleep + sleep(10) + + return results + + def process_write_result(self, success, change_flag, change_value, params, results): + if success: + results['msg'] = f"Updated flag '{change_flag}' to '{change_value}' for fabric '{params['fabric_name']}' of type '{params['fabric_type']}'" + else: + results['failed'] = True + results['msg'] = f"Failed to update flag '{change_flag}'" diff --git a/plugins/action/common/read_run_map.py b/plugins/action/common/read_run_map.py index 4f0ea013c..1662dd902 100644 --- a/plugins/action/common/read_run_map.py +++ b/plugins/action/common/read_run_map.py @@ -73,6 +73,9 @@ def run(self, tmp=None, task_vars=None): # All stages of the automation must run for the diff_run framework to be enabled if play_tags and 'all' not in play_tags: results['diff_run'] = False + # If force_run_all is True then set the diff_run flag to false + if task_vars.get('force_run_all') is True: + results['diff_run'] = False # If only the role_validate tag is present then set validate_only_run to true # This is used to prevent the diff_run map from being reset when the validate role diff --git a/roles/dtc/common/tasks/common/ndfc_edge_connections.yml b/roles/dtc/common/tasks/common/ndfc_edge_connections.yml index 81008166e..c74a68bca 100644 --- a/roles/dtc/common/tasks/common/ndfc_edge_connections.yml +++ b/roles/dtc/common/tasks/common/ndfc_edge_connections.yml @@ -21,10 +21,10 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_edge_connections: false - delegate_to: localhost +# - name: Initialize changes_detected Var +# ansible.builtin.set_fact: +# changes_detected_edge_connections: false +# delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -76,9 +76,22 @@ register: file_diff_result delegate_to: localhost +# - name: Set File Change Flag Based on File Diff Result +# ansible.builtin.set_fact: +# changes_detected_edge_connections: true +# delegate_to: localhost +# when: +# - file_diff_result.file_data_changed +# - check_roles['save_previous'] + - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_edge_connections: true + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_edge_connections + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/common/ndfc_fabric.yml b/roles/dtc/common/tasks/common/ndfc_fabric.yml index 7c584c5df..6cbf7cb8a 100644 --- a/roles/dtc/common/tasks/common/ndfc_fabric.yml +++ b/roles/dtc/common/tasks/common/ndfc_fabric.yml @@ -21,10 +21,10 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_fabric: false - delegate_to: localhost +# - name: Initialize changes_detected Var +# ansible.builtin.set_fact: +# changes_detected_fabric: false +# delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -76,9 +76,22 @@ register: file_diff_result delegate_to: localhost +# - name: Set File Change Flag Based on File Diff Result +# ansible.builtin.set_fact: +# changes_detected_fabric: true +# delegate_to: localhost +# when: +# - file_diff_result.file_data_changed +# - check_roles['save_previous'] + - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_fabric: true + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_fabric + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/common/ndfc_fabric_links.yml b/roles/dtc/common/tasks/common/ndfc_fabric_links.yml index b05ff6b16..5edd674ed 100644 --- a/roles/dtc/common/tasks/common/ndfc_fabric_links.yml +++ b/roles/dtc/common/tasks/common/ndfc_fabric_links.yml @@ -21,10 +21,10 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_fabric_links: false - delegate_to: localhost +# - name: Initialize changes_detected Var +# ansible.builtin.set_fact: +# changes_detected_fabric_links: false +# delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -94,9 +94,22 @@ register: file_diff_result delegate_to: localhost +# - name: Set File Change Flag Based on File Diff Result +# ansible.builtin.set_fact: +# changes_detected_fabric_links: true +# delegate_to: localhost +# when: +# - file_diff_result.file_data_changed +# - check_roles['save_previous'] + - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_fabric_links: true + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_fabric_links + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/common/ndfc_interface_access.yml b/roles/dtc/common/tasks/common/ndfc_interface_access.yml index 621d49ac9..baea9335f 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_access.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_access.yml @@ -21,10 +21,10 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_interface_access: false - delegate_to: localhost +# - name: Initialize changes_detected Var +# ansible.builtin.set_fact: +# changes_detected_interface_access: false +# delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -76,9 +76,22 @@ register: file_diff_result delegate_to: localhost +# - name: Set File Change Flag Based on File Diff Result +# ansible.builtin.set_fact: +# changes_detected_interface_access: true +# delegate_to: localhost +# when: +# - file_diff_result.file_data_changed +# - check_roles['save_previous'] + - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_interface_access: true + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_interface_access + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/common/ndfc_interface_access_po.yml b/roles/dtc/common/tasks/common/ndfc_interface_access_po.yml index e8fc14c59..7fb7a1b9c 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_access_po.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_access_po.yml @@ -21,10 +21,10 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_interface_access_po: false - delegate_to: localhost +# - name: Initialize changes_detected Var +# ansible.builtin.set_fact: +# changes_detected_interface_access_po: false +# delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -76,9 +76,22 @@ register: file_diff_result delegate_to: localhost +# - name: Set File Change Flag Based on File Diff Result +# ansible.builtin.set_fact: +# changes_detected_interface_access_po: true +# delegate_to: localhost +# when: +# - file_diff_result.file_data_changed +# - check_roles['save_previous'] + - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_interface_access_po: true + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_interface_access_po + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/common/ndfc_interface_all.yml b/roles/dtc/common/tasks/common/ndfc_interface_all.yml index aa9d14dd3..651112805 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_all.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_all.yml @@ -21,10 +21,10 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_interfaces: false - delegate_to: localhost +# - name: Initialize changes_detected Var +# ansible.builtin.set_fact: +# changes_detected_interfaces: false +# delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -126,9 +126,22 @@ register: file_diff_result delegate_to: localhost +# - name: Set File Change Flag Based on File Diff Result +# ansible.builtin.set_fact: +# changes_detected_interfaces: true +# delegate_to: localhost +# when: +# - file_diff_result.file_data_changed +# - check_roles['save_previous'] + - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_interfaces: true + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_interfaces + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/common/ndfc_interface_breakout.yml b/roles/dtc/common/tasks/common/ndfc_interface_breakout.yml index 562fee504..39564f9cb 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_breakout.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_breakout.yml @@ -21,10 +21,10 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_interface_breakout: false - delegate_to: localhost +# - name: Initialize changes_detected Var +# ansible.builtin.set_fact: +# changes_detected_interface_breakout: false +# delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -76,9 +76,22 @@ register: file_diff_result delegate_to: localhost +# - name: Set File Change Flag Based on File Diff Result +# ansible.builtin.set_fact: +# changes_detected_interface_breakout: true +# delegate_to: localhost +# when: +# - file_diff_result.file_data_changed +# - check_roles['save_previous'] + - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_interface_breakout: true + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_interface_breakout + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/common/ndfc_interface_breakout_preprov.yml b/roles/dtc/common/tasks/common/ndfc_interface_breakout_preprov.yml index cf2f76e6c..a2020b050 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_breakout_preprov.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_breakout_preprov.yml @@ -21,10 +21,10 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_interface_breakout_preprov: false - delegate_to: localhost +# - name: Initialize changes_detected Var +# ansible.builtin.set_fact: +# changes_detected_interface_breakout_preprov: false +# delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -76,9 +76,22 @@ register: file_diff_result delegate_to: localhost +# - name: Set File Change Flag Based on File Diff Result +# ansible.builtin.set_fact: +# changes_detected_interface_breakout_preprov: true +# delegate_to: localhost +# when: +# - file_diff_result.file_data_changed +# - check_roles['save_previous'] + - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_interface_breakout_preprov: true + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_interface_breakout_preprov + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/common/ndfc_interface_dot1q.yml b/roles/dtc/common/tasks/common/ndfc_interface_dot1q.yml index 514ff2c0e..aa717064b 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_dot1q.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_dot1q.yml @@ -21,10 +21,10 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_interface_dot1q: false - delegate_to: localhost +# - name: Initialize changes_detected Var +# ansible.builtin.set_fact: +# changes_detected_interface_dot1q: false +# delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -76,9 +76,22 @@ register: file_diff_result delegate_to: localhost +# - name: Set File Change Flag Based on File Diff Result +# ansible.builtin.set_fact: +# changes_detected_interface_dot1q: true +# delegate_to: localhost +# when: +# - file_diff_result.file_data_changed +# - check_roles['save_previous'] + - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_interface_dot1q: true + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_interface_dot1q + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/common/ndfc_interface_loopback.yml b/roles/dtc/common/tasks/common/ndfc_interface_loopback.yml index ee3fd1f86..e3c4b59eb 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_loopback.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_loopback.yml @@ -21,10 +21,10 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_interface_loopback: false - delegate_to: localhost +# - name: Initialize changes_detected Var +# ansible.builtin.set_fact: +# changes_detected_interface_loopback: false +# delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -79,9 +79,22 @@ register: file_diff_result delegate_to: localhost +# - name: Set File Change Flag Based on File Diff Result +# ansible.builtin.set_fact: +# changes_detected_interface_loopback: true +# delegate_to: localhost +# when: +# - file_diff_result.file_data_changed +# - check_roles['save_previous'] + - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_interface_loopback: true + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_interface_loopback + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/common/ndfc_interface_po_routed.yml b/roles/dtc/common/tasks/common/ndfc_interface_po_routed.yml index bb4792caa..d4ad34e54 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_po_routed.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_po_routed.yml @@ -21,10 +21,10 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_interface_po_routed: false - delegate_to: localhost +# - name: Initialize changes_detected Var +# ansible.builtin.set_fact: +# changes_detected_interface_po_routed: false +# delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -76,9 +76,22 @@ register: file_diff_result delegate_to: localhost +# - name: Set File Change Flag Based on File Diff Result +# ansible.builtin.set_fact: +# changes_detected_interface_po_routed: true +# delegate_to: localhost +# when: +# - file_diff_result.file_data_changed +# - check_roles['save_previous'] + - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_interface_po_routed: true + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_interface_po_routed + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/common/ndfc_interface_routed.yml b/roles/dtc/common/tasks/common/ndfc_interface_routed.yml index d170ff039..6bae3ea83 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_routed.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_routed.yml @@ -21,10 +21,10 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_interface_routed: false - delegate_to: localhost +# - name: Initialize changes_detected Var +# ansible.builtin.set_fact: +# changes_detected_interface_routed: false +# delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -76,9 +76,22 @@ register: file_diff_result delegate_to: localhost +# - name: Set File Change Flag Based on File Diff Result +# ansible.builtin.set_fact: +# changes_detected_interface_routed: true +# delegate_to: localhost +# when: +# - file_diff_result.file_data_changed +# - check_roles['save_previous'] + - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_interface_routed: true + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_interface_routed + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/common/ndfc_interface_trunk.yml b/roles/dtc/common/tasks/common/ndfc_interface_trunk.yml index 2a9ab284d..f189491a7 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_trunk.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_trunk.yml @@ -21,10 +21,10 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_interface_trunk: false - delegate_to: localhost +# - name: Initialize changes_detected Var +# ansible.builtin.set_fact: +# changes_detected_interface_trunk: false +# delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -76,9 +76,22 @@ register: file_diff_result delegate_to: localhost +# - name: Set File Change Flag Based on File Diff Result +# ansible.builtin.set_fact: +# changes_detected_interface_trunk: true +# delegate_to: localhost +# when: +# - file_diff_result.file_data_changed +# - check_roles['save_previous'] + - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_interface_trunk: true + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_interface_trunk + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/common/ndfc_interface_trunk_po.yml b/roles/dtc/common/tasks/common/ndfc_interface_trunk_po.yml index 8378187c1..58b13a17a 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_trunk_po.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_trunk_po.yml @@ -21,10 +21,10 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_interface_trunk_po: false - delegate_to: localhost +# - name: Initialize changes_detected Var +# ansible.builtin.set_fact: +# changes_detected_interface_trunk_po: false +# delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -76,9 +76,22 @@ register: file_diff_result delegate_to: localhost +# - name: Set File Change Flag Based on File Diff Result +# ansible.builtin.set_fact: +# changes_detected_interface_trunk_po: true +# delegate_to: localhost +# when: +# - file_diff_result.file_data_changed +# - check_roles['save_previous'] + - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_interface_trunk_po: true + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_interface_trunk_po + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/common/ndfc_interface_vpc.yml b/roles/dtc/common/tasks/common/ndfc_interface_vpc.yml index 94dc0383d..9597fc578 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_vpc.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_vpc.yml @@ -21,10 +21,10 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_interface_vpc: false - delegate_to: localhost +# - name: Initialize changes_detected Var +# ansible.builtin.set_fact: +# changes_detected_interface_vpc: false +# delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -76,9 +76,22 @@ register: file_diff_result delegate_to: localhost +# - name: Set File Change Flag Based on File Diff Result +# ansible.builtin.set_fact: +# changes_detected_interface_vpc: true +# delegate_to: localhost +# when: +# - file_diff_result.file_data_changed +# - check_roles['save_previous'] + - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_interface_vpc: true + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_interface_vpc + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/common/ndfc_inventory.yml b/roles/dtc/common/tasks/common/ndfc_inventory.yml index 96886577e..d219ae070 100644 --- a/roles/dtc/common/tasks/common/ndfc_inventory.yml +++ b/roles/dtc/common/tasks/common/ndfc_inventory.yml @@ -26,10 +26,10 @@ model_data: "{{ MD_Extended }}" register: poap_data -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_inventory: false - delegate_to: localhost +# - name: Initialize changes_detected Var +# ansible.builtin.set_fact: +# changes_detected_inventory: false +# delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -99,9 +99,22 @@ register: file_diff_result delegate_to: localhost +# - name: Set File Change Flag Based on File Diff Result +# ansible.builtin.set_fact: +# changes_detected_inventory: true +# delegate_to: localhost +# when: +# - file_diff_result.file_data_changed +# - check_roles['save_previous'] + - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_inventory: true + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_inventory + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/common/ndfc_policy.yml b/roles/dtc/common/tasks/common/ndfc_policy.yml index d14f7d9ab..52a4f36fb 100644 --- a/roles/dtc/common/tasks/common/ndfc_policy.yml +++ b/roles/dtc/common/tasks/common/ndfc_policy.yml @@ -21,10 +21,10 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_policy: false - delegate_to: localhost +# - name: Initialize changes_detected Var +# ansible.builtin.set_fact: +# changes_detected_policy: false +# delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -77,9 +77,22 @@ register: file_diff_result delegate_to: localhost +# - name: Set File Change Flag Based on File Diff Result +# ansible.builtin.set_fact: +# changes_detected_policy: true +# delegate_to: localhost +# when: +# - file_diff_result.file_data_changed +# - check_roles['save_previous'] + - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_policy: true + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_policy + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/common/ndfc_sub_interface_routed.yml b/roles/dtc/common/tasks/common/ndfc_sub_interface_routed.yml index 4a91f7f60..c67587fcf 100644 --- a/roles/dtc/common/tasks/common/ndfc_sub_interface_routed.yml +++ b/roles/dtc/common/tasks/common/ndfc_sub_interface_routed.yml @@ -21,10 +21,10 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_sub_interface_routed: false - delegate_to: localhost +# - name: Initialize changes_detected Var +# ansible.builtin.set_fact: +# changes_detected_sub_interface_routed: false +# delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -76,9 +76,22 @@ register: file_diff_result delegate_to: localhost +# - name: Set File Change Flag Based on File Diff Result +# ansible.builtin.set_fact: +# changes_detected_sub_interface_routed: true +# delegate_to: localhost +# when: +# - file_diff_result.file_data_changed +# - check_roles['save_previous'] + - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_sub_interface_routed: true + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_sub_interface_routed + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml b/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml index 8d888050b..a7476efef 100644 --- a/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml +++ b/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml @@ -20,10 +20,11 @@ # SPDX-License-Identifier: MIT --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_underlay_ip_address: false - delegate_to: localhost + +# - name: Initialize changes_detected Var +# ansible.builtin.set_fact: +# changes_detected_underlay_ip_address: false +# delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -94,9 +95,22 @@ register: file_diff_result delegate_to: localhost +# - name: Set File Change Flag Based on File Diff Result +# ansible.builtin.set_fact: +# changes_detected_underlay_ip_address: true +# delegate_to: localhost +# when: +# - file_diff_result.file_data_changed +# - check_roles['save_previous'] + - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_underlay_ip_address: true + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_underlay_ip_address + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml b/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml index b62889665..ded3dbe79 100644 --- a/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml +++ b/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml @@ -21,10 +21,10 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_vpc_domain_id_resource: false - delegate_to: localhost +# - name: Initialize changes_detected Var +# ansible.builtin.set_fact: +# changes_detected_vpc_domain_id_resource: false +# delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -92,9 +92,22 @@ register: file_diff_result delegate_to: localhost +# - name: Set File Change Flag Based on File Diff Result +# ansible.builtin.set_fact: +# changes_detected_vpc_domain_id_resource: true +# delegate_to: localhost +# when: +# - file_diff_result.file_data_changed +# - check_roles['save_previous'] + - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_vpc_domain_id_resource: true + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_vpc_domain_id_resource + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/common/ndfc_vpc_fabric_peering_links.yml b/roles/dtc/common/tasks/common/ndfc_vpc_fabric_peering_links.yml index cf3f44391..38b5a939f 100644 --- a/roles/dtc/common/tasks/common/ndfc_vpc_fabric_peering_links.yml +++ b/roles/dtc/common/tasks/common/ndfc_vpc_fabric_peering_links.yml @@ -21,10 +21,10 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_link_vpc_peering: false - delegate_to: localhost +# - name: Initialize changes_detected Var +# ansible.builtin.set_fact: +# changes_detected_link_vpc_peering: false +# delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -79,9 +79,22 @@ register: file_diff_result delegate_to: localhost +# - name: Set File Change Flag Based on File Diff Result +# ansible.builtin.set_fact: +# changes_detected_link_vpc_peering: true +# delegate_to: localhost +# when: +# - file_diff_result.file_data_changed +# - check_roles['save_previous'] + - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_link_vpc_peering: true + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_link_vpc_peering + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml b/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml index 3bccf69ab..ed0d5fd66 100644 --- a/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml +++ b/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml @@ -21,10 +21,10 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_vpc_peering: false - delegate_to: localhost +# - name: Initialize changes_detected Var +# ansible.builtin.set_fact: +# changes_detected_vpc_peering: false +# delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -92,9 +92,22 @@ register: file_diff_result delegate_to: localhost +# - name: Set File Change Flag Based on File Diff Result +# ansible.builtin.set_fact: +# changes_detected_vpc_peering: true +# delegate_to: localhost +# when: +# - file_diff_result.file_data_changed +# - check_roles['save_previous'] + - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_vpc_peering: true + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_vpc_peering + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/external/ndfc_fabric.yml b/roles/dtc/common/tasks/external/ndfc_fabric.yml index 0b0823a75..2b94ed537 100644 --- a/roles/dtc/common/tasks/external/ndfc_fabric.yml +++ b/roles/dtc/common/tasks/external/ndfc_fabric.yml @@ -78,3 +78,16 @@ when: - file_diff_result.file_data_changed - check_roles['save_previous'] + +- name: Set File Change Flag Based on File Diff Result + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_fabric + flag_value: true + delegate_to: localhost + when: + - file_diff_result.file_data_changed + - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_interface_access.yml b/roles/dtc/common/tasks/external/ndfc_interface_access.yml index 8ed96053e..f10aae6bc 100644 --- a/roles/dtc/common/tasks/external/ndfc_interface_access.yml +++ b/roles/dtc/common/tasks/external/ndfc_interface_access.yml @@ -83,3 +83,16 @@ when: - file_diff_result.file_data_changed - check_roles['save_previous'] + +- name: Set File Change Flag Based on File Diff Result + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_interface_access + flag_value: true + delegate_to: localhost + when: + - file_diff_result.file_data_changed + - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_interface_access_po.yml b/roles/dtc/common/tasks/external/ndfc_interface_access_po.yml index 6589cff43..5689fa7e3 100644 --- a/roles/dtc/common/tasks/external/ndfc_interface_access_po.yml +++ b/roles/dtc/common/tasks/external/ndfc_interface_access_po.yml @@ -83,3 +83,16 @@ when: - file_diff_result.file_data_changed - check_roles['save_previous'] + +- name: Set File Change Flag Based on File Diff Result + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_interface_access_po + flag_value: true + delegate_to: localhost + when: + - file_diff_result.file_data_changed + - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_interface_all.yml b/roles/dtc/common/tasks/external/ndfc_interface_all.yml index fc2658daa..4f082bca1 100644 --- a/roles/dtc/common/tasks/external/ndfc_interface_all.yml +++ b/roles/dtc/common/tasks/external/ndfc_interface_all.yml @@ -92,3 +92,16 @@ when: - file_diff_result.file_data_changed - check_roles['save_previous'] + +- name: Set File Change Flag Based on File Diff Result + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_interfaces + flag_value: true + delegate_to: localhost + when: + - file_diff_result.file_data_changed + - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_interface_loopback.yml b/roles/dtc/common/tasks/external/ndfc_interface_loopback.yml index 46c21da63..eb74408eb 100644 --- a/roles/dtc/common/tasks/external/ndfc_interface_loopback.yml +++ b/roles/dtc/common/tasks/external/ndfc_interface_loopback.yml @@ -86,3 +86,16 @@ when: - file_diff_result.file_data_changed - check_roles['save_previous'] + +- name: Set File Change Flag Based on File Diff Result + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_interface_loopback + flag_value: true + delegate_to: localhost + when: + - file_diff_result.file_data_changed + - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_interface_po_routed.yml b/roles/dtc/common/tasks/external/ndfc_interface_po_routed.yml index 4faafa3c6..78c1a7a74 100644 --- a/roles/dtc/common/tasks/external/ndfc_interface_po_routed.yml +++ b/roles/dtc/common/tasks/external/ndfc_interface_po_routed.yml @@ -83,3 +83,16 @@ when: - file_diff_result.file_data_changed - check_roles['save_previous'] + +- name: Set File Change Flag Based on File Diff Result + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_interface_po_routed + flag_value: true + delegate_to: localhost + when: + - file_diff_result.file_data_changed + - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_interface_routed.yml b/roles/dtc/common/tasks/external/ndfc_interface_routed.yml index 2faf943b3..6dedd3265 100644 --- a/roles/dtc/common/tasks/external/ndfc_interface_routed.yml +++ b/roles/dtc/common/tasks/external/ndfc_interface_routed.yml @@ -83,3 +83,16 @@ when: - file_diff_result.file_data_changed - check_roles['save_previous'] + +- name: Set File Change Flag Based on File Diff Result + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_interface_routed + flag_value: true + delegate_to: localhost + when: + - file_diff_result.file_data_changed + - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_interface_trunk.yml b/roles/dtc/common/tasks/external/ndfc_interface_trunk.yml index d3e20e825..aaf446260 100644 --- a/roles/dtc/common/tasks/external/ndfc_interface_trunk.yml +++ b/roles/dtc/common/tasks/external/ndfc_interface_trunk.yml @@ -83,3 +83,16 @@ when: - file_diff_result.file_data_changed - check_roles['save_previous'] + +- name: Set File Change Flag Based on File Diff Result + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_interface_trunk + flag_value: true + delegate_to: localhost + when: + - file_diff_result.file_data_changed + - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_interface_trunk_po.yml b/roles/dtc/common/tasks/external/ndfc_interface_trunk_po.yml index f0e6d1cdc..52e21b47d 100644 --- a/roles/dtc/common/tasks/external/ndfc_interface_trunk_po.yml +++ b/roles/dtc/common/tasks/external/ndfc_interface_trunk_po.yml @@ -83,3 +83,16 @@ when: - file_diff_result.file_data_changed - check_roles['save_previous'] + +- name: Set File Change Flag Based on File Diff Result + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_interface_trunk_po + flag_value: true + delegate_to: localhost + when: + - file_diff_result.file_data_changed + - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_interface_vpc.yml b/roles/dtc/common/tasks/external/ndfc_interface_vpc.yml index cf1c51d7c..d31e655c4 100644 --- a/roles/dtc/common/tasks/external/ndfc_interface_vpc.yml +++ b/roles/dtc/common/tasks/external/ndfc_interface_vpc.yml @@ -83,3 +83,16 @@ when: - file_diff_result.file_data_changed - check_roles['save_previous'] + +- name: Set File Change Flag Based on File Diff Result + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_interface_vpc + flag_value: true + delegate_to: localhost + when: + - file_diff_result.file_data_changed + - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_policy.yml b/roles/dtc/common/tasks/external/ndfc_policy.yml index 12226a3d9..7e0a7d258 100644 --- a/roles/dtc/common/tasks/external/ndfc_policy.yml +++ b/roles/dtc/common/tasks/external/ndfc_policy.yml @@ -79,3 +79,16 @@ when: - file_diff_result.file_data_changed - check_roles['save_previous'] + +- name: Set File Change Flag Based on File Diff Result + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_policy + flag_value: true + delegate_to: localhost + when: + - file_diff_result.file_data_changed + - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_sub_interface_routed.yml b/roles/dtc/common/tasks/external/ndfc_sub_interface_routed.yml index f81a7f0cb..7bbe70d8e 100644 --- a/roles/dtc/common/tasks/external/ndfc_sub_interface_routed.yml +++ b/roles/dtc/common/tasks/external/ndfc_sub_interface_routed.yml @@ -83,3 +83,16 @@ when: - file_diff_result.file_data_changed - check_roles['save_previous'] + +- name: Set File Change Flag Based on File Diff Result + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_sub_interface_routed + flag_value: true + delegate_to: localhost + when: + - file_diff_result.file_data_changed + - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_vpc_peering_pairs.yml b/roles/dtc/common/tasks/external/ndfc_vpc_peering_pairs.yml index 9a267acd0..6c9fde5f1 100644 --- a/roles/dtc/common/tasks/external/ndfc_vpc_peering_pairs.yml +++ b/roles/dtc/common/tasks/external/ndfc_vpc_peering_pairs.yml @@ -88,3 +88,16 @@ when: - file_diff_result.file_data_changed - check_roles['save_previous'] + +- name: Set File Change Flag Based on File Diff Result + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_vpc_peering + flag_value: true + delegate_to: localhost + when: + - file_diff_result.file_data_changed + - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/main.yml b/roles/dtc/common/tasks/main.yml index a336dade1..59cdcd043 100644 --- a/roles/dtc/common/tasks/main.yml +++ b/roles/dtc/common/tasks/main.yml @@ -21,93 +21,101 @@ --- -# ------------------------------------------------------------------------ -# Initialize NameSpace Dicts For Variable Sharing -# ------------------------------------------------------------------------ -- name: Initialize NameSpace Dict For Sharing Variables - ansible.builtin.set_fact: - vars_common_vxlan: - changes_detected_fabric: false - changes_detected_fabric_links: false - changes_detected_edge_connections: false - changes_detected_interface_dot1q: false - changes_detected_interface_access_po: false - changes_detected_interface_access: false - changes_detected_interfaces: false - changes_detected_interface_loopback: false - changes_detected_interface_po_routed: false - changes_detected_interface_routed: false - changes_detected_interface_trunk_po: false - changes_detected_interface_trunk: false - changes_detected_interface_vpc: false - changes_detected_inventory: false - changes_detected_link_vpc_peering: false - changes_detected_networks: false - changes_detected_policy: false - changes_detected_sub_interface_routed: false - changes_detected_vpc_peering: false - changes_detected_vpc_domain_id_resource: false - changes_detected_vrfs: false - changes_detected_underlay_ip_address: false - vars_common_isn: - changes_detected_fabric: false - changes_detected_fabric_links: false - changes_detected_edge_connections: false - changes_detected_interface_dot1q: false - changes_detected_interface_access_po: false - changes_detected_interface_access: false - changes_detected_interfaces: false - changes_detected_interface_loopback: false - changes_detected_interface_po_routed: false - changes_detected_interface_routed: false - changes_detected_interface_trunk_po: false - changes_detected_interface_trunk: false - changes_detected_interface_vpc: false - changes_detected_inventory: false - changes_detected_policy: false - changes_detected_sub_interface_routed: false - vars_common_msd: - changes_detected_fabric: false - changes_detected_bgw_anycast_vip: false - changes_detected_vrfs: false - changes_detected_networks: false - vars_common_external: - changes_detected_inventory: false - changes_detected_fabric: false - changes_detected_interface_dot1q: false - changes_detected_interface_access_po: false - changes_detected_interface_access: false - changes_detected_interfaces: false - changes_detected_interface_loopback: false - changes_detected_interface_po_routed: false - changes_detected_interface_routed: false - changes_detected_interface_trunk_po: false - changes_detected_interface_trunk: false - changes_detected_interface_vpc: false - changes_detected_sub_interface_routed: false - changes_detected_policy: false - vars_common_ebgp_vxlan: - changes_detected_fabric: false - changes_detected_fabric_links: false - changes_detected_edge_connections: false - changes_detected_interface_dot1q: false - changes_detected_interface_access_po: false - changes_detected_interface_access: false - changes_detected_interfaces: false - changes_detected_interface_loopback: false - changes_detected_interface_po_routed: false - changes_detected_interface_routed: false - changes_detected_interface_trunk_po: false - changes_detected_interface_trunk: false - changes_detected_interface_vpc: false - changes_detected_inventory: false - changes_detected_link_vpc_peering: false - changes_detected_networks: false - changes_detected_policy: false - changes_detected_sub_interface_routed: false - changes_detected_vpc_peering: false - changes_detected_vrfs: false - tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml +- name: Initialize Change Flags + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "initialize" + delegate_to: localhost + +# # ------------------------------------------------------------------------ +# # Initialize NameSpace Dicts For Variable Sharing +# # ------------------------------------------------------------------------ +# - name: Initialize NameSpace Dict For Sharing Variables +# ansible.builtin.set_fact: +# vars_common_vxlan: +# changes_detected_fabric: false +# changes_detected_fabric_links: false +# changes_detected_edge_connections: false +# changes_detected_interface_dot1q: false +# changes_detected_interface_access_po: false +# changes_detected_interface_access: false +# changes_detected_interfaces: false +# changes_detected_interface_loopback: false +# changes_detected_interface_po_routed: false +# changes_detected_interface_routed: false +# changes_detected_interface_trunk_po: false +# changes_detected_interface_trunk: false +# changes_detected_interface_vpc: false +# changes_detected_inventory: false +# changes_detected_link_vpc_peering: false +# changes_detected_networks: false +# changes_detected_policy: false +# changes_detected_sub_interface_routed: false +# changes_detected_vpc_peering: false +# changes_detected_vpc_domain_id_resource: false +# changes_detected_vrfs: false +# changes_detected_underlay_ip_address: false +# vars_common_isn: +# changes_detected_fabric: false +# changes_detected_fabric_links: false +# changes_detected_edge_connections: false +# changes_detected_interface_dot1q: false +# changes_detected_interface_access_po: false +# changes_detected_interface_access: false +# changes_detected_interfaces: false +# changes_detected_interface_loopback: false +# changes_detected_interface_po_routed: false +# changes_detected_interface_routed: false +# changes_detected_interface_trunk_po: false +# changes_detected_interface_trunk: false +# changes_detected_interface_vpc: false +# changes_detected_inventory: false +# changes_detected_policy: false +# changes_detected_sub_interface_routed: false +# vars_common_msd: +# changes_detected_fabric: false +# changes_detected_bgw_anycast_vip: false +# changes_detected_vrfs: false +# changes_detected_networks: false +# vars_common_external: +# changes_detected_inventory: false +# changes_detected_fabric: false +# changes_detected_interface_dot1q: false +# changes_detected_interface_access_po: false +# changes_detected_interface_access: false +# changes_detected_interfaces: false +# changes_detected_interface_loopback: false +# changes_detected_interface_po_routed: false +# changes_detected_interface_routed: false +# changes_detected_interface_trunk_po: false +# changes_detected_interface_trunk: false +# changes_detected_interface_vpc: false +# changes_detected_sub_interface_routed: false +# changes_detected_policy: false +# vars_common_ebgp_vxlan: +# changes_detected_fabric: false +# changes_detected_fabric_links: false +# changes_detected_edge_connections: false +# changes_detected_interface_dot1q: false +# changes_detected_interface_access_po: false +# changes_detected_interface_access: false +# changes_detected_interfaces: false +# changes_detected_interface_loopback: false +# changes_detected_interface_po_routed: false +# changes_detected_interface_routed: false +# changes_detected_interface_trunk_po: false +# changes_detected_interface_trunk: false +# changes_detected_interface_vpc: false +# changes_detected_inventory: false +# changes_detected_link_vpc_peering: false +# changes_detected_networks: false +# changes_detected_policy: false +# changes_detected_sub_interface_routed: false +# changes_detected_vpc_peering: false +# changes_detected_vrfs: false +# tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml - name: Import Role Tasks for iBGP VXLAN Fabric ansible.builtin.import_tasks: sub_main_vxlan.yml @@ -133,3 +141,23 @@ ansible.builtin.import_tasks: sub_main_external.yml tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml when: MD_Extended.vxlan.fabric.type == 'External' + +- name: Read Change Flags JSON Data From File + ansible.builtin.set_fact: + change_flag_data: "{{ lookup('ansible.builtin.file', role_path + '/files/' + MD_Extended.vxlan.fabric.name + '_changes_detected_flags.json') | from_json }}" + delegate_to: localhost + +- name: Set Change Flags Fact + ansible.builtin.set_fact: + change_flags: "{{ change_flag_data[MD_Extended.vxlan.fabric.name][MD_Extended.vxlan.fabric.type] }}" + delegate_to: localhost + +- name: Display Flag Values + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "display" + delegate_to: localhost + +- debug: msg="{{ change_flags }}" \ No newline at end of file diff --git a/roles/dtc/common/tasks/msd/ndfc_bgw_anycast_vip.yml b/roles/dtc/common/tasks/msd/ndfc_bgw_anycast_vip.yml index 9b1a51e8e..661852836 100644 --- a/roles/dtc/common/tasks/msd/ndfc_bgw_anycast_vip.yml +++ b/roles/dtc/common/tasks/msd/ndfc_bgw_anycast_vip.yml @@ -81,3 +81,16 @@ when: - file_diff_result.file_data_changed - check_roles['save_previous'] + +- name: Set File Change Flag Based on File Diff Result + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_bgw_anycast_vip + flag_value: true + delegate_to: localhost + when: + - file_diff_result.file_data_changed + - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/msd/ndfc_child_vrfs.yml b/roles/dtc/common/tasks/msd/ndfc_child_vrfs.yml index fc16c9d3a..e3a7b351d 100644 --- a/roles/dtc/common/tasks/msd/ndfc_child_vrfs.yml +++ b/roles/dtc/common/tasks/msd/ndfc_child_vrfs.yml @@ -84,6 +84,19 @@ - file_diff_result.file_data_changed - check_roles['save_previous'] +- name: Set File Change Flag Based on File Diff Result + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_vrfs + flag_value: true + delegate_to: localhost + when: + - file_diff_result.file_data_changed + - check_roles['save_previous'] + # - name: Set file_name Var for loopback attachments # ansible.builtin.set_fact: # file_name: "{{ MD_Extended.vxlan.fabric.name }}_attach_vrfs_loopbacks.yml" diff --git a/roles/dtc/common/tasks/msd/ndfc_fabric.yml b/roles/dtc/common/tasks/msd/ndfc_fabric.yml index f3863e2f7..6dcecb123 100644 --- a/roles/dtc/common/tasks/msd/ndfc_fabric.yml +++ b/roles/dtc/common/tasks/msd/ndfc_fabric.yml @@ -83,3 +83,16 @@ when: - file_diff_result.file_data_changed - check_roles['save_previous'] + +- name: Set File Change Flag Based on File Diff Result + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_fabric + flag_value: true + delegate_to: localhost + when: + - file_diff_result.file_data_changed + - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/msd/ndfc_networks.yml b/roles/dtc/common/tasks/msd/ndfc_networks.yml index c243eed3b..b4f187454 100644 --- a/roles/dtc/common/tasks/msd/ndfc_networks.yml +++ b/roles/dtc/common/tasks/msd/ndfc_networks.yml @@ -83,3 +83,16 @@ when: - file_diff_result.file_data_changed - check_roles['save_previous'] + +- name: Set File Change Flag Based on File Diff Result + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_networks + flag_value: true + delegate_to: localhost + when: + - file_diff_result.file_data_changed + - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/msd/ndfc_vrfs.yml b/roles/dtc/common/tasks/msd/ndfc_vrfs.yml index 21849224a..84a91e1a0 100644 --- a/roles/dtc/common/tasks/msd/ndfc_vrfs.yml +++ b/roles/dtc/common/tasks/msd/ndfc_vrfs.yml @@ -84,6 +84,19 @@ - file_diff_result.file_data_changed - check_roles['save_previous'] +- name: Set File Change Flag Based on File Diff Result + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_vrfs + flag_value: true + delegate_to: localhost + when: + - file_diff_result.file_data_changed + - check_roles['save_previous'] + - name: Set file_name Var for loopback attachments ansible.builtin.set_fact: file_name: "{{ MD_Extended.vxlan.fabric.name }}_attach_vrfs_loopbacks.yml" diff --git a/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml b/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml index 2704bbe81..dea44c32a 100644 --- a/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml +++ b/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml @@ -211,30 +211,6 @@ - name: Save Local Variables With Namespace Context ansible.builtin.set_fact: vars_common_ebgp_vxlan: - changes_detected_fabric: "{{ changes_detected_fabric }}" - changes_detected_fabric_links: false - # changes_detected_fabric_links: "{{ changes_detected_fabric_links }}" - # changes_detected_edge_connections: "{{ changes_detected_edge_connections }}" - changes_detected_interface_access_po: "{{ changes_detected_interface_access_po }}" - changes_detected_interface_access: "{{ changes_detected_interface_access }}" - changes_detected_interfaces: "{{ changes_detected_interfaces }}" - changes_detected_interface_loopback: "{{ changes_detected_interface_loopback }}" - changes_detected_interface_breakout: "{{ changes_detected_interface_breakout }}" - changes_detected_interface_breakout_preprov: "{{ changes_detected_interface_breakout_preprov }}" - changes_detected_interface_po_routed: "{{ changes_detected_interface_po_routed }}" - changes_detected_interface_routed: "{{ changes_detected_interface_routed }}" - changes_detected_interface_trunk_po: "{{ changes_detected_interface_trunk_po }}" - changes_detected_interface_trunk: "{{ changes_detected_interface_trunk }}" - changes_detected_interface_vpc: "{{ changes_detected_interface_vpc }}" - changes_detected_interface_dot1q: "{{ changes_detected_interface_dot1q }}" - changes_detected_inventory: "{{ changes_detected_inventory }}" - changes_detected_link_vpc_peering: "{{ changes_detected_link_vpc_peering }}" - changes_detected_networks: "{{ changes_detected_networks }}" - changes_detected_policy: "{{ changes_detected_policy }}" - changes_detected_sub_interface_routed: "{{ changes_detected_sub_interface_routed }}" - changes_detected_vpc_peering: "{{ changes_detected_vpc_peering }}" - changes_detected_vpc_domain_id_resource: "{{ changes_detected_vpc_domain_id_resource }}" - changes_detected_vrfs: "{{ changes_detected_vrfs }}" fabric_config: "{{ fabric_config }}" # fabric_links: "{{ fabric_links }}" interface_breakout: "{{ interface_breakout }}" @@ -262,37 +238,3 @@ vpc_domain_id_resource: "{{ vpc_domain_id_resource }}" vrf_config: "{{ vrf_config }}" vrf_attach_config: "{{ vrf_attach_config }}" - -- name: Run Diff Flags - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ Fabric Changes Detected - [ {{ vars_common_ebgp_vxlan.changes_detected_fabric }} ]" - - "+ Inventory Changes Detected - [ {{ vars_common_ebgp_vxlan.changes_detected_inventory }} ]" - - "+ vPC Link Peer Changes Detected - [ {{ vars_common_ebgp_vxlan.changes_detected_link_vpc_peering }} ]" - - "+ vPC Peer Changes Detected - [ {{ vars_common_ebgp_vxlan.changes_detected_vpc_peering }} ]" - - "+ vPC Domain ID Detected - [ {{ vars_common_ebgp_vxlan.changes_detected_vpc_domain_id_resource }} ]" - - "+ ----- Interfaces -----" - - "+ Interface breakout Changes Detected - [ {{ vars_common_ebgp_vxlan.changes_detected_interface_breakout }} ]" - - "+ Interface PreProv breakout Changes Detected - [ {{ vars_common_ebgp_vxlan.changes_detected_interface_breakout_preprov }} ]" - - "+ Interface vPC Changes Detected - [ {{ vars_common_ebgp_vxlan.changes_detected_interface_vpc }} ]" - - "+ Interface Access Changes Detected - [ {{ vars_common_ebgp_vxlan.changes_detected_interface_access }} ]" - - "+ Interface Access PO Changes Detected - [ {{ vars_common_ebgp_vxlan.changes_detected_interface_access_po }} ]" - - "+ Interface Loopback Changes Detected - [ {{ vars_common_ebgp_vxlan.changes_detected_interface_loopback }} ]" - - "+ Interface PO Routed Changes Detected - [ {{ vars_common_ebgp_vxlan.changes_detected_interface_po_routed }} ]" - - "+ Interface Routed Changes Detected - [ {{ vars_common_ebgp_vxlan.changes_detected_interface_routed }} ]" - - "+ Interface Trunk Changes Detected - [ {{ vars_common_ebgp_vxlan.changes_detected_interface_trunk }} ]" - - "+ Interface Trunk PO Changes Detected - [ {{ vars_common_ebgp_vxlan.changes_detected_interface_trunk_po }} ]" - - "+ Sub Interface Routed Changes Detected - [ {{ vars_common_ebgp_vxlan.changes_detected_sub_interface_routed }} ]" - - "+ ----- All Interfaces -----" - - "+ All Interfaces Changes Detected - [ {{ vars_common_ebgp_vxlan.changes_detected_interfaces }} ]" - - "+ ----- All Interfaces -----" - - "+ VRFs Changes Detected - [ {{ vars_common_ebgp_vxlan.changes_detected_vrfs }} ]" - - "+ Networks Changes Detected - [ {{ vars_common_ebgp_vxlan.changes_detected_networks }} ]" - - "+ Policy Changes Detected - [ {{ vars_common_ebgp_vxlan.changes_detected_policy }} ]" -# - "+ Fabric Links Changes Detected - [ {{ vars_common_ebgp_vxlan.changes_detected_fabric_links }} ]" -# - "+ Edge Connections Changes Detected - [ {{ vars_common_ebgp_vxlan.changes_detected_edge_connections }} ]" - - "+ ----- Run Map -----" - - "+ Run Map Diff Run - [ {{ run_map_read_result.diff_run }} ]" - - "+ Force Run Flag - [ {{ force_run_all }} ]" - - "----------------------------------------------------------------" diff --git a/roles/dtc/common/tasks/sub_main_external.yml b/roles/dtc/common/tasks/sub_main_external.yml index fac4e05be..88dc96963 100644 --- a/roles/dtc/common/tasks/sub_main_external.yml +++ b/roles/dtc/common/tasks/sub_main_external.yml @@ -177,23 +177,6 @@ - name: Save Local Variables With Namespace Context ansible.builtin.set_fact: vars_common_external: - changes_detected_fabric: "{{ changes_detected_fabric }}" - changes_detected_inventory: "{{ changes_detected_inventory }}" - changes_detected_edge_connections: "{{ changes_detected_edge_connections }}" - changes_detected_interface_access_po: "{{ changes_detected_interface_access_po }}" - changes_detected_interface_access: "{{ changes_detected_interface_access }}" - changes_detected_interface_loopback: "{{ changes_detected_interface_loopback }}" - changes_detected_interface_breakout: "{{ changes_detected_interface_breakout }}" - changes_detected_interface_breakout_preprov: "{{ changes_detected_interface_breakout_preprov }}" - changes_detected_interface_po_routed: "{{ changes_detected_interface_po_routed }}" - changes_detected_interface_routed: "{{ changes_detected_interface_routed }}" - changes_detected_interface_trunk_po: "{{ changes_detected_interface_trunk_po }}" - changes_detected_interface_trunk: "{{ changes_detected_interface_trunk }}" - changes_detected_sub_interface_routed: "{{ changes_detected_sub_interface_routed }}" - changes_detected_interface_dot1q: "{{ changes_detected_interface_dot1q }}" - changes_detected_interfaces: "{{ changes_detected_interfaces }}" - changes_detected_policy: "{{ changes_detected_policy }}" - changes_detected_vpc_peering: "{{ changes_detected_vpc_peering }}" fabric_config: "{{ fabric_config }}" edge_connections: "{{ edge_connections }}" interface_breakout: "{{ interface_breakout }}" @@ -215,31 +198,3 @@ updated_inv_config: "{{ updated_inv_config }}" updated_inv_config_no_bootstrap: "{{ updated_inv_config_no_bootstrap }}" vpc_peering: "{{ vpc_peering }}" - -- name: Run Diff Flags - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ Fabric Changes Detected - [ {{ vars_common_external.changes_detected_fabric }} ]" - - "+ Inventory Changes Detected - [ {{ vars_common_external.changes_detected_inventory }} ]" - - "+ Edge Connections Changes Detected - [ {{ vars_common_external.changes_detected_edge_connections }} ]" - - "+ vPC Peer Changes Detected - [ {{ vars_common_external.changes_detected_vpc_peering }} ]" - - "+ ----- Interfaces -----" - - "+ Interface breakout Changes Detected - [ {{ vars_common_external.changes_detected_interface_breakout }} ]" - - "+ Interface PreProv breakout Changes Detected - [ {{ vars_common_external.changes_detected_interface_breakout_preprov }} ]" - - "+ Interface Access Changes Detected - [ {{ vars_common_external.changes_detected_interface_access }} ]" - - "+ Interface Access PO Changes Detected - [ {{ vars_common_external.changes_detected_interface_access_po }} ]" - - "+ Interface Loopback Changes Detected - [ {{ vars_common_external.changes_detected_interface_loopback }} ]" - - "+ Interface PO Routed Changes Detected - [ {{ vars_common_external.changes_detected_interface_po_routed }} ]" - - "+ Interface Routed Changes Detected - [ {{ vars_common_external.changes_detected_interface_routed }} ]" - - "+ Interface Trunk Changes Detected - [ {{ vars_common_external.changes_detected_interface_trunk }} ]" - - "+ Interface Trunk PO Changes Detected - [ {{ vars_common_external.changes_detected_interface_trunk_po }} ]" - - "+ Sub Interface Routed Changes Detected - [ {{ vars_common_external.changes_detected_sub_interface_routed }} ]" - - "+ ----- All Interfaces -----" - - "+ All Interfaces Changes Detected - [ {{ vars_common_external.changes_detected_interfaces }} ]" - - "+ ----- All Interfaces -----" - - "+ Policy Changes Detected - [ {{ vars_common_external.changes_detected_policy }} ]" - - "+ ----- Run Map -----" - - "+ Run Map Diff Run - [ {{ run_map_read_result.diff_run }} ]" - - "+ Force Run Flag - [ {{ force_run_all }} ]" - - "----------------------------------------------------------------" diff --git a/roles/dtc/common/tasks/sub_main_isn.yml b/roles/dtc/common/tasks/sub_main_isn.yml index 22db91470..93b2827fc 100644 --- a/roles/dtc/common/tasks/sub_main_isn.yml +++ b/roles/dtc/common/tasks/sub_main_isn.yml @@ -170,23 +170,6 @@ - name: Save Local Variables With Namespace Context ansible.builtin.set_fact: vars_common_isn: - changes_detected_fabric: "{{ changes_detected_fabric }}" - changes_detected_edge_connections: "{{ changes_detected_edge_connections }}" - changes_detected_interface_access_po: "{{ changes_detected_interface_access_po }}" - changes_detected_interface_access: "{{ changes_detected_interface_access }}" - changes_detected_interfaces: "{{ changes_detected_interfaces }}" - changes_detected_interface_loopback: "{{ changes_detected_interface_loopback }}" - changes_detected_interface_breakout: "{{ changes_detected_interface_breakout }}" - changes_detected_interface_breakout_preprov: "{{ changes_detected_interface_breakout_preprov }}" - changes_detected_interface_po_routed: "{{ changes_detected_interface_po_routed }}" - changes_detected_interface_routed: "{{ changes_detected_interface_routed }}" - changes_detected_interface_trunk_po: "{{ changes_detected_interface_trunk_po }}" - changes_detected_interface_trunk: "{{ changes_detected_interface_trunk }}" - changes_detected_interface_vpc: "{{ changes_detected_interface_vpc }}" - changes_detected_interface_dot1q: "{{ changes_detected_interface_dot1q }}" - changes_detected_inventory: "{{ changes_detected_inventory }}" - changes_detected_policy: "{{ changes_detected_policy }}" - changes_detected_sub_interface_routed: "{{ changes_detected_sub_interface_routed }}" fabric_config: "{{ fabric_config }}" interface_breakout: "{{ interface_breakout }}" interface_breakout_preprov: "{{ interface_breakout_preprov }}" @@ -207,31 +190,3 @@ sub_interface_routed: "{{ sub_interface_routed }}" updated_inv_config: "{{ updated_inv_config }}" updated_inv_config_no_bootstrap: "{{ updated_inv_config_no_bootstrap }}" - -- name: Run Diff Flags - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ Fabric Changes Detected - [ {{ vars_common_isn.changes_detected_fabric }} ]" - - "+ Inventory Changes Detected - [ {{ vars_common_isn.changes_detected_inventory }} ]" - - "+ ----- Interfaces -----" - - "+ Interface breakout Changes Detected - [ {{ vars_common_isn.changes_detected_interface_breakout }} ]" - - "+ Interface PreProv breakout Changes Detected - [ {{ vars_common_isn.changes_detected_interface_breakout_preprov }} ]" - - "+ Interface vPC Changes Detected - [ {{ vars_common_isn.changes_detected_interface_vpc }} ]" - - "+ Interface Access Changes Detected - [ {{ vars_common_isn.changes_detected_interface_access }} ]" - - "+ Interface Access PO Changes Detected - [ {{ vars_common_isn.changes_detected_interface_access_po }} ]" - - "+ Interface Loopback Changes Detected - [ {{ vars_common_isn.changes_detected_interface_loopback }} ]" - - "+ Interface PO Routed Changes Detected - [ {{ vars_common_isn.changes_detected_interface_po_routed }} ]" - - "+ Interface Routed Changes Detected - [ {{ vars_common_isn.changes_detected_interface_routed }} ]" - - "+ Interface Trunk Changes Detected - [ {{ vars_common_isn.changes_detected_interface_trunk }} ]" - - "+ Interface Trunk PO Changes Detected - [ {{ vars_common_isn.changes_detected_interface_trunk_po }} ]" - - "+ Sub Interface Routed Changes Detected - [ {{ vars_common_isn.changes_detected_sub_interface_routed }} ]" - - "+ ----- All Interfaces -----" - - "+ All Interfaces Changes Detected - [ {{ vars_common_isn.changes_detected_interfaces }} ]" - - "+ ----- All Interfaces -----" - - "+ Policy Changes Detected - [ {{ vars_common_isn.changes_detected_policy }} ]" - - "+ Edge Connection Changes Detected - [ {{ vars_common_isn.changes_detected_edge_connections }} ]" - - "+ ----- Run Map -----" - - "+ Run Map Diff Run - [ {{ run_map_read_result.diff_run }} ]" - - "+ Force Run Flag - [ {{ force_run_all }} ]" - - "----------------------------------------------------------------" diff --git a/roles/dtc/common/tasks/sub_main_msd.yml b/roles/dtc/common/tasks/sub_main_msd.yml index f1c09d880..c5c687a10 100644 --- a/roles/dtc/common/tasks/sub_main_msd.yml +++ b/roles/dtc/common/tasks/sub_main_msd.yml @@ -81,9 +81,6 @@ - name: Save Local Variables With Namespace Context ansible.builtin.set_fact: vars_common_msd: - changes_detected_fabric: "{{ changes_detected_fabric }}" - changes_detected_bgw_anycast_vip: "{{ changes_detected_bgw_anycast_vip }}" - # changes_detected_vrfs and changes_detected_networks must be defaulted back to false # because ansible.builtin.set_fact copmletely rewrites vars_common_msd and we need # to keep alignment with the initialzed false state in common/main.yml. # The proper state will update in create/sub_main_msd.yml as that is where vrfs and networks @@ -96,18 +93,3 @@ # net_config: "{{ net_config }}" # Check with Matt and Pete on how to handle this for MSD # vrf_attach_config: "{{ vrf_attach_config }}" - -- name: Run Diff Flags - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ Fabric Changes Detected - [ {{ vars_common_msd.changes_detected_fabric }} ]" - - "+ BGW Anycast VIP Changes Detected - [ {{ vars_common_msd.changes_detected_bgw_anycast_vip }} ]" - - "+ VRFs Changes Detected - [ {{ vars_common_msd.changes_detected_vrfs }} ]" - - "+ VRFs Changes Detected - [ Known Later, Initialized to False for MSD ]" - - "+ Networks Changes Detected - [ {{ vars_common_msd.changes_detected_networks }} ]" - - "+ Networks Changes Detected - [ Known Later, Initialized to False for MSD ]" - - "+ ----- Run Map -----" - - "+ Run Map Diff Run - [ {{ run_map_read_result.diff_run }} ]" - - "+ Force Run Flag - [ {{ force_run_all }} ]" - - "----------------------------------------------------------------" diff --git a/roles/dtc/common/tasks/sub_main_vxlan.yml b/roles/dtc/common/tasks/sub_main_vxlan.yml index e659c3a2e..66d248e06 100644 --- a/roles/dtc/common/tasks/sub_main_vxlan.yml +++ b/roles/dtc/common/tasks/sub_main_vxlan.yml @@ -219,30 +219,6 @@ - name: Save Local Variables With Namespace Context ansible.builtin.set_fact: vars_common_vxlan: - changes_detected_fabric: "{{ changes_detected_fabric }}" - changes_detected_fabric_links: "{{ changes_detected_fabric_links }}" - changes_detected_edge_connections: "{{ changes_detected_edge_connections }}" - changes_detected_interface_access_po: "{{ changes_detected_interface_access_po }}" - changes_detected_interface_access: "{{ changes_detected_interface_access }}" - changes_detected_interfaces: "{{ changes_detected_interfaces }}" - changes_detected_interface_loopback: "{{ changes_detected_interface_loopback }}" - changes_detected_interface_breakout: "{{ changes_detected_interface_breakout }}" - changes_detected_interface_breakout_preprov: "{{ changes_detected_interface_breakout_preprov }}" - changes_detected_interface_po_routed: "{{ changes_detected_interface_po_routed }}" - changes_detected_interface_routed: "{{ changes_detected_interface_routed }}" - changes_detected_sub_interface_routed: "{{ changes_detected_sub_interface_routed }}" - changes_detected_interface_trunk_po: "{{ changes_detected_interface_trunk_po }}" - changes_detected_interface_trunk: "{{ changes_detected_interface_trunk }}" - changes_detected_interface_vpc: "{{ changes_detected_interface_vpc }}" - changes_detected_interface_dot1q: "{{ changes_detected_interface_dot1q }}" - changes_detected_inventory: "{{ changes_detected_inventory }}" - changes_detected_link_vpc_peering: "{{ changes_detected_link_vpc_peering }}" - changes_detected_networks: "{{ changes_detected_networks }}" - changes_detected_policy: "{{ changes_detected_policy }}" - changes_detected_vpc_peering: "{{ changes_detected_vpc_peering }}" - changes_detected_vpc_domain_id_resource: "{{ changes_detected_vpc_domain_id_resource }}" - changes_detected_vrfs: "{{ changes_detected_vrfs }}" - changes_detected_underlay_ip_address: "{{ changes_detected_underlay_ip_address }}" fabric_config: "{{ fabric_config }}" fabric_links: "{{ fabric_links }}" edge_connections: "{{ edge_connections }}" @@ -275,37 +251,3 @@ vrf_attach_config: "{{ vrf_attach_config }}" underlay_ip_address: "{{ underlay_ip_address }}" underlay_ip_address_diff_result: "{{ underlay_ip_address_diff_result }}" - -- name: Run Diff Flags - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ Fabric Changes Detected - [ {{ vars_common_vxlan.changes_detected_fabric }} ]" - - "+ Inventory Changes Detected - [ {{ vars_common_vxlan.changes_detected_inventory }} ]" - - "+ vPC Link Peer Changes Detected - [ {{ vars_common_vxlan.changes_detected_link_vpc_peering }} ]" - - "+ vPC Peer Changes Detected - [ {{ vars_common_vxlan.changes_detected_vpc_peering }} ]" - - "+ vPC Domain ID Detected - [ {{ vars_common_vxlan.changes_detected_vpc_domain_id_resource }} ]" - - "+ ----- Interfaces -----" - - "+ Interface breakout Changes Detected - [ {{ vars_common_vxlan.changes_detected_interface_breakout }} ]" - - "+ Interface PreProv breakout Changes Detected - [ {{ vars_common_vxlan.changes_detected_interface_breakout_preprov }} ]" - - "+ Interface vPC Changes Detected - [ {{ vars_common_vxlan.changes_detected_interface_vpc }} ]" - - "+ Interface Access Changes Detected - [ {{ vars_common_vxlan.changes_detected_interface_access }} ]" - - "+ Interface Access PO Changes Detected - [ {{ vars_common_vxlan.changes_detected_interface_access_po }} ]" - - "+ Interface Loopback Changes Detected - [ {{ vars_common_vxlan.changes_detected_interface_loopback }} ]" - - "+ Interface PO Routed Changes Detected - [ {{ vars_common_vxlan.changes_detected_interface_po_routed }} ]" - - "+ Interface Routed Changes Detected - [ {{ vars_common_vxlan.changes_detected_interface_routed }} ]" - - "+ Interface Trunk Changes Detected - [ {{ vars_common_vxlan.changes_detected_interface_trunk }} ]" - - "+ Interface Trunk PO Changes Detected - [ {{ vars_common_vxlan.changes_detected_interface_trunk_po }} ]" - - "+ Sub Interface Routed Changes Detected - [ {{ vars_common_vxlan.changes_detected_sub_interface_routed }} ]" - - "+ ----- All Interfaces -----" - - "+ All Interfaces Changes Detected - [ {{ vars_common_vxlan.changes_detected_interfaces }} ]" - - "+ ----- All Interfaces -----" - - "+ VRFs Changes Detected - [ {{ vars_common_vxlan.changes_detected_vrfs }} ]" - - "+ Networks Changes Detected - [ {{ vars_common_vxlan.changes_detected_networks }} ]" - - "+ Policy Changes Detected - [ {{ vars_common_vxlan.changes_detected_policy }} ]" - - "+ Fabric Links Changes Detected - [ {{ vars_common_vxlan.changes_detected_fabric_links }} ]" - - "+ Edge Connections Changes Detected - [ {{ vars_common_vxlan.changes_detected_edge_connections }} ]" - - "+ ----- Run Map -----" - - "+ Run Map Diff Run - [ {{ run_map_read_result.diff_run }} ]" - - "+ Force Run Flag - [ {{ force_run_all }} ]" - - "----------------------------------------------------------------" diff --git a/roles/dtc/common/tasks/vxlan/ndfc_networks.yml b/roles/dtc/common/tasks/vxlan/ndfc_networks.yml index f6539d67f..8e7bcf2a5 100644 --- a/roles/dtc/common/tasks/vxlan/ndfc_networks.yml +++ b/roles/dtc/common/tasks/vxlan/ndfc_networks.yml @@ -84,3 +84,16 @@ when: - file_diff_result.file_data_changed - check_roles['save_previous'] + +- name: Set File Change Flag Based on File Diff Result + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_networks + flag_value: true + delegate_to: localhost + when: + - file_diff_result.file_data_changed + - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml b/roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml index 83efd520e..ce3a33bc3 100644 --- a/roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml +++ b/roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml @@ -85,6 +85,19 @@ - file_diff_result.file_data_changed - check_roles['save_previous'] +- name: Set File Change Flag Based on File Diff Result + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ role_path }}" + operation: "update" + change_flag: changes_detected_vrfs + flag_value: true + delegate_to: localhost + when: + - file_diff_result.file_data_changed + - check_roles['save_previous'] + - name: Set file_name Var for loopback attachments ansible.builtin.set_fact: file_name: "attach_vrfs_loopbacks.yml" diff --git a/roles/dtc/create/tasks/common/interfaces.yml b/roles/dtc/create/tasks/common/interfaces.yml index 36cec9f12..f208ed4dc 100644 --- a/roles/dtc/create/tasks/common/interfaces.yml +++ b/roles/dtc/create/tasks/common/interfaces.yml @@ -73,6 +73,14 @@ when: - run_map_read_result.diff_run is true|bool +- name: Diff Run Feature Status + ansible.builtin.debug: + msg: + - "-------------------------------------------------------------------------" + - "+ Diff Run Feature Status: {{ run_map_read_result.diff_run }}" + - "+ Interface Config List Count: {{ interface_config_list | length }}" + - "-------------------------------------------------------------------------" + - name: Manage Interface All in Nexus Dashboard cisco.dcnm.dcnm_interface: fabric: "{{ MD_Extended.vxlan.fabric.name }}" diff --git a/roles/dtc/create/tasks/main.yml b/roles/dtc/create/tasks/main.yml index af55fdef4..0cb0e888b 100644 --- a/roles/dtc/create/tasks/main.yml +++ b/roles/dtc/create/tasks/main.yml @@ -21,67 +21,97 @@ --- +# - name: Import iBGP VXLAN Fabric Role Tasks +# ansible.builtin.import_tasks: sub_main_vxlan.yml +# when: > +# (MD_Extended.vxlan.fabric.type == 'VXLAN_EVPN') and +# (vars_common_vxlan.changes_detected_fabric) or +# (vars_common_vxlan.changes_detected_inventory) or +# (vars_common_vxlan.changes_detected_vpc_peering) or +# (vars_common_vxlan.changes_detected_interfaces) or +# (vars_common_vxlan.changes_detected_link_vpc_peering) or +# (vars_common_vxlan.changes_detected_vrfs) or +# (vars_common_vxlan.changes_detected_networks) or +# (vars_common_vxlan.changes_detected_policy) or +# (vars_common_vxlan.changes_detected_edge_connections) or +# (vars_common_vxlan.changes_detected_fabric_links) or +# (vars_common_vxlan.changes_detected_underlay_ip_address) or +# (vars_common_vxlan.changes_detected_vpc_domain_id_resource) + +# - name: Import eBGP VXLAN Fabric Role Tasks +# ansible.builtin.import_tasks: sub_main_ebgp_vxlan.yml +# when: > +# (MD_Extended.vxlan.fabric.type == 'eBGP_VXLAN') and +# (vars_common_ebgp_vxlan.changes_detected_fabric) or +# (vars_common_ebgp_vxlan.changes_detected_inventory) or +# (vars_common_ebgp_vxlan.changes_detected_vpc_peering) or +# (vars_common_ebgp_vxlan.changes_detected_link_vpc_peering) or +# (vars_common_ebgp_vxlan.changes_detected_policy) or +# (vars_common_ebgp_vxlan.changes_detected_interfaces) or +# (vars_common_ebgp_vxlan.changes_detected_vrfs) or +# (vars_common_ebgp_vxlan.changes_detected_networks) + +# - name: Import ISN Fabric Role Tasks +# ansible.builtin.import_tasks: sub_main_isn.yml +# when: > +# (MD_Extended.vxlan.fabric.type == 'ISN') and +# (vars_common_isn.changes_detected_fabric) or +# (vars_common_isn.changes_detected_inventory) or +# (vars_common_isn.changes_detected_interfaces) or +# (vars_common_isn.changes_detected_policy) + +# - name: Import MSD Fabric Role Tasks +# ansible.builtin.import_tasks: sub_main_msd.yml +# when: > +# (MD_Extended.vxlan.fabric.type == 'MSD') + +# # Check with Matt and Pete on External Fabrics +# - name: Import External Fabric Role Tasks +# ansible.builtin.import_tasks: sub_main_external.yml +# when: > +# (MD_Extended.vxlan.fabric.type == 'External') and +# (vars_common_external.changes_detected_inventory) or +# (vars_common_external.changes_detected_interfaces) or +# (vars_common_external.changes_detected_fabric) or +# (vars_common_external.changes_detected_interface_access_po) or +# (vars_common_external.changes_detected_interface_access) or +# (vars_common_external.changes_detected_interface_loopback) or +# (vars_common_external.changes_detected_interface_po_routed) or +# (vars_common_external.changes_detected_interface_routed) or +# (vars_common_external.changes_detected_interface_trunk_po) or +# (vars_common_external.changes_detected_interface_trunk) or +# (vars_common_external.changes_detected_sub_interface_routed) or +# (vars_common_external.changes_detected_policy) + +- debug: msg="{{ change_flags }}" + - name: Import iBGP VXLAN Fabric Role Tasks ansible.builtin.import_tasks: sub_main_vxlan.yml - when: > - (MD_Extended.vxlan.fabric.type == 'VXLAN_EVPN') and - (vars_common_vxlan.changes_detected_fabric) or - (vars_common_vxlan.changes_detected_inventory) or - (vars_common_vxlan.changes_detected_vpc_peering) or - (vars_common_vxlan.changes_detected_interfaces) or - (vars_common_vxlan.changes_detected_link_vpc_peering) or - (vars_common_vxlan.changes_detected_vrfs) or - (vars_common_vxlan.changes_detected_networks) or - (vars_common_vxlan.changes_detected_policy) or - (vars_common_vxlan.changes_detected_edge_connections) or - (vars_common_vxlan.changes_detected_fabric_links) or - (vars_common_vxlan.changes_detected_underlay_ip_address) or - (vars_common_vxlan.changes_detected_vpc_domain_id_resource) + when: + - MD_Extended.vxlan.fabric.type == 'VXLAN_EVPN' + - change_flags.changes_detected_any - name: Import eBGP VXLAN Fabric Role Tasks ansible.builtin.import_tasks: sub_main_ebgp_vxlan.yml - when: > - (MD_Extended.vxlan.fabric.type == 'eBGP_VXLAN') and - (vars_common_ebgp_vxlan.changes_detected_fabric) or - (vars_common_ebgp_vxlan.changes_detected_inventory) or - (vars_common_ebgp_vxlan.changes_detected_vpc_peering) or - (vars_common_ebgp_vxlan.changes_detected_link_vpc_peering) or - (vars_common_ebgp_vxlan.changes_detected_policy) or - (vars_common_ebgp_vxlan.changes_detected_interfaces) or - (vars_common_ebgp_vxlan.changes_detected_vrfs) or - (vars_common_ebgp_vxlan.changes_detected_networks) + when: + - MD_Extended.vxlan.fabric.type == 'eBGP_VXLAN' + - change_flags.changes_detected_any - name: Import ISN Fabric Role Tasks ansible.builtin.import_tasks: sub_main_isn.yml - when: > - (MD_Extended.vxlan.fabric.type == 'ISN') and - (vars_common_isn.changes_detected_fabric) or - (vars_common_isn.changes_detected_inventory) or - (vars_common_isn.changes_detected_interfaces) or - (vars_common_isn.changes_detected_policy) + when: + - MD_Extended.vxlan.fabric.type == 'ISN' + - change_flags.changes_detected_any - name: Import MSD Fabric Role Tasks ansible.builtin.import_tasks: sub_main_msd.yml - when: > - (MD_Extended.vxlan.fabric.type == 'MSD') + when: MD_Extended.vxlan.fabric.type == 'MSD' -# Check with Matt and Pete on External Fabrics - name: Import External Fabric Role Tasks ansible.builtin.import_tasks: sub_main_external.yml - when: > - (MD_Extended.vxlan.fabric.type == 'External') and - (vars_common_external.changes_detected_inventory) or - (vars_common_external.changes_detected_interfaces) or - (vars_common_external.changes_detected_fabric) or - (vars_common_external.changes_detected_interface_access_po) or - (vars_common_external.changes_detected_interface_access) or - (vars_common_external.changes_detected_interface_loopback) or - (vars_common_external.changes_detected_interface_po_routed) or - (vars_common_external.changes_detected_interface_routed) or - (vars_common_external.changes_detected_interface_trunk_po) or - (vars_common_external.changes_detected_interface_trunk) or - (vars_common_external.changes_detected_sub_interface_routed) or - (vars_common_external.changes_detected_policy) + when: + - MD_Extended.vxlan.fabric.type == 'External' + - change_flags.changes_detected_any - name: Mark Stage Role Create Completed cisco.nac_dc_vxlan.common.run_map: diff --git a/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml b/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml index 9064b2b13..ad6fae2fa 100644 --- a/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml +++ b/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml @@ -29,6 +29,14 @@ - "----------------------------------------------------------------" tags: "{{ nac_tags.create }}" # Tags defined in roles/common_global/vars/main.yml +- name: VXLAN EBGP FABRIC + ansible.builtin.debug: + msg: + - "----------------------------------------------------------------" + - "+ VXLAN EBGP FABRIC +" + - "----------------------------------------------------------------" + tags: "{{ nac_tags.create }}" # Tags defined in roles/common_global/vars/main.yml + - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using Nexus Dashboard (Direct to Controller)" diff --git a/roles/dtc/create/tasks/sub_main_external.yml b/roles/dtc/create/tasks/sub_main_external.yml index fa53ee952..cf0a05357 100644 --- a/roles/dtc/create/tasks/sub_main_external.yml +++ b/roles/dtc/create/tasks/sub_main_external.yml @@ -29,6 +29,14 @@ - "----------------------------------------------------------------" tags: "{{ nac_tags.create }}" # Tags defined in roles/common_global/vars/main.yml +- name: EXTERNAL FABRIC + ansible.builtin.debug: + msg: + - "----------------------------------------------------------------" + - "+ EXTERNAL FABRIC +" + - "----------------------------------------------------------------" + tags: "{{ nac_tags.create }}" # Tags defined in roles/common_global/vars/main.yml + - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using Nexus Dashboard (Direct to Controller)" diff --git a/roles/dtc/create/tasks/sub_main_isn.yml b/roles/dtc/create/tasks/sub_main_isn.yml index 48a9304ec..edeeb3e9e 100644 --- a/roles/dtc/create/tasks/sub_main_isn.yml +++ b/roles/dtc/create/tasks/sub_main_isn.yml @@ -29,6 +29,14 @@ - "----------------------------------------------------------------" tags: "{{ nac_tags.create }}" # Tags defined in roles/common_global/vars/main.yml +- name: ISN FABRIC + ansible.builtin.debug: + msg: + - "----------------------------------------------------------------" + - "+ ISN FABRIC +" + - "----------------------------------------------------------------" + tags: "{{ nac_tags.create }}" # Tags defined in roles/common_global/vars/main.yml + - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using Nexus Dashboard (Direct to Controller)" diff --git a/roles/dtc/create/tasks/sub_main_msd.yml b/roles/dtc/create/tasks/sub_main_msd.yml index e6c16e951..4638ea054 100644 --- a/roles/dtc/create/tasks/sub_main_msd.yml +++ b/roles/dtc/create/tasks/sub_main_msd.yml @@ -29,6 +29,14 @@ - "----------------------------------------------------------------" tags: "{{ nac_tags.create }}" # Tags defined in roles/common_global/vars/main.yml +- name: VXLAN MSD FABRIC + ansible.builtin.debug: + msg: + - "----------------------------------------------------------------" + - "+ VXLAN MSD FABRIC +" + - "----------------------------------------------------------------" + tags: "{{ nac_tags.create }}" # Tags defined in roles/common_global/vars/main.yml + - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using Nexus Dashboard (Direct to Controller)" diff --git a/roles/dtc/create/tasks/sub_main_vxlan.yml b/roles/dtc/create/tasks/sub_main_vxlan.yml index c924a0490..dc336280d 100644 --- a/roles/dtc/create/tasks/sub_main_vxlan.yml +++ b/roles/dtc/create/tasks/sub_main_vxlan.yml @@ -29,6 +29,14 @@ - "----------------------------------------------------------------" tags: "{{ nac_tags.create }}" # Tags defined in roles/common_global/vars/main.yml +- name: VXLAN IBGP FABRIC + ansible.builtin.debug: + msg: + - "----------------------------------------------------------------" + - "+ VXLAN IBGP FABRIC +" + - "----------------------------------------------------------------" + tags: "{{ nac_tags.create }}" # Tags defined in roles/common_global/vars/main.yml + - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using Nexus Dashboard (Direct to Controller)" diff --git a/roles/dtc/deploy/tasks/main.yml b/roles/dtc/deploy/tasks/main.yml index 25900c8ed..e30f8f425 100644 --- a/roles/dtc/deploy/tasks/main.yml +++ b/roles/dtc/deploy/tasks/main.yml @@ -21,108 +21,140 @@ --- +# - name: Import iBGP VXLAN EVPN Role Tasks +# ansible.builtin.import_tasks: sub_main_vxlan.yml +# tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml +# when: > +# (MD_Extended.vxlan.fabric.type == 'VXLAN_EVPN') and +# (vars_common_vxlan.changes_detected_fabric or +# vars_common_vxlan.changes_detected_fabric_links or +# vars_common_vxlan.changes_detected_interface_access_po or +# vars_common_vxlan.changes_detected_interface_access or +# vars_common_vxlan.changes_detected_interfaces or +# vars_common_vxlan.changes_detected_interface_loopback or +# vars_common_vxlan.changes_detected_interface_po_routed or +# vars_common_vxlan.changes_detected_interface_routed or +# vars_common_vxlan.changes_detected_interface_trunk_po or +# vars_common_vxlan.changes_detected_interface_trunk or +# vars_common_vxlan.changes_detected_interface_vpc or +# vars_common_vxlan.changes_detected_inventory or +# vars_common_vxlan.changes_detected_link_vpc_peering or +# vars_common_vxlan.changes_detected_networks or +# vars_common_vxlan.changes_detected_policy or +# vars_common_vxlan.changes_detected_sub_interface_routed or +# vars_common_vxlan.changes_detected_vpc_peering or +# vars_common_vxlan.changes_detected_vrfs or +# vars_common_vxlan.changes_detected_edge_connections or +# vars_common_vxlan.changes_detected_underlay_ip_address or +# vars_common_vxlan.changes_detected_vpc_domain_id_resource) + +# - name: Import MSD Fabric Role Tasks +# ansible.builtin.import_tasks: sub_main_msd.yml +# tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml +# when: > +# (MD_Extended.vxlan.fabric.type == 'MSD') and +# (vars_common_msd.changes_detected_fabric or +# vars_common_msd.changes_detected_vrfs or +# vars_common_msd.changes_detected_networks or +# (child_fabrics_vrfs_networks_changed is defined and child_fabrics_vrfs_networks_changed | length > 0) or +# vars_common_msd.changes_detected_bgw_anycast_vip) + +# - name: Import ISN Fabric Role Tasks +# ansible.builtin.import_tasks: sub_main_isn.yml +# tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml +# when: > +# (MD_Extended.vxlan.fabric.type == 'ISN') and +# (vars_common_isn.changes_detected_fabric or +# vars_common_isn.changes_detected_interface_access_po or +# vars_common_isn.changes_detected_interface_access or +# vars_common_isn.changes_detected_interfaces or +# vars_common_isn.changes_detected_interface_loopback or +# vars_common_isn.changes_detected_interface_po_routed or +# vars_common_isn.changes_detected_interface_routed or +# vars_common_isn.changes_detected_interface_trunk_po or +# vars_common_isn.changes_detected_interface_trunk or +# vars_common_isn.changes_detected_interface_vpc or +# vars_common_isn.changes_detected_inventory or +# vars_common_isn.changes_detected_policy or +# vars_common_isn.changes_detected_sub_interface_routed) + +# - name: Import External Fabric Role Tasks +# ansible.builtin.import_tasks: sub_main_external.yml +# tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml +# when: > +# (MD_Extended.vxlan.fabric.type == 'External') and +# (vars_common_external.changes_detected_fabric or +# vars_common_external.changes_detected_interface_access_po or +# vars_common_external.changes_detected_interface_access or +# vars_common_external.changes_detected_interfaces or +# vars_common_external.changes_detected_interface_loopback or +# vars_common_external.changes_detected_interface_po_routed or +# vars_common_external.changes_detected_interface_routed or +# vars_common_external.changes_detected_interface_trunk_po or +# vars_common_external.changes_detected_interface_trunk or +# vars_common_external.changes_detected_interface_vpc or +# vars_common_external.changes_detected_inventory or +# vars_common_external.changes_detected_policy or +# vars_common_external.changes_detected_sub_interface_routed) + +# - name: Import Role Tasks +# ansible.builtin.import_tasks: sub_main_ebgp_vxlan.yml +# tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml +# when: > +# (MD_Extended.vxlan.fabric.type == 'eBGP_VXLAN') and +# (vars_common_ebgp_vxlan.changes_detected_fabric or +# vars_common_ebgp_vxlan.changes_detected_interface_access or +# vars_common_ebgp_vxlan.changes_detected_interface_access_po or +# vars_common_ebgp_vxlan.changes_detected_interface_trunk or +# vars_common_ebgp_vxlan.changes_detected_interface_trunk_po or +# vars_common_ebgp_vxlan.changes_detected_interface_vpc or +# vars_common_ebgp_vxlan.changes_detected_interface_po_routed or +# vars_common_ebgp_vxlan.changes_detected_interface_routed or +# vars_common_ebgp_vxlan.changes_detected_sub_interface_routed or +# vars_common_ebgp_vxlan.changes_detected_interfaces or +# vars_common_ebgp_vxlan.changes_detected_interface_loopback or +# vars_common_ebgp_vxlan.changes_detected_inventory or +# vars_common_ebgp_vxlan.changes_detected_vpc_peering or +# vars_common_ebgp_vxlan.changes_detected_link_vpc_peering or +# vars_common_ebgp_vxlan.changes_detected_interface_vpc or +# vars_common_ebgp_vxlan.changes_detected_policy or +# vars_common_ebgp_vxlan.changes_detected_vrfs or +# vars_common_ebgp_vxlan.changes_detected_networks) + - name: Import iBGP VXLAN EVPN Role Tasks ansible.builtin.import_tasks: sub_main_vxlan.yml tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml - when: > - (MD_Extended.vxlan.fabric.type == 'VXLAN_EVPN') and - (vars_common_vxlan.changes_detected_fabric or - vars_common_vxlan.changes_detected_fabric_links or - vars_common_vxlan.changes_detected_interface_access_po or - vars_common_vxlan.changes_detected_interface_access or - vars_common_vxlan.changes_detected_interfaces or - vars_common_vxlan.changes_detected_interface_loopback or - vars_common_vxlan.changes_detected_interface_po_routed or - vars_common_vxlan.changes_detected_interface_routed or - vars_common_vxlan.changes_detected_interface_trunk_po or - vars_common_vxlan.changes_detected_interface_trunk or - vars_common_vxlan.changes_detected_interface_vpc or - vars_common_vxlan.changes_detected_inventory or - vars_common_vxlan.changes_detected_link_vpc_peering or - vars_common_vxlan.changes_detected_networks or - vars_common_vxlan.changes_detected_policy or - vars_common_vxlan.changes_detected_sub_interface_routed or - vars_common_vxlan.changes_detected_vpc_peering or - vars_common_vxlan.changes_detected_vrfs or - vars_common_vxlan.changes_detected_edge_connections or - vars_common_vxlan.changes_detected_underlay_ip_address or - vars_common_vxlan.changes_detected_vpc_domain_id_resource) + when: + - MD_Extended.vxlan.fabric.type == 'VXLAN_EVPN' + - change_flags.changes_detected_any - name: Import MSD Fabric Role Tasks ansible.builtin.import_tasks: sub_main_msd.yml tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml - when: > - (MD_Extended.vxlan.fabric.type == 'MSD') and - (vars_common_msd.changes_detected_fabric or - vars_common_msd.changes_detected_vrfs or - vars_common_msd.changes_detected_networks or - (child_fabrics_vrfs_networks_changed is defined and child_fabrics_vrfs_networks_changed | length > 0) or - vars_common_msd.changes_detected_bgw_anycast_vip) + when: + - MD_Extended.vxlan.fabric.type == 'MSD' + - change_flags.changes_detected_any - name: Import ISN Fabric Role Tasks ansible.builtin.import_tasks: sub_main_isn.yml tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml - when: > - (MD_Extended.vxlan.fabric.type == 'ISN') and - (vars_common_isn.changes_detected_fabric or - vars_common_isn.changes_detected_interface_access_po or - vars_common_isn.changes_detected_interface_access or - vars_common_isn.changes_detected_interfaces or - vars_common_isn.changes_detected_interface_loopback or - vars_common_isn.changes_detected_interface_po_routed or - vars_common_isn.changes_detected_interface_routed or - vars_common_isn.changes_detected_interface_trunk_po or - vars_common_isn.changes_detected_interface_trunk or - vars_common_isn.changes_detected_interface_vpc or - vars_common_isn.changes_detected_inventory or - vars_common_isn.changes_detected_policy or - vars_common_isn.changes_detected_sub_interface_routed) + when: + - MD_Extended.vxlan.fabric.type == 'ISN' + - change_flags.changes_detected_any - name: Import External Fabric Role Tasks ansible.builtin.import_tasks: sub_main_external.yml tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml - when: > - (MD_Extended.vxlan.fabric.type == 'External') and - (vars_common_external.changes_detected_fabric or - vars_common_external.changes_detected_interface_access_po or - vars_common_external.changes_detected_interface_access or - vars_common_external.changes_detected_interfaces or - vars_common_external.changes_detected_interface_loopback or - vars_common_external.changes_detected_interface_po_routed or - vars_common_external.changes_detected_interface_routed or - vars_common_external.changes_detected_interface_trunk_po or - vars_common_external.changes_detected_interface_trunk or - vars_common_external.changes_detected_interface_vpc or - vars_common_external.changes_detected_inventory or - vars_common_external.changes_detected_policy or - vars_common_external.changes_detected_sub_interface_routed) + when: + - MD_Extended.vxlan.fabric.type == 'External' + - change_flags.changes_detected_any - name: Import Role Tasks ansible.builtin.import_tasks: sub_main_ebgp_vxlan.yml tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml - when: > - (MD_Extended.vxlan.fabric.type == 'eBGP_VXLAN') and - (vars_common_ebgp_vxlan.changes_detected_fabric or - vars_common_ebgp_vxlan.changes_detected_interface_access or - vars_common_ebgp_vxlan.changes_detected_interface_access_po or - vars_common_ebgp_vxlan.changes_detected_interface_trunk or - vars_common_ebgp_vxlan.changes_detected_interface_trunk_po or - vars_common_ebgp_vxlan.changes_detected_interface_vpc or - vars_common_ebgp_vxlan.changes_detected_interface_po_routed or - vars_common_ebgp_vxlan.changes_detected_interface_routed or - vars_common_ebgp_vxlan.changes_detected_sub_interface_routed or - vars_common_ebgp_vxlan.changes_detected_interfaces or - vars_common_ebgp_vxlan.changes_detected_interface_loopback or - vars_common_ebgp_vxlan.changes_detected_inventory or - vars_common_ebgp_vxlan.changes_detected_vpc_peering or - vars_common_ebgp_vxlan.changes_detected_link_vpc_peering or - vars_common_ebgp_vxlan.changes_detected_interface_vpc or - vars_common_ebgp_vxlan.changes_detected_policy or - vars_common_ebgp_vxlan.changes_detected_vrfs or - vars_common_ebgp_vxlan.changes_detected_networks) - -# Additional conditions to be added when needed: -# vars_common_ebgp_vxlan.changes_detected_fabric_links or + when: + - MD_Extended.vxlan.fabric.type == 'eBGP_VXLAN' + - change_flags.changes_detected_any - name: Mark Stage Role Deploy Completed cisco.nac_dc_vxlan.common.run_map: diff --git a/roles/dtc/deploy/tasks/sub_main_ebgp_vxlan.yml b/roles/dtc/deploy/tasks/sub_main_ebgp_vxlan.yml index 922f9e523..d43d102a9 100644 --- a/roles/dtc/deploy/tasks/sub_main_ebgp_vxlan.yml +++ b/roles/dtc/deploy/tasks/sub_main_ebgp_vxlan.yml @@ -28,6 +28,13 @@ - "+ Calling Role - [cisco.nac_dc_vxlan.dtc.deploy] +" - "----------------------------------------------------------------" +- name: VXLAN EBGP FABRIC + ansible.builtin.debug: + msg: + - "----------------------------------------------------------------" + - "+ VXLAN EBGP FABRIC +" + - "----------------------------------------------------------------" + - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using NDFC (Direct to Controller)" diff --git a/roles/dtc/deploy/tasks/sub_main_external.yml b/roles/dtc/deploy/tasks/sub_main_external.yml index fe77fbbaa..6c5d31b11 100644 --- a/roles/dtc/deploy/tasks/sub_main_external.yml +++ b/roles/dtc/deploy/tasks/sub_main_external.yml @@ -28,6 +28,13 @@ - "+ Calling Role - [cisco.nac_dc_vxlan.dtc.deploy] +" - "----------------------------------------------------------------" +- name: External FABRIC + ansible.builtin.debug: + msg: + - "----------------------------------------------------------------" + - "+ External FABRIC +" + - "----------------------------------------------------------------" + - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using NDFC (Direct to Controller)" diff --git a/roles/dtc/deploy/tasks/sub_main_isn.yml b/roles/dtc/deploy/tasks/sub_main_isn.yml index c1bbe3b9a..0ed54c76c 100644 --- a/roles/dtc/deploy/tasks/sub_main_isn.yml +++ b/roles/dtc/deploy/tasks/sub_main_isn.yml @@ -28,6 +28,13 @@ - "+ Calling Role - [cisco.nac_dc_vxlan.dtc.deploy] +" - "----------------------------------------------------------------" +- name: ISN FABRIC + ansible.builtin.debug: + msg: + - "----------------------------------------------------------------" + - "+ ISN FABRIC +" + - "----------------------------------------------------------------" + - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using NDFC (Direct to Controller)" diff --git a/roles/dtc/deploy/tasks/sub_main_msd.yml b/roles/dtc/deploy/tasks/sub_main_msd.yml index 7df425ac1..d104aac10 100644 --- a/roles/dtc/deploy/tasks/sub_main_msd.yml +++ b/roles/dtc/deploy/tasks/sub_main_msd.yml @@ -28,6 +28,13 @@ - "+ Calling Role - [cisco.nac_dc_vxlan.dtc.deploy] +" - "----------------------------------------------------------------" +- name: MSD FABRIC + ansible.builtin.debug: + msg: + - "----------------------------------------------------------------" + - "+ MSD FABRIC +" + - "----------------------------------------------------------------" + - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using NDFC (Direct to Controller)" diff --git a/roles/dtc/deploy/tasks/sub_main_vxlan.yml b/roles/dtc/deploy/tasks/sub_main_vxlan.yml index 788e4e046..02a5177e1 100644 --- a/roles/dtc/deploy/tasks/sub_main_vxlan.yml +++ b/roles/dtc/deploy/tasks/sub_main_vxlan.yml @@ -28,6 +28,13 @@ - "+ Calling Role - [cisco.nac_dc_vxlan.dtc.deploy] +" - "----------------------------------------------------------------" +- name: VXLAN IBGP FABRIC + ansible.builtin.debug: + msg: + - "----------------------------------------------------------------" + - "+ VXLAN IBGP FABRIC +" + - "----------------------------------------------------------------" + - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using NDFC (Direct to Controller)" diff --git a/roles/dtc/remove/tasks/common/interfaces.yml b/roles/dtc/remove/tasks/common/interfaces.yml index 24f1e4766..e371b35c3 100644 --- a/roles/dtc/remove/tasks/common/interfaces.yml +++ b/roles/dtc/remove/tasks/common/interfaces.yml @@ -52,6 +52,13 @@ - switch_list.response.DATA | length > 0 - (interface_delete_mode is defined) and (interface_delete_mode is true|bool) +- name: Diff Run Feature Status + ansible.builtin.debug: + msg: + - "-------------------------------------------------------------------------" + - "+ Diff Run Feature Status: {{ run_map_read_result.diff_run }}" + - "-------------------------------------------------------------------------" + # ----------------------------------------------------------------------------- # Remove Interfaces Using Diff Run Framework # ----------------------------------------------------------------------------- @@ -61,7 +68,7 @@ # previous run must be non-zero. # - The diff_run feature must be active # Combination of the (diff_run flag and force_run_all_flag state) -- name: Remove Unmanaged Fabric Interfaces in Nexus Dashboard - Diff Run True +- name: Remove Unmanaged Fabric Interfaces in Nexus Dashboard - Diff Run Feature Active cisco.dcnm.dcnm_interface: fabric: "{{ MD_Extended.vxlan.fabric.name }}" state: deleted @@ -81,11 +88,12 @@ # ----------------------------------------------------------------------------- # Remove Interfaces Default Mode # ----------------------------------------------------------------------------- -- name: Remove Unmanaged Fabric Interfaces in Nexus Dashboard - Diff Run False +- name: Remove Unmanaged Fabric Interfaces in Nexus Dashboard - Diff Run Feature Disabled cisco.dcnm.dcnm_interface: fabric: "{{ MD_Extended.vxlan.fabric.name }}" state: overridden config: "{{ vars_common_local.interface_all }}" + # Might need to set this back to true to keep default behavior deploy: false vars: ansible_command_timeout: 3000 diff --git a/roles/dtc/remove/tasks/main.yml b/roles/dtc/remove/tasks/main.yml index 418418834..116c3e050 100644 --- a/roles/dtc/remove/tasks/main.yml +++ b/roles/dtc/remove/tasks/main.yml @@ -21,20 +21,73 @@ --- +# - name: Import iBGP VXLAN Fabric Role Tasks +# ansible.builtin.import_tasks: sub_main_vxlan.yml +# # Check with Matt on changes_detected_policy here +# # Was not there previously +# when: > +# (MD_Extended.vxlan.fabric.type == 'VXLAN_EVPN') and +# (vars_common_vxlan.changes_detected_fabric_links or +# vars_common_vxlan.changes_detected_interfaces or +# vars_common_vxlan.changes_detected_inventory or +# vars_common_vxlan.changes_detected_networks or +# vars_common_vxlan.changes_detected_policy or +# vars_common_vxlan.changes_detected_vpc_peering or +# vars_common_vxlan.changes_detected_vrfs or +# vars_common_vxlan.changes_detected_edge_connections) + +# - name: Import MSD Fabric Role Tasks +# ansible.builtin.import_tasks: sub_main_msd.yml +# when: > +# MD_Extended.vxlan.fabric.type == 'MSD' +# # Current implementation has to leverage the changes_detected flags +# # in the sub_main files to determine if the tasks should be run + +# - name: Import ISN Fabric Role Tasks +# ansible.builtin.import_tasks: sub_main_isn.yml +# when: > +# (MD_Extended.vxlan.fabric.type == 'ISN') and +# (vars_common_isn.changes_detected_interfaces or +# vars_common_isn.changes_detected_inventory or +# vars_common_isn.changes_detected_policy or +# vars_common_isn.changes_detected_edge_connections) + +# - name: Import External Fabric Role Tasks +# ansible.builtin.import_tasks: sub_main_external.yml +# when: > +# (MD_Extended.vxlan.fabric.type == 'External') and +# (vars_common_external.changes_detected_interfaces or +# vars_common_external.changes_detected_inventory or +# vars_common_external.changes_detected_policy or +# vars_common_external.changes_detected_edge_connections) + +# - name: Import eBGP Role Tasks +# ansible.builtin.import_tasks: sub_main_ebgp_vxlan.yml +# # Check with Matt on changes_detected_policy here +# # Was not there previously +# when: > +# (MD_Extended.vxlan.fabric.type == 'eBGP_VXLAN') and +# (vars_common_ebgp_vxlan.changes_detected_fabric_links or +# vars_common_ebgp_vxlan.changes_detected_vpc_peering or +# vars_common_ebgp_vxlan.changes_detected_vrfs or +# vars_common_ebgp_vxlan.changes_detected_interfaces or +# vars_common_ebgp_vxlan.changes_detected_policy or +# vars_common_ebgp_vxlan.changes_detected_inventory or +# vars_common_ebgp_vxlan.changes_detected_networks) +# # Additional conditions to be added when needed: + + + + + + - name: Import iBGP VXLAN Fabric Role Tasks ansible.builtin.import_tasks: sub_main_vxlan.yml # Check with Matt on changes_detected_policy here # Was not there previously - when: > - (MD_Extended.vxlan.fabric.type == 'VXLAN_EVPN') and - (vars_common_vxlan.changes_detected_fabric_links or - vars_common_vxlan.changes_detected_interfaces or - vars_common_vxlan.changes_detected_inventory or - vars_common_vxlan.changes_detected_networks or - vars_common_vxlan.changes_detected_policy or - vars_common_vxlan.changes_detected_vpc_peering or - vars_common_vxlan.changes_detected_vrfs or - vars_common_vxlan.changes_detected_edge_connections) + when: + - MD_Extended.vxlan.fabric.type == 'VXLAN_EVPN' + - change_flags.changes_detected_any - name: Import MSD Fabric Role Tasks ansible.builtin.import_tasks: sub_main_msd.yml @@ -45,45 +98,34 @@ - name: Import ISN Fabric Role Tasks ansible.builtin.import_tasks: sub_main_isn.yml - when: > - (MD_Extended.vxlan.fabric.type == 'ISN') and - (vars_common_isn.changes_detected_interfaces or - vars_common_isn.changes_detected_inventory or - vars_common_isn.changes_detected_policy or - vars_common_isn.changes_detected_edge_connections) + when: + - MD_Extended.vxlan.fabric.type == 'ISN' + - change_flags.changes_detected_any - name: Import External Fabric Role Tasks ansible.builtin.import_tasks: sub_main_external.yml - when: > - (MD_Extended.vxlan.fabric.type == 'External') and - (vars_common_external.changes_detected_interfaces or - vars_common_external.changes_detected_inventory or - vars_common_external.changes_detected_policy or - vars_common_external.changes_detected_edge_connections) + when: + - MD_Extended.vxlan.fabric.type == 'External' + - change_flags.changes_detected_any - name: Import eBGP Role Tasks ansible.builtin.import_tasks: sub_main_ebgp_vxlan.yml # Check with Matt on changes_detected_policy here # Was not there previously - when: > - (MD_Extended.vxlan.fabric.type == 'eBGP_VXLAN') and - (vars_common_ebgp_vxlan.changes_detected_fabric_links or - vars_common_ebgp_vxlan.changes_detected_vpc_peering or - vars_common_ebgp_vxlan.changes_detected_vrfs or - vars_common_ebgp_vxlan.changes_detected_interfaces or - vars_common_ebgp_vxlan.changes_detected_policy or - vars_common_ebgp_vxlan.changes_detected_inventory or - vars_common_ebgp_vxlan.changes_detected_networks) - # Additional conditions to be added when needed: + when: + - MD_Extended.vxlan.fabric.type == 'eBGP_VXLAN' + - change_flags.changes_detected_any - name: Log Stage Remove Without Deploy Setting ansible.builtin.debug: - msg: "Stage Remove Without Deploy Is {{ stage_remove }}" + msg: + - "Stage Remove Without Deploy Is {{ stage_remove }}" - name: Deploy Remove Changes ansible.builtin.include_role: name: cisco.nac_dc_vxlan.dtc.deploy - when: stage_remove is false|bool + when: + - stage_remove is false|bool - name: Mark Stage Role Remove Completed cisco.nac_dc_vxlan.common.run_map: diff --git a/roles/dtc/remove/tasks/sub_main_ebgp_vxlan.yml b/roles/dtc/remove/tasks/sub_main_ebgp_vxlan.yml index 2326c290b..11a273f16 100644 --- a/roles/dtc/remove/tasks/sub_main_ebgp_vxlan.yml +++ b/roles/dtc/remove/tasks/sub_main_ebgp_vxlan.yml @@ -28,6 +28,14 @@ - "----------------------------------------------------------------" tags: "{{ nac_tags.remove }}" # Tags defined in roles/common_global/vars/main.yml +- name: VXLAN EBGP FABRIC + ansible.builtin.debug: + msg: + - "----------------------------------------------------------------" + - "+ VXLAN EBGP FABRIC +" + - "----------------------------------------------------------------" + tags: "{{ nac_tags.remove }}" # Tags defined in roles/common_global/vars/main.yml + - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using Nexus Dashboard (Direct to Controller)" diff --git a/roles/dtc/remove/tasks/sub_main_external.yml b/roles/dtc/remove/tasks/sub_main_external.yml index 1e23e0a74..b1ed2b661 100644 --- a/roles/dtc/remove/tasks/sub_main_external.yml +++ b/roles/dtc/remove/tasks/sub_main_external.yml @@ -28,6 +28,14 @@ - "----------------------------------------------------------------" tags: "{{ nac_tags.remove }}" # Tags defined in roles/common_global/vars/main.yml +- name: External FABRIC + ansible.builtin.debug: + msg: + - "----------------------------------------------------------------" + - "+ External FABRIC +" + - "----------------------------------------------------------------" + tags: "{{ nac_tags.remove }}" # Tags defined in roles/common_global/vars/main.yml + - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using Nexus Dashboard (Direct to Controller)" diff --git a/roles/dtc/remove/tasks/sub_main_isn.yml b/roles/dtc/remove/tasks/sub_main_isn.yml index 2a15e1b34..214c74a18 100644 --- a/roles/dtc/remove/tasks/sub_main_isn.yml +++ b/roles/dtc/remove/tasks/sub_main_isn.yml @@ -28,6 +28,14 @@ - "----------------------------------------------------------------" tags: "{{ nac_tags.remove }}" # Tags defined in roles/common_global/vars/main.yml +- name: ISN FABRIC + ansible.builtin.debug: + msg: + - "----------------------------------------------------------------" + - "+ ISN FABRIC +" + - "----------------------------------------------------------------" + tags: "{{ nac_tags.remove }}" # Tags defined in roles/common_global/vars/main.yml + - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using Nexus Dashboard (Direct to Controller)" diff --git a/roles/dtc/remove/tasks/sub_main_msd.yml b/roles/dtc/remove/tasks/sub_main_msd.yml index 98bba072e..6a9b0d525 100644 --- a/roles/dtc/remove/tasks/sub_main_msd.yml +++ b/roles/dtc/remove/tasks/sub_main_msd.yml @@ -28,6 +28,14 @@ - "----------------------------------------------------------------" tags: "{{ nac_tags.remove }}" # Tags defined in roles/common_global/vars/main.yml +- name: MSD FABRIC + ansible.builtin.debug: + msg: + - "----------------------------------------------------------------" + - "+ MSD FABRIC +" + - "----------------------------------------------------------------" + tags: "{{ nac_tags.remove }}" # Tags defined in roles/common_global/vars/main.yml + - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using Nexus Dashboard (Direct to Controller)" diff --git a/roles/dtc/remove/tasks/sub_main_vxlan.yml b/roles/dtc/remove/tasks/sub_main_vxlan.yml index cf1d6a38e..b33cfb7bd 100644 --- a/roles/dtc/remove/tasks/sub_main_vxlan.yml +++ b/roles/dtc/remove/tasks/sub_main_vxlan.yml @@ -28,6 +28,14 @@ - "----------------------------------------------------------------" tags: "{{ nac_tags.remove }}" # Tags defined in roles/common_global/vars/main.yml +- name: VXLAN IBGP FABRIC + ansible.builtin.debug: + msg: + - "----------------------------------------------------------------" + - "+ VXLAN IBGP FABRIC +" + - "----------------------------------------------------------------" + tags: "{{ nac_tags.remove }}" # Tags defined in roles/common_global/vars/main.yml + - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using Nexus Dashboard (Direct to Controller)" From 50ca6067cf797855b69e230dd174e29752827d0e Mon Sep 17 00:00:00 2001 From: mwiebe Date: Mon, 6 Oct 2025 19:45:51 -0400 Subject: [PATCH 21/65] Update changes_detected flags --- .../create/tasks/common/devices_discovery.yml | 10 +++++----- .../create/tasks/common_vxlan/vrfs_networks.yml | 6 +++--- roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml | 12 ++++++------ roles/dtc/create/tasks/sub_main_external.yml | 12 ++++++------ roles/dtc/create/tasks/sub_main_isn.yml | 10 +++++----- roles/dtc/create/tasks/sub_main_msd.yml | 4 ++-- roles/dtc/create/tasks/sub_main_vxlan.yml | 16 ++++++++-------- roles/dtc/remove/tasks/sub_main_ebgp_vxlan.yml | 12 ++++++------ roles/dtc/remove/tasks/sub_main_external.yml | 10 +++++----- roles/dtc/remove/tasks/sub_main_isn.yml | 8 ++++---- roles/dtc/remove/tasks/sub_main_vxlan.yml | 16 ++++++++-------- 11 files changed, 58 insertions(+), 58 deletions(-) diff --git a/roles/dtc/create/tasks/common/devices_discovery.yml b/roles/dtc/create/tasks/common/devices_discovery.yml index 6b180f2de..aca1fcff3 100644 --- a/roles/dtc/create/tasks/common/devices_discovery.yml +++ b/roles/dtc/create/tasks/common/devices_discovery.yml @@ -58,7 +58,7 @@ ansible_connect_timeout: 3000 when: - MD_Extended.vxlan.topology.switches | length > 0 - - vars_common_local.changes_detected_inventory + - change_flags.changes_detected_inventory - debug: msg="{{ vars_common_vxlan.underlay_ip_address_diff_result.updated }}" - debug: msg="{{ vars_common_vxlan.underlay_ip_address_diff_result.updated | length }}" @@ -76,8 +76,8 @@ when: - MD_Extended.vxlan.underlay.general.manual_underlay_allocation is defined - MD_Extended.vxlan.underlay.general.manual_underlay_allocation - # - (vars_common_local.changes_detected_underlay_ip_address is defined and vars_common_local.changes_detected_underlay_ip_address) - - (vars_common_local.underlay_ip_address_diff_result is defined and vars_common_local.underlay_ip_address_diff_result.updated | length > 0) + # - (change_flags.changes_detected_underlay_ip_address is defined and change_flags.changes_detected_underlay_ip_address) + - (change_flags.underlay_ip_address_diff_result is defined and change_flags.underlay_ip_address_diff_result.updated | length > 0) # With the addition of the Allocate Underlay IP Address change above we # cannot call cisco.dcnm.dcnm_inventory with save: true until after @@ -95,8 +95,8 @@ ansible_connect_timeout: 3000 when: - MD_Extended.vxlan.topology.switches | length > 0 - - vars_common_local.changes_detected_inventory or - (vars_common_local.changes_detected_underlay_ip_address is defined and vars_common_local.changes_detected_underlay_ip_address) + - change_flags.changes_detected_inventory or + (change_flags.changes_detected_underlay_ip_address is defined and change_flags.changes_detected_underlay_ip_address) - name: Create List of Switch Serial Numbers from Data Model ansible.builtin.set_fact: diff --git a/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml b/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml index 2e09cc44f..9d436a6bf 100644 --- a/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml +++ b/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml @@ -75,7 +75,7 @@ when: - MD_Extended.vxlan.overlay.vrfs is defined - MD_Extended.vxlan.overlay.vrfs - - vars_common_local.changes_detected_vrfs + - change_flags.changes_detected_vrfs - not is_active_child_fabric # -------------------------------------------------------------------- @@ -89,7 +89,7 @@ when: - MD_Extended.vxlan.overlay.vrfs is defined - MD_Extended.vxlan.overlay.vrfs - - vars_common_local.changes_detected_vrfs + - change_flags.changes_detected_vrfs - not is_active_child_fabric - name: Fail If Current Fabric is Part of Multisite And Attempting to Manage Networks @@ -111,5 +111,5 @@ when: - MD_Extended.vxlan.overlay.networks is defined - MD_Extended.vxlan.overlay.networks - - vars_common_local.changes_detected_networks + - change_flags.changes_detected_networks - not is_active_child_fabric diff --git a/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml b/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml index ad6fae2fa..99ec77a22 100644 --- a/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml +++ b/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml @@ -48,21 +48,21 @@ - MD_Extended.vxlan.fabric.name is defined - MD_Extended.vxlan.fabric.type == "eBGP_VXLAN" - MD_Extended.vxlan.global.ebgp is defined - - vars_common_ebgp_vxlan.changes_detected_fabric + - change_flags.changes_detected_fabric tags: "{{ nac_tags.create_fabric }}" - name: Manage eBGP VXLAN Fabric Switches in Nexus Dashboard ansible.builtin.import_tasks: common/devices.yml when: - MD_Extended.vxlan.topology.switches | length > 0 - - vars_common_ebgp_vxlan.changes_detected_inventory + - change_flags.changes_detected_inventory tags: "{{ nac_tags.create_switches }}" - name: Manage eBGP VXLAN vPC Peering in Nexus Dashboard ansible.builtin.import_tasks: common/vpc_peering.yml when: - MD_Extended.vxlan.topology.vpc_peers | length > 0 - - vars_common_ebgp_vxlan.changes_detected_vpc_peering + - change_flags.changes_detected_vpc_peering tags: "{{ nac_tags.create_vpc_peers }}" - name: Config-Save Block to Propagate vPC Changes to eBGP VXLAN Fabric in Nexus Dashboard @@ -83,7 +83,7 @@ ansible.builtin.import_tasks: common/interfaces.yml when: - (MD_Extended.vxlan.topology.interfaces.modes.all.count >0) and (MD_Extended.vxlan.topology.switches | length > 0) - - vars_common_ebgp_vxlan.changes_detected_interfaces + - change_flags.changes_detected_interfaces tags: "{{ nac_tags.create_interfaces }}" - name: Manage eBGP VXLAN Fabric VRFs and Networks in Nexus Dashboard @@ -91,12 +91,12 @@ when: - MD_Extended.vxlan.overlay is defined - MD_Extended.vxlan.topology.switches | length > 0 - - vars_common_ebgp_vxlan.changes_detected_vrfs or vars_common_ebgp_vxlan.changes_detected_networks + - change_flags.changes_detected_vrfs or change_flags.changes_detected_networks tags: "{{ nac_tags.create_vrfs_networks }}" - name: Manage eBGP VXLAN Fabric Policies in Nexus Dashboard ansible.builtin.import_tasks: common/policies.yml when: - (MD_Extended.vxlan.policy is defined) and (MD_Extended.vxlan.policy.policies | length > 0) - - vars_common_ebgp_vxlan.changes_detected_policy + - change_flags.changes_detected_policy tags: "{{ nac_tags.create_policy }}" diff --git a/roles/dtc/create/tasks/sub_main_external.yml b/roles/dtc/create/tasks/sub_main_external.yml index cf0a05357..e19043059 100644 --- a/roles/dtc/create/tasks/sub_main_external.yml +++ b/roles/dtc/create/tasks/sub_main_external.yml @@ -48,21 +48,21 @@ - MD_Extended.vxlan.fabric.name is defined - MD_Extended.vxlan.fabric.type == "External" - MD_Extended.vxlan.global.external is defined - - vars_common_external.changes_detected_fabric + - change_flags.changes_detected_fabric tags: "{{ nac_tags.create_fabric }}" - name: Manage External Fabric Switches in Nexus Dashboard ansible.builtin.import_tasks: common/devices.yml when: - MD_Extended.vxlan.topology.switches | length > 0 - - vars_common_external.changes_detected_inventory + - change_flags.changes_detected_inventory tags: "{{ nac_tags.create_switches }}" - name: Manage NDFC External VPC Peering ansible.builtin.import_tasks: common/vpc_peering.yml when: - MD_Extended.vxlan.topology.vpc_peers | length > 0 - - vars_common_external.changes_detected_vpc_peering + - change_flags.changes_detected_vpc_peering tags: "{{ nac_tags.create_vpc_peers }}" @@ -70,19 +70,19 @@ ansible.builtin.import_tasks: common/edge_connections.yml when: - MD_Extended.vxlan.topology.edge_connections | length > 0 - - changes_detected_edge_connections + - change_flags.changes_detected_edge_connections tags: "{{ nac_tags.create_links }}" - name: Manage External Fabric Interfaces in Nexus Dashboard ansible.builtin.import_tasks: common/interfaces.yml when: - (MD_Extended.vxlan.topology.interfaces.modes.all.count >0) and (MD_Extended.vxlan.topology.switches | length > 0) - - vars_common_external.changes_detected_interfaces + - change_flags.changes_detected_interfaces tags: "{{ nac_tags.create_interfaces }}" - name: Manage External Fabric Policies in Nexus Dashboard ansible.builtin.import_tasks: common/policies.yml when: - (MD_Extended.vxlan.policy is defined) and (MD_Extended.vxlan.policy.policies | length > 0) - - vars_common_external.changes_detected_policy + - change_flags.changes_detected_policy tags: "{{ nac_tags.create_policy }}" diff --git a/roles/dtc/create/tasks/sub_main_isn.yml b/roles/dtc/create/tasks/sub_main_isn.yml index edeeb3e9e..532540093 100644 --- a/roles/dtc/create/tasks/sub_main_isn.yml +++ b/roles/dtc/create/tasks/sub_main_isn.yml @@ -48,33 +48,33 @@ - MD_Extended.vxlan.fabric.name is defined - MD_Extended.vxlan.fabric.type == "ISN" - MD_Extended.vxlan.multisite is defined - - vars_common_isn.changes_detected_fabric + - change_flags.changes_detected_fabric tags: "{{ nac_tags.create_fabric }}" - name: Manage ISN Fabric Switches in Nexus Dashboard ansible.builtin.import_tasks: common/devices.yml when: - MD_Extended.vxlan.topology.switches | length > 0 - - vars_common_isn.changes_detected_inventory + - change_flags.changes_detected_inventory tags: "{{ nac_tags.create_switches }}" - name: Manage ISN Fabric Inter Links in Nexus Dashboard ansible.builtin.import_tasks: common/edge_connections.yml when: - MD_Extended.vxlan.topology.edge_connections | length > 0 - - changes_detected_edge_connections + - change_flags.changes_detected_edge_connections tags: "{{ nac_tags.create_links }}" - name: Manage ISN Fabric Interfaces in Nexus Dashboard ansible.builtin.import_tasks: common/interfaces.yml when: - (MD_Extended.vxlan.topology.interfaces.modes.all.count >0) and (MD_Extended.vxlan.topology.switches | length > 0) - - vars_common_isn.changes_detected_interfaces + - change_flags.changes_detected_interfaces tags: "{{ nac_tags.create_interfaces }}" - name: Manage ISN Fabric Policies in Nexus Dashboard ansible.builtin.import_tasks: common/policies.yml when: - (MD_Extended.vxlan.policy is defined) and (MD_Extended.vxlan.policy.policies | length > 0) - - vars_common_isn.changes_detected_policy + - change_flags.changes_detected_policy tags: "{{ nac_tags.create_policy }}" diff --git a/roles/dtc/create/tasks/sub_main_msd.yml b/roles/dtc/create/tasks/sub_main_msd.yml index 4638ea054..101670586 100644 --- a/roles/dtc/create/tasks/sub_main_msd.yml +++ b/roles/dtc/create/tasks/sub_main_msd.yml @@ -47,7 +47,7 @@ when: - MD_Extended.vxlan.fabric.name is defined - MD_Extended.vxlan.fabric.type == "MSD" - - vars_common_msd.changes_detected_fabric + - change_flags.changes_detected_fabric tags: "{{ nac_tags.create_fabric }}" - name: Manage MSD Fabric Child Fabrics in Nexus Dashboard @@ -77,7 +77,7 @@ | list | length > 0) - vars_common_msd.bgw_anycast_vip | length > 0 - - vars_common_msd.changes_detected_bgw_anycast_vip + - change_flags.changes_detected_bgw_anycast_vip - name: Manage MSD Fabric VRFs and Networks in Nexus Dashboard ansible.builtin.import_tasks: msd/vrfs_networks.yml diff --git a/roles/dtc/create/tasks/sub_main_vxlan.yml b/roles/dtc/create/tasks/sub_main_vxlan.yml index dc336280d..b20773a59 100644 --- a/roles/dtc/create/tasks/sub_main_vxlan.yml +++ b/roles/dtc/create/tasks/sub_main_vxlan.yml @@ -48,21 +48,21 @@ - MD_Extended.vxlan.fabric.name is defined - MD_Extended.vxlan.fabric.type == "VXLAN_EVPN" - MD_Extended.vxlan.global.ibgp is defined - - vars_common_vxlan.changes_detected_fabric + - change_flags.changes_detected_fabric tags: "{{ nac_tags.create_fabric }}" - name: Manage iBGP VXLAN Fabric Switches in Nexus Dashboard ansible.builtin.import_tasks: common/devices.yml when: - MD_Extended.vxlan.topology.switches | length > 0 - - vars_common_vxlan.changes_detected_inventory or vars_common_vxlan.changes_detected_underlay_ip_address + - change_flags.changes_detected_inventory or change_flags.changes_detected_underlay_ip_address tags: "{{ nac_tags.create_switches }}" - name: Manage iBGP VXLAN vPC Peering in Nexus Dashboard ansible.builtin.import_tasks: common/vpc_peering.yml when: - MD_Extended.vxlan.topology.vpc_peers | length > 0 - - vars_common_vxlan.changes_detected_vpc_peering or vars_common_vxlan.changes_detected_vpc_domain_id_resource + - change_flags.changes_detected_vpc_peering or change_flags.changes_detected_vpc_domain_id_resource tags: "{{ nac_tags.create_vpc_peers }}" - name: Config-Save Block to Propagate vPC Changes to iBGP VXLAN Fabric in Nexus Dashboard @@ -85,14 +85,14 @@ ansible.builtin.import_tasks: common/interfaces.yml when: - (MD_Extended.vxlan.topology.interfaces.modes.all.count >0) and (MD_Extended.vxlan.topology.switches | length > 0) - - vars_common_vxlan.changes_detected_interfaces + - change_flags.changes_detected_interfaces tags: "{{ nac_tags.create_interfaces }}" - name: Manage iBGP VXLAN Fabric Inter Links in Nexus Dashboard ansible.builtin.import_tasks: common/edge_connections.yml when: - MD_Extended.vxlan.topology.edge_connections | length > 0 - - vars_common_vxlan.changes_detected_edge_connections + - change_flags.changes_detected_edge_connections tags: "{{ nac_tags.create_links }}" - name: Manage iBGP VXLAN Fabric VRFs and Networks in Nexus Dashboard @@ -100,19 +100,19 @@ when: - MD_Extended.vxlan.overlay is defined - MD_Extended.vxlan.topology.switches | length > 0 - - vars_common_vxlan.changes_detected_vrfs or vars_common_vxlan.changes_detected_networks + - change_flags.changes_detected_vrfs or change_flags.changes_detected_networks tags: "{{ nac_tags.create_vrfs_networks }}" - name: Manage iBGP VXLAN Fabric Intra Links in Nexus Dashboard ansible.builtin.import_tasks: common/links.yml when: - MD_Extended.vxlan.topology.fabric_links | length > 0 - - vars_common_vxlan.changes_detected_fabric_links + - change_flags.changes_detected_fabric_links tags: "{{ nac_tags.create_links }}" - name: Manage iBGP VXLAN Fabric Policies in Nexus Dashboard ansible.builtin.import_tasks: common/policies.yml when: - (MD_Extended.vxlan.policy is defined) and (MD_Extended.vxlan.policy.policies | length > 0) - - vars_common_vxlan.changes_detected_policy + - change_flags.changes_detected_policy tags: "{{ nac_tags.create_policy }}" diff --git a/roles/dtc/remove/tasks/sub_main_ebgp_vxlan.yml b/roles/dtc/remove/tasks/sub_main_ebgp_vxlan.yml index 11a273f16..e35e015f5 100644 --- a/roles/dtc/remove/tasks/sub_main_ebgp_vxlan.yml +++ b/roles/dtc/remove/tasks/sub_main_ebgp_vxlan.yml @@ -52,34 +52,34 @@ ansible.builtin.import_tasks: common/vpc_peers.yml tags: "{{ nac_tags.remove_vpc_peers }}" when: - - vars_common_ebgp_vxlan.changes_detected_vpc_peering + - change_flags.changes_detected_vpc_peering - name: Remove eBGP VXLAN Fabric Policy from Nexus Dashboard ansible.builtin.import_tasks: common/policy.yml tags: "{{ nac_tags.remove_policy }}" when: - - vars_common_ebgp_vxlan.changes_detected_policy + - change_flags.changes_detected_policy - name: Remove eBGP VXLAN Fabric Interfaces from Nexus Dashboard ansible.builtin.import_tasks: common/interfaces.yml tags: "{{ nac_tags.remove_interfaces }}" when: - - vars_common_ebgp_vxlan.changes_detected_interfaces + - change_flags.changes_detected_interfaces - name: Remove eBGP VXLAN Fabric Networks from Nexus Dashboard ansible.builtin.import_tasks: common_vxlan/networks.yml tags: "{{ nac_tags.remove_networks }}" when: - - vars_common_ebgp_vxlan.changes_detected_networks + - change_flags.changes_detected_networks - name: Remove eBGP VXLAN Fabric VRFs from Nexus Dashboard ansible.builtin.import_tasks: common_vxlan/vrfs.yml tags: "{{ nac_tags.remove_vrfs }}" when: - - vars_common_ebgp_vxlan.changes_detected_vrfs + - change_flags.changes_detected_vrfs - name: Remove eBGP VXLAN Fabric Switches from Nexus Dashboard ansible.builtin.import_tasks: common/switches.yml tags: "{{ nac_tags.remove_switches }}" when: - - vars_common_ebgp_vxlan.changes_detected_inventory + - change_flags.changes_detected_inventory diff --git a/roles/dtc/remove/tasks/sub_main_external.yml b/roles/dtc/remove/tasks/sub_main_external.yml index b1ed2b661..282ef4577 100644 --- a/roles/dtc/remove/tasks/sub_main_external.yml +++ b/roles/dtc/remove/tasks/sub_main_external.yml @@ -52,28 +52,28 @@ ansible.builtin.import_tasks: common/edge_connections.yml tags: "{{ nac_tags.remove_edge_connections }}" when: - - vars_common_external.changes_detected_edge_connections + - change_flags.changes_detected_edge_connections - name: Remove External Fabric Policy from Nexus Dashboard ansible.builtin.import_tasks: common/policy.yml tags: "{{ nac_tags.remove_policy }}" when: - - vars_common_external.changes_detected_policy + - change_flags.changes_detected_policy - name: Remove External Fabric Interfaces from Nexus Dashboard ansible.builtin.import_tasks: common/interfaces.yml tags: "{{ nac_tags.remove_interfaces }}" when: - - vars_common_external.changes_detected_interfaces + - change_flags.changes_detected_interfaces - name: Remove External Fabric vPC Peering from Nexus Dashboard ansible.builtin.import_tasks: common/vpc_peers.yml tags: "{{ nac_tags.remove_vpc_peers }}" when: - - vars_common_external.changes_detected_vpc_peering + - change_flags.changes_detected_vpc_peering - name: Remove External Fabric Switches from Nexus Dashboard ansible.builtin.import_tasks: common/switches.yml tags: "{{ nac_tags.remove_switches }}" when: - - vars_common_external.changes_detected_inventory + - change_flags.changes_detected_inventory diff --git a/roles/dtc/remove/tasks/sub_main_isn.yml b/roles/dtc/remove/tasks/sub_main_isn.yml index 214c74a18..b88f3a22c 100644 --- a/roles/dtc/remove/tasks/sub_main_isn.yml +++ b/roles/dtc/remove/tasks/sub_main_isn.yml @@ -52,22 +52,22 @@ ansible.builtin.import_tasks: common/edge_connections.yml tags: "{{ nac_tags.remove_edge_connections }}" when: - - vars_common_isn.changes_detected_edge_connections + - change_flags.changes_detected_edge_connections - name: Remove ISN Fabric Policy from Nexus Dashboard ansible.builtin.import_tasks: common/policy.yml tags: "{{ nac_tags.remove_policy }}" when: - - vars_common_isn.changes_detected_policy + - change_flags.changes_detected_policy - name: Remove ISN Fabric Interfaces from Nexus Dashboard ansible.builtin.import_tasks: common/interfaces.yml tags: "{{ nac_tags.remove_interfaces }}" when: - - vars_common_isn.changes_detected_interfaces + - change_flags.changes_detected_interfaces - name: Remove ISN Fabric Switches from Nexus Dashboard ansible.builtin.import_tasks: common/switches.yml tags: "{{ nac_tags.remove_switches }}" when: - - vars_common_isn.changes_detected_inventory + - change_flags.changes_detected_inventory diff --git a/roles/dtc/remove/tasks/sub_main_vxlan.yml b/roles/dtc/remove/tasks/sub_main_vxlan.yml index b33cfb7bd..77afa535b 100644 --- a/roles/dtc/remove/tasks/sub_main_vxlan.yml +++ b/roles/dtc/remove/tasks/sub_main_vxlan.yml @@ -52,46 +52,46 @@ ansible.builtin.import_tasks: common/edge_connections.yml tags: "{{ nac_tags.remove_edge_connections }}" when: - - vars_common_vxlan.changes_detected_edge_connections + - change_flags.changes_detected_edge_connections - name: Remove iBGP VXLAN Fabric Policy from Nexus Dashboard ansible.builtin.import_tasks: common/policy.yml tags: "{{ nac_tags.remove_policy }}" when: - - vars_common_vxlan.changes_detected_policy + - change_flags.changes_detected_policy - name: Remove iBGP VXLAN Fabric Interfaces from Nexus Dashboard ansible.builtin.import_tasks: common/interfaces.yml tags: "{{ nac_tags.remove_interfaces }}" when: - - vars_common_vxlan.changes_detected_interfaces + - change_flags.changes_detected_interfaces - name: Remove iBGP VXLAN Fabric Networks from Nexus Dashboard ansible.builtin.import_tasks: common_vxlan/networks.yml tags: "{{ nac_tags.remove_networks }}" when: - - vars_common_vxlan.changes_detected_networks + - change_flags.changes_detected_networks - name: Remove iBGP VXLAN Fabric VRFs from Nexus Dashboard ansible.builtin.import_tasks: common_vxlan/vrfs.yml tags: "{{ nac_tags.remove_vrfs }}" when: - - vars_common_vxlan.changes_detected_vrfs + - change_flags.changes_detected_vrfs - name: Remove iBGP VXLAN Fabric Links from Nexus Dashboard ansible.builtin.import_tasks: common/links.yml tags: "{{ nac_tags.remove_links }}" when: - - vars_common_vxlan.changes_detected_fabric_links + - change_flags.changes_detected_fabric_links - name: Remove iBGP VXLAN Fabric vPC Peering from Nexus Dashboard ansible.builtin.import_tasks: common/vpc_peers.yml tags: "{{ nac_tags.remove_vpc_peers }}" when: - - vars_common_vxlan.changes_detected_vpc_peering + - change_flags.changes_detected_vpc_peering - name: Remove iBGP VXLAN Fabric Switches from Nexus Dashboard ansible.builtin.import_tasks: common/switches.yml tags: "{{ nac_tags.remove_switches }}" when: - - vars_common_vxlan.changes_detected_inventory + - change_flags.changes_detected_inventory From b68dcd8609f3f6eae8705976b7fe744a5f04abdd Mon Sep 17 00:00:00 2001 From: mwiebe Date: Mon, 6 Oct 2025 23:13:53 -0400 Subject: [PATCH 22/65] Add common role tags --- roles/dtc/common/tasks/main.yml | 7 ++++++- roles/dtc/remove/tasks/main.yml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/roles/dtc/common/tasks/main.yml b/roles/dtc/common/tasks/main.yml index 59cdcd043..48287d107 100644 --- a/roles/dtc/common/tasks/main.yml +++ b/roles/dtc/common/tasks/main.yml @@ -27,6 +27,7 @@ fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" role_path: "{{ role_path }}" operation: "initialize" + tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml delegate_to: localhost # # ------------------------------------------------------------------------ @@ -145,11 +146,13 @@ - name: Read Change Flags JSON Data From File ansible.builtin.set_fact: change_flag_data: "{{ lookup('ansible.builtin.file', role_path + '/files/' + MD_Extended.vxlan.fabric.name + '_changes_detected_flags.json') | from_json }}" + tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml delegate_to: localhost - name: Set Change Flags Fact ansible.builtin.set_fact: change_flags: "{{ change_flag_data[MD_Extended.vxlan.fabric.name][MD_Extended.vxlan.fabric.type] }}" + tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml delegate_to: localhost - name: Display Flag Values @@ -158,6 +161,8 @@ fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" role_path: "{{ role_path }}" operation: "display" + tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml delegate_to: localhost -- debug: msg="{{ change_flags }}" \ No newline at end of file +- debug: msg="{{ change_flags }}" + tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml diff --git a/roles/dtc/remove/tasks/main.yml b/roles/dtc/remove/tasks/main.yml index 116c3e050..70c8c8d93 100644 --- a/roles/dtc/remove/tasks/main.yml +++ b/roles/dtc/remove/tasks/main.yml @@ -91,7 +91,7 @@ - name: Import MSD Fabric Role Tasks ansible.builtin.import_tasks: sub_main_msd.yml - when: > + when: MD_Extended.vxlan.fabric.type == 'MSD' # Current implementation has to leverage the changes_detected flags # in the sub_main files to determine if the tasks should be run From 0a4c386f5d4137dff2b64e10c04d7328cd3ae974 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Tue, 7 Oct 2025 14:06:16 -0400 Subject: [PATCH 23/65] Updates --- .../dtc/common/tasks/external/ndfc_vpc_peering_pairs.yml | 9 +++++++++ roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml | 2 ++ roles/dtc/common/tasks/sub_main_external.yml | 1 + roles/dtc/common/tasks/sub_main_vxlan.yml | 1 + roles/dtc/create/tasks/common/devices_discovery.yml | 6 +++--- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/roles/dtc/common/tasks/external/ndfc_vpc_peering_pairs.yml b/roles/dtc/common/tasks/external/ndfc_vpc_peering_pairs.yml index 6c9fde5f1..009373f24 100644 --- a/roles/dtc/common/tasks/external/ndfc_vpc_peering_pairs.yml +++ b/roles/dtc/common/tasks/external/ndfc_vpc_peering_pairs.yml @@ -74,6 +74,15 @@ when: MD_Extended.vxlan.topology.vpc_peers | length > 0 delegate_to: localhost +- name: Build vPC Peering Diff Between Previous and Current Run + # This task must be run before the next task because + # dtc.diff_model_changes deletes the .old file if it exists + cisco.nac_dc_vxlan.dtc.diff_compare: + old_file: "{{ path_name }}{{ file_name }}.old" + new_file: "{{ path_name }}{{ file_name }}" + register: vpc_peering_diff_result + delegate_to: localhost + - name: Diff Previous and Current Data Files cisco.nac_dc_vxlan.dtc.diff_model_changes: file_name_previous: "{{ path_name }}{{ file_name }}.old" diff --git a/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml b/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml index dea44c32a..589b9549a 100644 --- a/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml +++ b/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml @@ -219,6 +219,7 @@ interface_access_po: "{{ interface_access_po }}" interface_access: "{{ interface_access }}" interface_all: "{{ interface_all }}" + interface_diff_result: "{{ interface_diff_result }}" int_loopback_config: "{{ int_loopback_config }}" interface_po_routed: "{{ interface_po_routed }}" interface_routed: "{{ interface_routed }}" @@ -235,6 +236,7 @@ updated_inv_config: "{{ updated_inv_config }}" updated_inv_config_no_bootstrap: "{{ updated_inv_config_no_bootstrap }}" vpc_peering: "{{ vpc_peering }}" + vpc_peering_diff_result: "{{ vpc_peering_diff_result }}" vpc_domain_id_resource: "{{ vpc_domain_id_resource }}" vrf_config: "{{ vrf_config }}" vrf_attach_config: "{{ vrf_attach_config }}" diff --git a/roles/dtc/common/tasks/sub_main_external.yml b/roles/dtc/common/tasks/sub_main_external.yml index 88dc96963..3d96023bd 100644 --- a/roles/dtc/common/tasks/sub_main_external.yml +++ b/roles/dtc/common/tasks/sub_main_external.yml @@ -198,3 +198,4 @@ updated_inv_config: "{{ updated_inv_config }}" updated_inv_config_no_bootstrap: "{{ updated_inv_config_no_bootstrap }}" vpc_peering: "{{ vpc_peering }}" + vpc_peering_diff_result: "{{ vpc_peering_diff_result }}" diff --git a/roles/dtc/common/tasks/sub_main_vxlan.yml b/roles/dtc/common/tasks/sub_main_vxlan.yml index 66d248e06..6a51d9da9 100644 --- a/roles/dtc/common/tasks/sub_main_vxlan.yml +++ b/roles/dtc/common/tasks/sub_main_vxlan.yml @@ -221,6 +221,7 @@ vars_common_vxlan: fabric_config: "{{ fabric_config }}" fabric_links: "{{ fabric_links }}" + fabric_links_diff_result: "{{ fabric_links_diff_result }}" edge_connections: "{{ edge_connections }}" interface_breakout: "{{ interface_breakout }}" interface_breakout_preprov: "{{ interface_breakout_preprov }}" diff --git a/roles/dtc/create/tasks/common/devices_discovery.yml b/roles/dtc/create/tasks/common/devices_discovery.yml index aca1fcff3..01abfc316 100644 --- a/roles/dtc/create/tasks/common/devices_discovery.yml +++ b/roles/dtc/create/tasks/common/devices_discovery.yml @@ -60,8 +60,8 @@ - MD_Extended.vxlan.topology.switches | length > 0 - change_flags.changes_detected_inventory -- debug: msg="{{ vars_common_vxlan.underlay_ip_address_diff_result.updated }}" -- debug: msg="{{ vars_common_vxlan.underlay_ip_address_diff_result.updated | length }}" +# - debug: msg="{{ vars_common_local.underlay_ip_address_diff_result.updated }}" +# - debug: msg="{{ vars_common_local.underlay_ip_address_diff_result.updated | length }}" - name: Sleep for 5 seconds ansible.builtin.pause: @@ -72,7 +72,7 @@ state: merged fabric: "{{ MD_Extended.vxlan.fabric.name }}" # config: "{{ vars_common_vxlan.underlay_ip_address }}" - config: "{{ vars_common_vxlan.underlay_ip_address_diff_result.updated }}" + config: "{{ vars_common_local.underlay_ip_address_diff_result.updated }}" when: - MD_Extended.vxlan.underlay.general.manual_underlay_allocation is defined - MD_Extended.vxlan.underlay.general.manual_underlay_allocation From 813237de515c635f510babc419cec8b7264d8268 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Wed, 8 Oct 2025 14:27:23 -0400 Subject: [PATCH 24/65] Cleanup, deploy false remove, write diff_compare to file --- plugins/action/dtc/diff_compare.py | 50 ++++++++ .../tasks/common/ndfc_edge_connections.yml | 13 --- roles/dtc/common/tasks/common/ndfc_fabric.yml | 14 --- .../common/tasks/common/ndfc_fabric_links.yml | 13 --- .../tasks/common/ndfc_interface_access.yml | 13 --- .../tasks/common/ndfc_interface_access_po.yml | 13 --- .../tasks/common/ndfc_interface_all.yml | 13 --- .../tasks/common/ndfc_interface_breakout.yml | 13 --- .../ndfc_interface_breakout_preprov.yml | 13 --- .../tasks/common/ndfc_interface_dot1q.yml | 13 --- .../tasks/common/ndfc_interface_loopback.yml | 13 --- .../tasks/common/ndfc_interface_po_routed.yml | 13 --- .../tasks/common/ndfc_interface_routed.yml | 8 -- .../tasks/common/ndfc_interface_trunk.yml | 13 --- .../tasks/common/ndfc_interface_trunk_po.yml | 13 --- .../tasks/common/ndfc_interface_vpc.yml | 8 -- .../common/tasks/common/ndfc_inventory.yml | 13 --- roles/dtc/common/tasks/common/ndfc_policy.yml | 6 - .../common/ndfc_sub_interface_routed.yml | 13 --- .../tasks/common/ndfc_underlay_ip_address.yml | 5 - .../common/ndfc_vpc_domain_id_resource.yml | 13 --- .../common/ndfc_vpc_fabric_peering_links.yml | 13 --- .../tasks/common/ndfc_vpc_peering_pairs.yml | 13 --- roles/dtc/common/tasks/main.yml | 107 ++---------------- .../dtc/common/tasks/sub_main_ebgp_vxlan.yml | 2 + roles/dtc/create/tasks/main.yml | 64 ----------- .../remove/tasks/common/edge_connections.yml | 2 +- roles/dtc/remove/tasks/common/interfaces.yml | 3 + roles/dtc/remove/tasks/common/links.yml | 1 + roles/dtc/remove/tasks/common/policy.yml | 2 +- roles/dtc/remove/tasks/common/switches.yml | 4 +- roles/dtc/remove/tasks/common/vpc_peers.yml | 4 +- 32 files changed, 70 insertions(+), 431 deletions(-) diff --git a/plugins/action/dtc/diff_compare.py b/plugins/action/dtc/diff_compare.py index 2c7a782bd..b1c6013b1 100644 --- a/plugins/action/dtc/diff_compare.py +++ b/plugins/action/dtc/diff_compare.py @@ -22,6 +22,8 @@ from __future__ import absolute_import, division, print_function import yaml +import os +import datetime from ansible.utils.display import Display from ansible.plugins.action import ActionBase @@ -91,8 +93,56 @@ def run(self, tmp=None, task_vars=None): display.v("Unchanged Items:\n%s", yaml.dump(equal_items, default_flow_style=False)) results['compare'] = {"updated": updated_items, "removed": removed_items, "equal": equal_items} + + # Write comparison results to file + self.write_comparison_results(results['compare']) + return results['compare'] + def write_comparison_results(self, compare_results): + """ + Write comparison results to a unique file in the same directory as new_file_path. + + Args: + compare_results (dict): Dictionary containing 'updated', 'removed', and 'equal' lists + """ + if not self.new_file_path: + display.warning("new_file_path is not set, cannot write comparison results") + return + + # Get the directory of the new_file_path + output_dir = os.path.dirname(self.new_file_path) + + # Create a unique filename with timestamp + base_filename = os.path.splitext(os.path.basename(self.new_file_path))[0] + output_filename = f"{base_filename}_comparison.yml" + output_path = os.path.join(output_dir, output_filename) + + # Prepare the data to write + output_data = { + 'comparison_summary': { + 'timestamp': datetime.datetime.now().isoformat(), + 'source_file': self.new_file_path, + 'total_updated': len(compare_results.get('updated', [])), + 'total_removed': len(compare_results.get('removed', [])), + 'total_equal': len(compare_results.get('equal', [])) + }, + 'updated_items': compare_results.get('updated', []), + 'removed_items': compare_results.get('removed', []), + 'equal_items': compare_results.get('equal', []) + } + + try: + # Remove old file if it exists + if os.path.exists(output_path): + os.remove(output_path) + display.v(f"Removed existing file: {output_path}") + + with open(output_path, 'w', encoding='utf-8') as f: + yaml.dump(output_data, f, default_flow_style=False, sort_keys=False) + except Exception as e: + display.warning(f"Failed to write comparison results to {output_path}: {str(e)}") + def load_yaml(self, filename): """ Load YAML data from a file. diff --git a/roles/dtc/common/tasks/common/ndfc_edge_connections.yml b/roles/dtc/common/tasks/common/ndfc_edge_connections.yml index c74a68bca..ae3f96197 100644 --- a/roles/dtc/common/tasks/common/ndfc_edge_connections.yml +++ b/roles/dtc/common/tasks/common/ndfc_edge_connections.yml @@ -21,11 +21,6 @@ --- -# - name: Initialize changes_detected Var -# ansible.builtin.set_fact: -# changes_detected_edge_connections: false -# delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_edge_connections.yml" @@ -76,14 +71,6 @@ register: file_diff_result delegate_to: localhost -# - name: Set File Change Flag Based on File Diff Result -# ansible.builtin.set_fact: -# changes_detected_edge_connections: true -# delegate_to: localhost -# when: -# - file_diff_result.file_data_changed -# - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/common/ndfc_fabric.yml b/roles/dtc/common/tasks/common/ndfc_fabric.yml index 6cbf7cb8a..550b67cb5 100644 --- a/roles/dtc/common/tasks/common/ndfc_fabric.yml +++ b/roles/dtc/common/tasks/common/ndfc_fabric.yml @@ -21,11 +21,6 @@ --- -# - name: Initialize changes_detected Var -# ansible.builtin.set_fact: -# changes_detected_fabric: false -# delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_fabric.yml" @@ -36,7 +31,6 @@ path: "{{ path_name }}{{ file_name }}" register: data_file_previous delegate_to: localhost - # TODO: Add capability to overridde path variable above for CI/CD pipeline - name: Backup Previous Data File If It Exists ansible.builtin.copy: @@ -76,14 +70,6 @@ register: file_diff_result delegate_to: localhost -# - name: Set File Change Flag Based on File Diff Result -# ansible.builtin.set_fact: -# changes_detected_fabric: true -# delegate_to: localhost -# when: -# - file_diff_result.file_data_changed -# - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/common/ndfc_fabric_links.yml b/roles/dtc/common/tasks/common/ndfc_fabric_links.yml index 5edd674ed..e45725e4c 100644 --- a/roles/dtc/common/tasks/common/ndfc_fabric_links.yml +++ b/roles/dtc/common/tasks/common/ndfc_fabric_links.yml @@ -21,11 +21,6 @@ --- -# - name: Initialize changes_detected Var -# ansible.builtin.set_fact: -# changes_detected_fabric_links: false -# delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_fabric_links.yml" @@ -94,14 +89,6 @@ register: file_diff_result delegate_to: localhost -# - name: Set File Change Flag Based on File Diff Result -# ansible.builtin.set_fact: -# changes_detected_fabric_links: true -# delegate_to: localhost -# when: -# - file_diff_result.file_data_changed -# - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/common/ndfc_interface_access.yml b/roles/dtc/common/tasks/common/ndfc_interface_access.yml index baea9335f..3415853b5 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_access.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_access.yml @@ -21,11 +21,6 @@ --- -# - name: Initialize changes_detected Var -# ansible.builtin.set_fact: -# changes_detected_interface_access: false -# delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_interface_access.yml" @@ -76,14 +71,6 @@ register: file_diff_result delegate_to: localhost -# - name: Set File Change Flag Based on File Diff Result -# ansible.builtin.set_fact: -# changes_detected_interface_access: true -# delegate_to: localhost -# when: -# - file_diff_result.file_data_changed -# - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/common/ndfc_interface_access_po.yml b/roles/dtc/common/tasks/common/ndfc_interface_access_po.yml index 7fb7a1b9c..4010cfa83 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_access_po.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_access_po.yml @@ -21,11 +21,6 @@ --- -# - name: Initialize changes_detected Var -# ansible.builtin.set_fact: -# changes_detected_interface_access_po: false -# delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_interface_access_po.yml" @@ -76,14 +71,6 @@ register: file_diff_result delegate_to: localhost -# - name: Set File Change Flag Based on File Diff Result -# ansible.builtin.set_fact: -# changes_detected_interface_access_po: true -# delegate_to: localhost -# when: -# - file_diff_result.file_data_changed -# - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/common/ndfc_interface_all.yml b/roles/dtc/common/tasks/common/ndfc_interface_all.yml index 651112805..fc5978f84 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_all.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_all.yml @@ -21,11 +21,6 @@ --- -# - name: Initialize changes_detected Var -# ansible.builtin.set_fact: -# changes_detected_interfaces: false -# delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_interface_all.yml" @@ -126,14 +121,6 @@ register: file_diff_result delegate_to: localhost -# - name: Set File Change Flag Based on File Diff Result -# ansible.builtin.set_fact: -# changes_detected_interfaces: true -# delegate_to: localhost -# when: -# - file_diff_result.file_data_changed -# - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/common/ndfc_interface_breakout.yml b/roles/dtc/common/tasks/common/ndfc_interface_breakout.yml index 39564f9cb..4716b1bc8 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_breakout.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_breakout.yml @@ -21,11 +21,6 @@ --- -# - name: Initialize changes_detected Var -# ansible.builtin.set_fact: -# changes_detected_interface_breakout: false -# delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_interface_breakout.yml" @@ -76,14 +71,6 @@ register: file_diff_result delegate_to: localhost -# - name: Set File Change Flag Based on File Diff Result -# ansible.builtin.set_fact: -# changes_detected_interface_breakout: true -# delegate_to: localhost -# when: -# - file_diff_result.file_data_changed -# - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/common/ndfc_interface_breakout_preprov.yml b/roles/dtc/common/tasks/common/ndfc_interface_breakout_preprov.yml index a2020b050..c115e940f 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_breakout_preprov.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_breakout_preprov.yml @@ -21,11 +21,6 @@ --- -# - name: Initialize changes_detected Var -# ansible.builtin.set_fact: -# changes_detected_interface_breakout_preprov: false -# delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_interface_breakout_preprov.yml" @@ -76,14 +71,6 @@ register: file_diff_result delegate_to: localhost -# - name: Set File Change Flag Based on File Diff Result -# ansible.builtin.set_fact: -# changes_detected_interface_breakout_preprov: true -# delegate_to: localhost -# when: -# - file_diff_result.file_data_changed -# - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/common/ndfc_interface_dot1q.yml b/roles/dtc/common/tasks/common/ndfc_interface_dot1q.yml index aa717064b..5087f2946 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_dot1q.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_dot1q.yml @@ -21,11 +21,6 @@ --- -# - name: Initialize changes_detected Var -# ansible.builtin.set_fact: -# changes_detected_interface_dot1q: false -# delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_interface_dot1q.yml" @@ -76,14 +71,6 @@ register: file_diff_result delegate_to: localhost -# - name: Set File Change Flag Based on File Diff Result -# ansible.builtin.set_fact: -# changes_detected_interface_dot1q: true -# delegate_to: localhost -# when: -# - file_diff_result.file_data_changed -# - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/common/ndfc_interface_loopback.yml b/roles/dtc/common/tasks/common/ndfc_interface_loopback.yml index e3c4b59eb..0b1625253 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_loopback.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_loopback.yml @@ -21,11 +21,6 @@ --- -# - name: Initialize changes_detected Var -# ansible.builtin.set_fact: -# changes_detected_interface_loopback: false -# delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_loopback_interfaces.yml" @@ -79,14 +74,6 @@ register: file_diff_result delegate_to: localhost -# - name: Set File Change Flag Based on File Diff Result -# ansible.builtin.set_fact: -# changes_detected_interface_loopback: true -# delegate_to: localhost -# when: -# - file_diff_result.file_data_changed -# - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/common/ndfc_interface_po_routed.yml b/roles/dtc/common/tasks/common/ndfc_interface_po_routed.yml index d4ad34e54..2a897b651 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_po_routed.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_po_routed.yml @@ -21,11 +21,6 @@ --- -# - name: Initialize changes_detected Var -# ansible.builtin.set_fact: -# changes_detected_interface_po_routed: false -# delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_interface_po_routed.yml" @@ -76,14 +71,6 @@ register: file_diff_result delegate_to: localhost -# - name: Set File Change Flag Based on File Diff Result -# ansible.builtin.set_fact: -# changes_detected_interface_po_routed: true -# delegate_to: localhost -# when: -# - file_diff_result.file_data_changed -# - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/common/ndfc_interface_routed.yml b/roles/dtc/common/tasks/common/ndfc_interface_routed.yml index 6bae3ea83..8167595d0 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_routed.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_routed.yml @@ -76,14 +76,6 @@ register: file_diff_result delegate_to: localhost -# - name: Set File Change Flag Based on File Diff Result -# ansible.builtin.set_fact: -# changes_detected_interface_routed: true -# delegate_to: localhost -# when: -# - file_diff_result.file_data_changed -# - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/common/ndfc_interface_trunk.yml b/roles/dtc/common/tasks/common/ndfc_interface_trunk.yml index f189491a7..850de988f 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_trunk.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_trunk.yml @@ -21,11 +21,6 @@ --- -# - name: Initialize changes_detected Var -# ansible.builtin.set_fact: -# changes_detected_interface_trunk: false -# delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_interface_trunk.yml" @@ -76,14 +71,6 @@ register: file_diff_result delegate_to: localhost -# - name: Set File Change Flag Based on File Diff Result -# ansible.builtin.set_fact: -# changes_detected_interface_trunk: true -# delegate_to: localhost -# when: -# - file_diff_result.file_data_changed -# - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/common/ndfc_interface_trunk_po.yml b/roles/dtc/common/tasks/common/ndfc_interface_trunk_po.yml index 58b13a17a..df4a65d07 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_trunk_po.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_trunk_po.yml @@ -21,11 +21,6 @@ --- -# - name: Initialize changes_detected Var -# ansible.builtin.set_fact: -# changes_detected_interface_trunk_po: false -# delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_interface_trunk_po.yml" @@ -76,14 +71,6 @@ register: file_diff_result delegate_to: localhost -# - name: Set File Change Flag Based on File Diff Result -# ansible.builtin.set_fact: -# changes_detected_interface_trunk_po: true -# delegate_to: localhost -# when: -# - file_diff_result.file_data_changed -# - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/common/ndfc_interface_vpc.yml b/roles/dtc/common/tasks/common/ndfc_interface_vpc.yml index 9597fc578..b4124e79a 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_vpc.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_vpc.yml @@ -76,14 +76,6 @@ register: file_diff_result delegate_to: localhost -# - name: Set File Change Flag Based on File Diff Result -# ansible.builtin.set_fact: -# changes_detected_interface_vpc: true -# delegate_to: localhost -# when: -# - file_diff_result.file_data_changed -# - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/common/ndfc_inventory.yml b/roles/dtc/common/tasks/common/ndfc_inventory.yml index d219ae070..334a050db 100644 --- a/roles/dtc/common/tasks/common/ndfc_inventory.yml +++ b/roles/dtc/common/tasks/common/ndfc_inventory.yml @@ -26,11 +26,6 @@ model_data: "{{ MD_Extended }}" register: poap_data -# - name: Initialize changes_detected Var -# ansible.builtin.set_fact: -# changes_detected_inventory: false -# delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_inventory.yml" @@ -99,14 +94,6 @@ register: file_diff_result delegate_to: localhost -# - name: Set File Change Flag Based on File Diff Result -# ansible.builtin.set_fact: -# changes_detected_inventory: true -# delegate_to: localhost -# when: -# - file_diff_result.file_data_changed -# - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/common/ndfc_policy.yml b/roles/dtc/common/tasks/common/ndfc_policy.yml index 52a4f36fb..ae78414be 100644 --- a/roles/dtc/common/tasks/common/ndfc_policy.yml +++ b/roles/dtc/common/tasks/common/ndfc_policy.yml @@ -21,11 +21,6 @@ --- -# - name: Initialize changes_detected Var -# ansible.builtin.set_fact: -# changes_detected_policy: false -# delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_policy.yml" @@ -36,7 +31,6 @@ path: "{{ path_name }}{{ file_name }}" register: data_file_previous delegate_to: localhost - # TODO: Add capability to overridde path variable above for CI/CD pipeline - name: Backup Previous Data File If It Exists ansible.builtin.copy: diff --git a/roles/dtc/common/tasks/common/ndfc_sub_interface_routed.yml b/roles/dtc/common/tasks/common/ndfc_sub_interface_routed.yml index c67587fcf..5f9cddf81 100644 --- a/roles/dtc/common/tasks/common/ndfc_sub_interface_routed.yml +++ b/roles/dtc/common/tasks/common/ndfc_sub_interface_routed.yml @@ -21,11 +21,6 @@ --- -# - name: Initialize changes_detected Var -# ansible.builtin.set_fact: -# changes_detected_sub_interface_routed: false -# delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_sub_interface_routed.yml" @@ -76,14 +71,6 @@ register: file_diff_result delegate_to: localhost -# - name: Set File Change Flag Based on File Diff Result -# ansible.builtin.set_fact: -# changes_detected_sub_interface_routed: true -# delegate_to: localhost -# when: -# - file_diff_result.file_data_changed -# - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml b/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml index a7476efef..e196dbee7 100644 --- a/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml +++ b/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml @@ -21,11 +21,6 @@ --- -# - name: Initialize changes_detected Var -# ansible.builtin.set_fact: -# changes_detected_underlay_ip_address: false -# delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_underlay_ip_address.yml" diff --git a/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml b/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml index ded3dbe79..cb93401b3 100644 --- a/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml +++ b/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml @@ -21,11 +21,6 @@ --- -# - name: Initialize changes_detected Var -# ansible.builtin.set_fact: -# changes_detected_vpc_domain_id_resource: false -# delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_vpc_domain_id_resource.yml" @@ -92,14 +87,6 @@ register: file_diff_result delegate_to: localhost -# - name: Set File Change Flag Based on File Diff Result -# ansible.builtin.set_fact: -# changes_detected_vpc_domain_id_resource: true -# delegate_to: localhost -# when: -# - file_diff_result.file_data_changed -# - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/common/ndfc_vpc_fabric_peering_links.yml b/roles/dtc/common/tasks/common/ndfc_vpc_fabric_peering_links.yml index 38b5a939f..72e6dca89 100644 --- a/roles/dtc/common/tasks/common/ndfc_vpc_fabric_peering_links.yml +++ b/roles/dtc/common/tasks/common/ndfc_vpc_fabric_peering_links.yml @@ -21,11 +21,6 @@ --- -# - name: Initialize changes_detected Var -# ansible.builtin.set_fact: -# changes_detected_link_vpc_peering: false -# delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_link_vpc_peering.yml" @@ -79,14 +74,6 @@ register: file_diff_result delegate_to: localhost -# - name: Set File Change Flag Based on File Diff Result -# ansible.builtin.set_fact: -# changes_detected_link_vpc_peering: true -# delegate_to: localhost -# when: -# - file_diff_result.file_data_changed -# - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml b/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml index ed0d5fd66..7227fe7a8 100644 --- a/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml +++ b/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml @@ -21,11 +21,6 @@ --- -# - name: Initialize changes_detected Var -# ansible.builtin.set_fact: -# changes_detected_vpc_peering: false -# delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_vpc_peering.yml" @@ -92,14 +87,6 @@ register: file_diff_result delegate_to: localhost -# - name: Set File Change Flag Based on File Diff Result -# ansible.builtin.set_fact: -# changes_detected_vpc_peering: true -# delegate_to: localhost -# when: -# - file_diff_result.file_data_changed -# - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/main.yml b/roles/dtc/common/tasks/main.yml index 48287d107..c9f2d1f00 100644 --- a/roles/dtc/common/tasks/main.yml +++ b/roles/dtc/common/tasks/main.yml @@ -30,129 +30,41 @@ tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml delegate_to: localhost -# # ------------------------------------------------------------------------ -# # Initialize NameSpace Dicts For Variable Sharing -# # ------------------------------------------------------------------------ -# - name: Initialize NameSpace Dict For Sharing Variables -# ansible.builtin.set_fact: -# vars_common_vxlan: -# changes_detected_fabric: false -# changes_detected_fabric_links: false -# changes_detected_edge_connections: false -# changes_detected_interface_dot1q: false -# changes_detected_interface_access_po: false -# changes_detected_interface_access: false -# changes_detected_interfaces: false -# changes_detected_interface_loopback: false -# changes_detected_interface_po_routed: false -# changes_detected_interface_routed: false -# changes_detected_interface_trunk_po: false -# changes_detected_interface_trunk: false -# changes_detected_interface_vpc: false -# changes_detected_inventory: false -# changes_detected_link_vpc_peering: false -# changes_detected_networks: false -# changes_detected_policy: false -# changes_detected_sub_interface_routed: false -# changes_detected_vpc_peering: false -# changes_detected_vpc_domain_id_resource: false -# changes_detected_vrfs: false -# changes_detected_underlay_ip_address: false -# vars_common_isn: -# changes_detected_fabric: false -# changes_detected_fabric_links: false -# changes_detected_edge_connections: false -# changes_detected_interface_dot1q: false -# changes_detected_interface_access_po: false -# changes_detected_interface_access: false -# changes_detected_interfaces: false -# changes_detected_interface_loopback: false -# changes_detected_interface_po_routed: false -# changes_detected_interface_routed: false -# changes_detected_interface_trunk_po: false -# changes_detected_interface_trunk: false -# changes_detected_interface_vpc: false -# changes_detected_inventory: false -# changes_detected_policy: false -# changes_detected_sub_interface_routed: false -# vars_common_msd: -# changes_detected_fabric: false -# changes_detected_bgw_anycast_vip: false -# changes_detected_vrfs: false -# changes_detected_networks: false -# vars_common_external: -# changes_detected_inventory: false -# changes_detected_fabric: false -# changes_detected_interface_dot1q: false -# changes_detected_interface_access_po: false -# changes_detected_interface_access: false -# changes_detected_interfaces: false -# changes_detected_interface_loopback: false -# changes_detected_interface_po_routed: false -# changes_detected_interface_routed: false -# changes_detected_interface_trunk_po: false -# changes_detected_interface_trunk: false -# changes_detected_interface_vpc: false -# changes_detected_sub_interface_routed: false -# changes_detected_policy: false -# vars_common_ebgp_vxlan: -# changes_detected_fabric: false -# changes_detected_fabric_links: false -# changes_detected_edge_connections: false -# changes_detected_interface_dot1q: false -# changes_detected_interface_access_po: false -# changes_detected_interface_access: false -# changes_detected_interfaces: false -# changes_detected_interface_loopback: false -# changes_detected_interface_po_routed: false -# changes_detected_interface_routed: false -# changes_detected_interface_trunk_po: false -# changes_detected_interface_trunk: false -# changes_detected_interface_vpc: false -# changes_detected_inventory: false -# changes_detected_link_vpc_peering: false -# changes_detected_networks: false -# changes_detected_policy: false -# changes_detected_sub_interface_routed: false -# changes_detected_vpc_peering: false -# changes_detected_vrfs: false -# tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml - - name: Import Role Tasks for iBGP VXLAN Fabric ansible.builtin.import_tasks: sub_main_vxlan.yml - tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml + tags: "{{ nac_tags.common_role }}" when: MD_Extended.vxlan.fabric.type == 'VXLAN_EVPN' - name: Import Role Tasks for eBGP VXLAN Fabric ansible.builtin.import_tasks: sub_main_ebgp_vxlan.yml - tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml + tags: "{{ nac_tags.common_role }}" when: MD_Extended.vxlan.fabric.type == 'eBGP_VXLAN' - name: Import Role Tasks for ISN Fabric ansible.builtin.import_tasks: sub_main_isn.yml - tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml + tags: "{{ nac_tags.common_role }}" when: MD_Extended.vxlan.fabric.type == 'ISN' - name: Import Role Tasks for MSD Fabric ansible.builtin.import_tasks: sub_main_msd.yml - tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml + tags: "{{ nac_tags.common_role }}" when: MD_Extended.vxlan.fabric.type == 'MSD' - name: Import Role Tasks for External Fabric ansible.builtin.import_tasks: sub_main_external.yml - tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml + tags: "{{ nac_tags.common_role }}" when: MD_Extended.vxlan.fabric.type == 'External' - name: Read Change Flags JSON Data From File ansible.builtin.set_fact: change_flag_data: "{{ lookup('ansible.builtin.file', role_path + '/files/' + MD_Extended.vxlan.fabric.name + '_changes_detected_flags.json') | from_json }}" - tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml + tags: "{{ nac_tags.common_role }}" delegate_to: localhost - name: Set Change Flags Fact ansible.builtin.set_fact: change_flags: "{{ change_flag_data[MD_Extended.vxlan.fabric.name][MD_Extended.vxlan.fabric.type] }}" - tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml + tags: "{{ nac_tags.common_role }}" delegate_to: localhost - name: Display Flag Values @@ -161,8 +73,5 @@ fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" role_path: "{{ role_path }}" operation: "display" - tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml + tags: "{{ nac_tags.common_role }}" delegate_to: localhost - -- debug: msg="{{ change_flags }}" - tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml diff --git a/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml b/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml index 589b9549a..f60b04df4 100644 --- a/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml +++ b/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml @@ -212,9 +212,11 @@ ansible.builtin.set_fact: vars_common_ebgp_vxlan: fabric_config: "{{ fabric_config }}" + # TODO: Why are these commented out (Here and above)? # fabric_links: "{{ fabric_links }}" interface_breakout: "{{ interface_breakout }}" interface_breakout_preprov: "{{ interface_breakout_preprov }}" + # TODO: Why are these commented out (Here and above)? # edge_connections: "{{ edge_connections }}" interface_access_po: "{{ interface_access_po }}" interface_access: "{{ interface_access }}" diff --git a/roles/dtc/create/tasks/main.yml b/roles/dtc/create/tasks/main.yml index 0cb0e888b..2b99ea444 100644 --- a/roles/dtc/create/tasks/main.yml +++ b/roles/dtc/create/tasks/main.yml @@ -21,70 +21,6 @@ --- -# - name: Import iBGP VXLAN Fabric Role Tasks -# ansible.builtin.import_tasks: sub_main_vxlan.yml -# when: > -# (MD_Extended.vxlan.fabric.type == 'VXLAN_EVPN') and -# (vars_common_vxlan.changes_detected_fabric) or -# (vars_common_vxlan.changes_detected_inventory) or -# (vars_common_vxlan.changes_detected_vpc_peering) or -# (vars_common_vxlan.changes_detected_interfaces) or -# (vars_common_vxlan.changes_detected_link_vpc_peering) or -# (vars_common_vxlan.changes_detected_vrfs) or -# (vars_common_vxlan.changes_detected_networks) or -# (vars_common_vxlan.changes_detected_policy) or -# (vars_common_vxlan.changes_detected_edge_connections) or -# (vars_common_vxlan.changes_detected_fabric_links) or -# (vars_common_vxlan.changes_detected_underlay_ip_address) or -# (vars_common_vxlan.changes_detected_vpc_domain_id_resource) - -# - name: Import eBGP VXLAN Fabric Role Tasks -# ansible.builtin.import_tasks: sub_main_ebgp_vxlan.yml -# when: > -# (MD_Extended.vxlan.fabric.type == 'eBGP_VXLAN') and -# (vars_common_ebgp_vxlan.changes_detected_fabric) or -# (vars_common_ebgp_vxlan.changes_detected_inventory) or -# (vars_common_ebgp_vxlan.changes_detected_vpc_peering) or -# (vars_common_ebgp_vxlan.changes_detected_link_vpc_peering) or -# (vars_common_ebgp_vxlan.changes_detected_policy) or -# (vars_common_ebgp_vxlan.changes_detected_interfaces) or -# (vars_common_ebgp_vxlan.changes_detected_vrfs) or -# (vars_common_ebgp_vxlan.changes_detected_networks) - -# - name: Import ISN Fabric Role Tasks -# ansible.builtin.import_tasks: sub_main_isn.yml -# when: > -# (MD_Extended.vxlan.fabric.type == 'ISN') and -# (vars_common_isn.changes_detected_fabric) or -# (vars_common_isn.changes_detected_inventory) or -# (vars_common_isn.changes_detected_interfaces) or -# (vars_common_isn.changes_detected_policy) - -# - name: Import MSD Fabric Role Tasks -# ansible.builtin.import_tasks: sub_main_msd.yml -# when: > -# (MD_Extended.vxlan.fabric.type == 'MSD') - -# # Check with Matt and Pete on External Fabrics -# - name: Import External Fabric Role Tasks -# ansible.builtin.import_tasks: sub_main_external.yml -# when: > -# (MD_Extended.vxlan.fabric.type == 'External') and -# (vars_common_external.changes_detected_inventory) or -# (vars_common_external.changes_detected_interfaces) or -# (vars_common_external.changes_detected_fabric) or -# (vars_common_external.changes_detected_interface_access_po) or -# (vars_common_external.changes_detected_interface_access) or -# (vars_common_external.changes_detected_interface_loopback) or -# (vars_common_external.changes_detected_interface_po_routed) or -# (vars_common_external.changes_detected_interface_routed) or -# (vars_common_external.changes_detected_interface_trunk_po) or -# (vars_common_external.changes_detected_interface_trunk) or -# (vars_common_external.changes_detected_sub_interface_routed) or -# (vars_common_external.changes_detected_policy) - -- debug: msg="{{ change_flags }}" - - name: Import iBGP VXLAN Fabric Role Tasks ansible.builtin.import_tasks: sub_main_vxlan.yml when: diff --git a/roles/dtc/remove/tasks/common/edge_connections.yml b/roles/dtc/remove/tasks/common/edge_connections.yml index 831479450..c5f4580ef 100644 --- a/roles/dtc/remove/tasks/common/edge_connections.yml +++ b/roles/dtc/remove/tasks/common/edge_connections.yml @@ -61,7 +61,7 @@ fabric: "{{ MD_Extended.vxlan.fabric.name }}" use_desc_as_key: true config: "{{ unmanaged_edge_connections_config.unmanaged_edge_connections }}" - deploy: true + deploy: false state: deleted when: unmanaged_edge_connections_config.unmanaged_edge_connections | length > 0 vars: diff --git a/roles/dtc/remove/tasks/common/interfaces.yml b/roles/dtc/remove/tasks/common/interfaces.yml index e371b35c3..7d0390fe3 100644 --- a/roles/dtc/remove/tasks/common/interfaces.yml +++ b/roles/dtc/remove/tasks/common/interfaces.yml @@ -85,6 +85,9 @@ - run_map_read_result.diff_run is true|bool - force_run_all is false|bool +# TODO: We need to replay port-channel member config here if we delete the PC +# AND the members are defined in the data model + # ----------------------------------------------------------------------------- # Remove Interfaces Default Mode # ----------------------------------------------------------------------------- diff --git a/roles/dtc/remove/tasks/common/links.yml b/roles/dtc/remove/tasks/common/links.yml index 0250e36e1..1737878b0 100644 --- a/roles/dtc/remove/tasks/common/links.yml +++ b/roles/dtc/remove/tasks/common/links.yml @@ -32,6 +32,7 @@ state: replaced src_fabric: "{{ MD_Extended.vxlan.fabric.name }}" config: "{{ vars_common_vxlan.link_vpc_peering }}" + deploy: false vars: ansible_command_timeout: 3000 ansible_connect_timeout: 3000 diff --git a/roles/dtc/remove/tasks/common/policy.yml b/roles/dtc/remove/tasks/common/policy.yml index 206ac2668..8967c7236 100644 --- a/roles/dtc/remove/tasks/common/policy.yml +++ b/roles/dtc/remove/tasks/common/policy.yml @@ -71,7 +71,7 @@ fabric: "{{ MD_Extended.vxlan.fabric.name }}" use_desc_as_key: true config: "{{ unmanaged_policy_config.unmanaged_policies }}" - deploy: true + deploy: false state: deleted when: unmanaged_policy_config.unmanaged_policies | length > 0 vars: diff --git a/roles/dtc/remove/tasks/common/switches.yml b/roles/dtc/remove/tasks/common/switches.yml index d890fb210..16be0e44a 100644 --- a/roles/dtc/remove/tasks/common/switches.yml +++ b/roles/dtc/remove/tasks/common/switches.yml @@ -55,8 +55,8 @@ cisco.dcnm.dcnm_inventory: fabric: "{{ MD_Extended.vxlan.fabric.name }}" config: "{{ vars_common_local.updated_inv_config_no_bootstrap['updated_inv_list'] }}" - deploy: true - save: true + deploy: false + save: false state: overridden vars: ansible_command_timeout: 3000 diff --git a/roles/dtc/remove/tasks/common/vpc_peers.yml b/roles/dtc/remove/tasks/common/vpc_peers.yml index a5231f1b2..526b3a2b6 100644 --- a/roles/dtc/remove/tasks/common/vpc_peers.yml +++ b/roles/dtc/remove/tasks/common/vpc_peers.yml @@ -55,7 +55,7 @@ - name: Remove Unmanaged Fabric vPC Peering in Nexus Dashboard - Diff Run True cisco.dcnm.dcnm_vpc_pair: src_fabric: "{{ MD_Extended.vxlan.fabric.name }}" - deploy: true + deploy: false state: deleted config: "{{ vars_common_local.vpc_peering_diff_result.removed }}" vars: @@ -77,7 +77,7 @@ - name: Remove Unmanaged vPC Peering from Nexus Dashboard - Diff Run False cisco.dcnm.dcnm_vpc_pair: src_fabric: "{{ MD_Extended.vxlan.fabric.name }}" - deploy: true + deploy: false state: overridden config: "{{ vars_common_local.vpc_peering }}" vars: From 8d8767e51e6bd959079926bbed49c8a5b7043f18 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Wed, 8 Oct 2025 23:03:56 -0400 Subject: [PATCH 25/65] Cleanup --- roles/common_global/vars/main.yml | 2 + .../common/tasks/common/ndfc_fabric_links.yml | 17 +- .../tasks/common/ndfc_interface_all.yml | 58 ++++--- .../tasks/common/ndfc_underlay_ip_address.yml | 2 +- .../common/ndfc_vpc_domain_id_resource.yml | 7 - .../tasks/common/ndfc_vpc_peering_pairs.yml | 9 +- .../dtc/common/tasks/external/ndfc_fabric.yml | 93 ----------- .../tasks/external/ndfc_interface_access.yml | 98 ------------ .../external/ndfc_interface_access_po.yml | 98 ------------ .../tasks/external/ndfc_interface_all.yml | 107 ------------- .../external/ndfc_interface_loopback.yml | 101 ------------ .../external/ndfc_interface_po_routed.yml | 98 ------------ .../tasks/external/ndfc_interface_routed.yml | 98 ------------ .../tasks/external/ndfc_interface_trunk.yml | 98 ------------ .../external/ndfc_interface_trunk_po.yml | 98 ------------ .../tasks/external/ndfc_interface_vpc.yml | 98 ------------ .../dtc/common/tasks/external/ndfc_policy.yml | 94 ----------- .../external/ndfc_sub_interface_routed.yml | 98 ------------ .../tasks/external/ndfc_vpc_peering_pairs.yml | 15 +- .../tasks/isn/ndfc_inventory_no_bootstrap.yml | 83 ---------- .../dtc/common/tasks/sub_main_ebgp_vxlan.yml | 10 +- roles/dtc/common/tasks/sub_main_external.yml | 3 +- roles/dtc/common/tasks/sub_main_isn.yml | 3 +- roles/dtc/common/tasks/sub_main_vxlan.yml | 13 +- .../dtc/common/tasks/vxlan/ndfc_networks.yml | 22 ++- .../create/tasks/common/devices_discovery.yml | 10 +- roles/dtc/create/tasks/common/interfaces.yml | 10 +- roles/dtc/create/tasks/common/links.yml | 15 +- roles/dtc/create/tasks/common/vpc_peering.yml | 51 ++++-- .../tasks/common_vxlan/vrfs_networks.yml | 12 +- roles/dtc/create/tasks/external/devices.yml | 32 ---- .../tasks/external/devices_discovery.yml | 60 ------- .../dtc/create/tasks/external/interfaces.yml | 147 ------------------ roles/dtc/create/tasks/external/policies.yml | 41 ----- .../dtc/create/tasks/sub_main_ebgp_vxlan.yml | 7 +- roles/dtc/create/tasks/sub_main_vxlan.yml | 8 +- roles/dtc/deploy/tasks/main.yml | 105 ++----------- roles/dtc/remove/tasks/common/interfaces.yml | 2 +- roles/dtc/remove/tasks/common/vpc_peers.yml | 6 - .../remove/tasks/common_vxlan/networks.yml | 31 +++- 40 files changed, 176 insertions(+), 1784 deletions(-) delete mode 100644 roles/dtc/common/tasks/external/ndfc_fabric.yml delete mode 100644 roles/dtc/common/tasks/external/ndfc_interface_access.yml delete mode 100644 roles/dtc/common/tasks/external/ndfc_interface_access_po.yml delete mode 100644 roles/dtc/common/tasks/external/ndfc_interface_all.yml delete mode 100644 roles/dtc/common/tasks/external/ndfc_interface_loopback.yml delete mode 100644 roles/dtc/common/tasks/external/ndfc_interface_po_routed.yml delete mode 100644 roles/dtc/common/tasks/external/ndfc_interface_routed.yml delete mode 100644 roles/dtc/common/tasks/external/ndfc_interface_trunk.yml delete mode 100644 roles/dtc/common/tasks/external/ndfc_interface_trunk_po.yml delete mode 100644 roles/dtc/common/tasks/external/ndfc_interface_vpc.yml delete mode 100644 roles/dtc/common/tasks/external/ndfc_policy.yml delete mode 100644 roles/dtc/common/tasks/external/ndfc_sub_interface_routed.yml delete mode 100644 roles/dtc/common/tasks/isn/ndfc_inventory_no_bootstrap.yml delete mode 100644 roles/dtc/create/tasks/external/devices.yml delete mode 100644 roles/dtc/create/tasks/external/devices_discovery.yml delete mode 100644 roles/dtc/create/tasks/external/interfaces.yml delete mode 100644 roles/dtc/create/tasks/external/policies.yml diff --git a/roles/common_global/vars/main.yml b/roles/common_global/vars/main.yml index bb5a06a96..ef51aa27a 100644 --- a/roles/common_global/vars/main.yml +++ b/roles/common_global/vars/main.yml @@ -80,6 +80,7 @@ nac_tags: - cr_manage_interfaces - cr_manage_vrfs_networks - cr_manage_policy + - cr_manage_links - cr_manage_edge_connections - rr_manage_edge_connections - rr_manage_interfaces @@ -102,6 +103,7 @@ nac_tags: - cr_manage_interfaces - cr_manage_vrfs_networks - cr_manage_policy + - cr_manage_links - cr_manage_edge_connections - rr_manage_edge_connections - rr_manage_interfaces diff --git a/roles/dtc/common/tasks/common/ndfc_fabric_links.yml b/roles/dtc/common/tasks/common/ndfc_fabric_links.yml index e45725e4c..8959ea374 100644 --- a/roles/dtc/common/tasks/common/ndfc_fabric_links.yml +++ b/roles/dtc/common/tasks/common/ndfc_fabric_links.yml @@ -64,24 +64,15 @@ when: MD_Extended.vxlan.topology.fabric_links | length > 0 delegate_to: localhost -- cisco.nac_dc_vxlan.dtc.diff_compare: +- name: Build Fabric Links Diff Between Previous and Current Run + # This task must be run before the next task because + # dtc.diff_model_changes deletes the .old file if it exists + cisco.nac_dc_vxlan.dtc.diff_compare: old_file: "{{ path_name }}{{ file_name }}.old" new_file: "{{ path_name }}{{ file_name }}" register: fabric_links_diff_result delegate_to: localhost -- debug: msg="EQUAL {{ fabric_links_diff_result['equal'] }}" -- debug: msg="REMOVED {{ fabric_links_diff_result['removed'] }}" -- debug: msg="UPDATED {{ fabric_links_diff_result['updated'] }}" -- debug: msg="EQUAL {{ fabric_links_diff_result['equal'] | length }}" -- debug: msg="REMOVED {{ fabric_links_diff_result['removed'] | length }}" -- debug: msg="UPDATED {{ fabric_links_diff_result['updated'] | length }}" - -- name: Sleep for 5 seconds - ansible.builtin.pause: - seconds: 5 - delegate_to: localhost - - name: Get MD5 Diff Previous and Current Data Files cisco.nac_dc_vxlan.dtc.diff_model_changes: file_name_previous: "{{ path_name }}{{ file_name }}.old" diff --git a/roles/dtc/common/tasks/common/ndfc_interface_all.yml b/roles/dtc/common/tasks/common/ndfc_interface_all.yml index fc5978f84..4a1488e9a 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_all.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_all.yml @@ -46,32 +46,19 @@ delegate_to: localhost when: data_file_previous.stat.exists -- name: Set interface_all Var +- name: Set interface_all_remove_overridden Var ansible.builtin.set_fact: - interface_all: [] + interface_all_remove_overridden: [] delegate_to: localhost - -- name: Debug All Interface Variables - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "Interface Types:" - - " Breakout: {{ interface_breakout | default([]) }}" - - " Access: {{ interface_access | default([]) }}" - - " Access Port-Channel: {{ interface_access_po | default([]) }}" - - " Trunk: {{ interface_trunk | default([]) }}" - - " Trunk Port-Channel: {{ interface_trunk_po | default([]) }}" - - " Routed: {{ interface_routed | default([]) }}" - - " Port-Channel Routed: {{ interface_po_routed | default([]) }}" - - " Sub-Interface Routed: {{ sub_interface_routed | default([]) }}" - - " VPC: {{ interface_vpc | default([]) }}" - - " Loopback: {{ int_loopback_config | default([]) }}" - - " Dot1Q: {{ interface_dot1q | default([]) }}" +- name: Set interface_all_create Var + ansible.builtin.set_fact: + interface_all_create: [] + delegate_to: localhost - name: Set interface_all Var ansible.builtin.set_fact: - interface_all: "{{ + interface_all_remove_overridden: "{{ interface_breakout + interface_breakout_preprov + interface_trunk + @@ -90,9 +77,28 @@ MD_Extended.vxlan.topology.interfaces.modes.all.count > 0 delegate_to: localhost -- name: Save interface_all +- name: Set interface_all Var + ansible.builtin.set_fact: + interface_all_create: "{{ + interface_breakout + + interface_trunk + + interface_routed + + sub_interface_routed + + interface_access + + interface_trunk_po + + interface_access_po + + interface_po_routed + + int_loopback_config + + interface_dot1q + + interface_vpc }}" + when: > + MD_Extended.vxlan.topology.interfaces.modes.breakout.count > 0 or + MD_Extended.vxlan.topology.interfaces.modes.all.count > 0 + delegate_to: localhost + +- name: Save interface_all_create ansible.builtin.copy: - content: "{{ interface_all | to_nice_yaml }}" + content: "{{ interface_all_create | to_nice_yaml }}" dest: "{{ path_name }}{{ file_name }}" mode: preserve delegate_to: localhost @@ -106,14 +112,6 @@ register: interface_diff_result delegate_to: localhost -- debug: msg="EQUAL {{ interface_diff_result['equal'] | length }}" -- debug: msg="REMOVED {{ interface_diff_result['removed'] | length }}" -- debug: msg="UPDATED {{ interface_diff_result['updated'] | length }}" -- name: Sleep for 5 seconds - ansible.builtin.pause: - seconds: 5 - delegate_to: localhost - - name: Get MD5 Diff For Previous and Current Data Files cisco.nac_dc_vxlan.dtc.diff_model_changes: file_name_previous: "{{ path_name }}{{ file_name }}.old" diff --git a/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml b/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml index e196dbee7..800359086 100644 --- a/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml +++ b/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml @@ -67,7 +67,7 @@ - vxlan.underlay.general.manual_underlay_allocation delegate_to: localhost -- name: Build underlay_ip_address Diff Between Previous and Current Run +- name: Build Underlay IP Address Diff Between Previous and Current Run # This task must be run before the next task because # dtc.diff_model_changes deletes the .old file if it exists cisco.nac_dc_vxlan.dtc.diff_compare: diff --git a/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml b/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml index cb93401b3..a1509ac67 100644 --- a/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml +++ b/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml @@ -73,13 +73,6 @@ register: vpc_domain_id_resource_diff_result delegate_to: localhost -- debug: msg="EQUAL {{ vpc_domain_id_resource_diff_result['equal'] }}" -- debug: msg="REMOVED {{ vpc_domain_id_resource_diff_result['removed'] }}" -- debug: msg="UPDATED {{ vpc_domain_id_resource_diff_result['updated'] }}" -- debug: msg="EQUAL {{ vpc_domain_id_resource_diff_result['equal'] | length }}" -- debug: msg="REMOVED {{ vpc_domain_id_resource_diff_result['removed'] | length }}" -- debug: msg="UPDATED {{ vpc_domain_id_resource_diff_result['updated'] | length }}" - - name: Get MD5 Diff Previous and Current Data Files cisco.nac_dc_vxlan.dtc.diff_model_changes: file_name_previous: "{{ path_name }}{{ file_name }}.old" diff --git a/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml b/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml index 7227fe7a8..b80f707e5 100644 --- a/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml +++ b/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates +# Copyright (c) 2025 Cisco Systems, Inc. and its affiliates # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -73,13 +73,6 @@ register: vpc_peering_diff_result delegate_to: localhost -- debug: msg="EQUAL {{ vpc_peering_diff_result['equal'] }}" -- debug: msg="REMOVED {{ vpc_peering_diff_result['removed'] }}" -- debug: msg="UPDATED {{ vpc_peering_diff_result['updated'] }}" -- debug: msg="EQUAL {{ vpc_peering_diff_result['equal'] | length }}" -- debug: msg="REMOVED {{ vpc_peering_diff_result['removed'] | length }}" -- debug: msg="UPDATED {{ vpc_peering_diff_result['updated'] | length }}" - - name: Get MD5 Diff Previous and Current Data Files cisco.nac_dc_vxlan.dtc.diff_model_changes: file_name_previous: "{{ path_name }}{{ file_name }}.old" diff --git a/roles/dtc/common/tasks/external/ndfc_fabric.yml b/roles/dtc/common/tasks/external/ndfc_fabric.yml deleted file mode 100644 index 2b94ed537..000000000 --- a/roles/dtc/common/tasks/external/ndfc_fabric.yml +++ /dev/null @@ -1,93 +0,0 @@ -# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in -# the Software without restriction, including without limitation the rights to -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -# the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# SPDX-License-Identifier: MIT - ---- - -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_fabric: false - delegate_to: localhost - -- name: Set file_name Var - ansible.builtin.set_fact: - file_name: "ndfc_fabric.yml" - delegate_to: localhost - -- name: Stat Previous File If It Exists - ansible.builtin.stat: - path: "{{ path_name }}{{ file_name }}" - register: data_file_previous - delegate_to: localhost - # TODO: Add capability to overridde path variable above for CI/CD pipeline - -- name: Backup Previous Data File If It Exists - ansible.builtin.copy: - src: "{{ path_name }}{{ file_name }}" - dest: "{{ path_name }}{{ file_name }}.old" - mode: preserve - when: data_file_previous.stat.exists - -- name: Delete Previous Data File If It Exists - ansible.builtin.file: - state: absent - path: "{{ path_name }}{{ file_name }}" - delegate_to: localhost - when: data_file_previous.stat.exists - -- name: Build Fabric Creation Parameters From Template - ansible.builtin.template: - src: ndfc_fabric.j2 - dest: "{{ path_name }}{{ file_name }}" - mode: '0644' - delegate_to: localhost - -- name: Set fabric_config Var - ansible.builtin.set_fact: - fabric_config: "{{ lookup('file', path_name + file_name) | from_yaml }}" - delegate_to: localhost - -- name: Diff Previous and Current Data Files - cisco.nac_dc_vxlan.dtc.diff_model_changes: - file_name_previous: "{{ path_name }}{{ file_name }}.old" - file_name_current: "{{ path_name }}{{ file_name }}" - register: file_diff_result - delegate_to: localhost - -- name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_fabric: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] - -- name: Set File Change Flag Based on File Diff Result - cisco.nac_dc_vxlan.common.change_flag_manager: - fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" - fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" - change_flag: changes_detected_fabric - flag_value: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_interface_access.yml b/roles/dtc/common/tasks/external/ndfc_interface_access.yml deleted file mode 100644 index f10aae6bc..000000000 --- a/roles/dtc/common/tasks/external/ndfc_interface_access.yml +++ /dev/null @@ -1,98 +0,0 @@ -# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in -# the Software without restriction, including without limitation the rights to -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -# the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# SPDX-License-Identifier: MIT - ---- - -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_interface_access: false - delegate_to: localhost - -- name: Set file_name Var - ansible.builtin.set_fact: - file_name: "ndfc_interface_access.yml" - delegate_to: localhost - -- name: Stat Previous File If It Exists - ansible.builtin.stat: - path: "{{ path_name }}{{ file_name }}" - register: data_file_previous - delegate_to: localhost - -- name: Backup Previous Data File If It Exists - ansible.builtin.copy: - src: "{{ path_name }}{{ file_name }}" - dest: "{{ path_name }}{{ file_name }}.old" - mode: preserve - when: data_file_previous.stat.exists - -- name: Delete Previous Data File If It Exists - ansible.builtin.file: - state: absent - path: "{{ path_name }}{{ file_name }}" - delegate_to: localhost - when: data_file_previous.stat.exists - -- name: Build Interface - ansible.builtin.template: - src: ndfc_interface_access.j2 - dest: "{{ path_name }}{{ file_name }}" - mode: '0644' - delegate_to: localhost - -- name: Set interface_access Var - ansible.builtin.set_fact: - interface_access: [] - delegate_to: localhost - -- name: Set interface_access Var - ansible.builtin.set_fact: - interface_access: "{{ lookup('file', path_name + file_name) | from_yaml }}" - when: MD_Extended.vxlan.topology.interfaces.modes.access.count > 0 - delegate_to: localhost - -- name: Diff Previous and Current Data Files - cisco.nac_dc_vxlan.dtc.diff_model_changes: - file_name_previous: "{{ path_name }}{{ file_name }}.old" - file_name_current: "{{ path_name }}{{ file_name }}" - register: file_diff_result - delegate_to: localhost - -- name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_interface_access: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] - -- name: Set File Change Flag Based on File Diff Result - cisco.nac_dc_vxlan.common.change_flag_manager: - fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" - fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" - change_flag: changes_detected_interface_access - flag_value: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_interface_access_po.yml b/roles/dtc/common/tasks/external/ndfc_interface_access_po.yml deleted file mode 100644 index 5689fa7e3..000000000 --- a/roles/dtc/common/tasks/external/ndfc_interface_access_po.yml +++ /dev/null @@ -1,98 +0,0 @@ -# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in -# the Software without restriction, including without limitation the rights to -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -# the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# SPDX-License-Identifier: MIT - ---- - -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_interface_access_po: false - delegate_to: localhost - -- name: Set file_name Var - ansible.builtin.set_fact: - file_name: "ndfc_interface_access_po.yml" - delegate_to: localhost - -- name: Stat Previous File If It Exists - ansible.builtin.stat: - path: "{{ path_name }}{{ file_name }}" - register: data_file_previous - delegate_to: localhost - -- name: Backup Previous Data File If It Exists - ansible.builtin.copy: - src: "{{ path_name }}{{ file_name }}" - dest: "{{ path_name }}{{ file_name }}.old" - mode: preserve - when: data_file_previous.stat.exists - -- name: Delete Previous Data File If It Exists - ansible.builtin.file: - state: absent - path: "{{ path_name }}{{ file_name }}" - delegate_to: localhost - when: data_file_previous.stat.exists - -- name: Build Interface - ansible.builtin.template: - src: ndfc_interface_access_po.j2 - dest: "{{ path_name }}{{ file_name }}" - mode: '0644' - delegate_to: localhost - -- name: Set interface_access_po Var - ansible.builtin.set_fact: - interface_access_po: [] - delegate_to: localhost - -- name: Set interface_access_po Var - ansible.builtin.set_fact: - interface_access_po: "{{ lookup('file', path_name + file_name) | from_yaml }}" - when: MD_Extended.vxlan.topology.interfaces.modes.access_po.count > 0 - delegate_to: localhost - -- name: Diff Previous and Current Data Files - cisco.nac_dc_vxlan.dtc.diff_model_changes: - file_name_previous: "{{ path_name }}{{ file_name }}.old" - file_name_current: "{{ path_name }}{{ file_name }}" - register: file_diff_result - delegate_to: localhost - -- name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_interface_access_po: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] - -- name: Set File Change Flag Based on File Diff Result - cisco.nac_dc_vxlan.common.change_flag_manager: - fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" - fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" - change_flag: changes_detected_interface_access_po - flag_value: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_interface_all.yml b/roles/dtc/common/tasks/external/ndfc_interface_all.yml deleted file mode 100644 index 4f082bca1..000000000 --- a/roles/dtc/common/tasks/external/ndfc_interface_all.yml +++ /dev/null @@ -1,107 +0,0 @@ -# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in -# the Software without restriction, including without limitation the rights to -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -# the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# SPDX-License-Identifier: MIT - ---- - -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_interfaces: false - delegate_to: localhost - -- name: Set file_name Var - ansible.builtin.set_fact: - file_name: "ndfc_interface_all.yml" - delegate_to: localhost - -- name: Stat Previous File If It Exists - ansible.builtin.stat: - path: "{{ path_name }}{{ file_name }}" - register: data_file_previous - delegate_to: localhost - -- name: Backup Previous Data File If It Exists - ansible.builtin.copy: - src: "{{ path_name }}{{ file_name }}" - dest: "{{ path_name }}{{ file_name }}.old" - mode: preserve - when: data_file_previous.stat.exists - -- name: Delete Previous Data File If It Exists - ansible.builtin.file: - state: absent - path: "{{ path_name }}{{ file_name }}" - delegate_to: localhost - when: data_file_previous.stat.exists - -- name: Set interface_all Var - ansible.builtin.set_fact: - interface_all: [] - delegate_to: localhost - -- name: Set interface_all Var - ansible.builtin.set_fact: - interface_all: > - "{{ interface_access + - interface_access_po + - interface_trunk + - interface_trunk_po + - interface_routed + - interface_po_routed + - sub_interface_routed + - interface_vpc + - int_loopback_config }}" - when: MD_Extended.vxlan.topology.interfaces.modes.all.count > 0 - delegate_to: localhost - -- name: Save interface_all - ansible.builtin.copy: - content: "{{ interface_all | to_nice_yaml }}" - dest: "{{ path_name }}{{ file_name }}" - mode: preserve - delegate_to: localhost - -- name: Diff Previous and Current Data Files - cisco.nac_dc_vxlan.dtc.diff_model_changes: - file_name_previous: "{{ path_name }}{{ file_name }}.old" - file_name_current: "{{ path_name }}{{ file_name }}" - register: file_diff_result - delegate_to: localhost - -- name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_interfaces: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] - -- name: Set File Change Flag Based on File Diff Result - cisco.nac_dc_vxlan.common.change_flag_manager: - fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" - fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" - change_flag: changes_detected_interfaces - flag_value: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_interface_loopback.yml b/roles/dtc/common/tasks/external/ndfc_interface_loopback.yml deleted file mode 100644 index eb74408eb..000000000 --- a/roles/dtc/common/tasks/external/ndfc_interface_loopback.yml +++ /dev/null @@ -1,101 +0,0 @@ -# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in -# the Software without restriction, including without limitation the rights to -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -# the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# SPDX-License-Identifier: MIT - ---- - -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_interface_loopback: false - delegate_to: localhost - -- name: Set file_name Var - ansible.builtin.set_fact: - file_name: "ndfc_loopback_interfaces.yml" - delegate_to: localhost - -- name: Stat Previous File If It Exists - ansible.builtin.stat: - path: "{{ path_name }}{{ file_name }}" - register: data_file_previous - delegate_to: localhost - -- name: Backup Previous Data File If It Exists - ansible.builtin.copy: - src: "{{ path_name }}{{ file_name }}" - dest: "{{ path_name }}{{ file_name }}.old" - mode: preserve - when: data_file_previous.stat.exists - -- name: Delete Previous Data File If It Exists - ansible.builtin.file: - state: absent - path: "{{ path_name }}{{ file_name }}" - delegate_to: localhost - when: data_file_previous.stat.exists - -- name: Build Loopback Interfaces List From Template - ansible.builtin.template: - src: ndfc_loopback_interfaces.j2 - dest: "{{ path_name }}{{ file_name }}" - mode: '0644' - delegate_to: localhost - -- name: Set int_loopback_config Var - ansible.builtin.set_fact: - int_loopback_config: [] - delegate_to: localhost - -- name: Set int_loopback_config Var - ansible.builtin.set_fact: - int_loopback_config: "{{ lookup('file', path_name + file_name) | from_yaml }}" - when: > - (MD_Extended.vxlan.topology.interfaces.modes.loopback.count > 0) or - (MD_Extended.vxlan.topology.interfaces.modes.fabric_loopback.count > 0) or - (MD_Extended.vxlan.topology.interfaces.modes.mpls_loopback.count > 0) - delegate_to: localhost - -- name: Diff Previous and Current Data Files - cisco.nac_dc_vxlan.dtc.diff_model_changes: - file_name_previous: "{{ path_name }}{{ file_name }}.old" - file_name_current: "{{ path_name }}{{ file_name }}" - register: file_diff_result - delegate_to: localhost - -- name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_interface_loopback: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] - -- name: Set File Change Flag Based on File Diff Result - cisco.nac_dc_vxlan.common.change_flag_manager: - fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" - fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" - change_flag: changes_detected_interface_loopback - flag_value: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_interface_po_routed.yml b/roles/dtc/common/tasks/external/ndfc_interface_po_routed.yml deleted file mode 100644 index 78c1a7a74..000000000 --- a/roles/dtc/common/tasks/external/ndfc_interface_po_routed.yml +++ /dev/null @@ -1,98 +0,0 @@ -# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in -# the Software without restriction, including without limitation the rights to -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -# the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# SPDX-License-Identifier: MIT - ---- - -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_interface_po_routed: false - delegate_to: localhost - -- name: Set file_name Var - ansible.builtin.set_fact: - file_name: "ndfc_interface_po_routed.yml" - delegate_to: localhost - -- name: Stat Previous File If It Exists - ansible.builtin.stat: - path: "{{ path_name }}{{ file_name }}" - register: data_file_previous - delegate_to: localhost - -- name: Backup Previous Data File If It Exists - ansible.builtin.copy: - src: "{{ path_name }}{{ file_name }}" - dest: "{{ path_name }}{{ file_name }}.old" - mode: preserve - when: data_file_previous.stat.exists - -- name: Delete Previous Data File If It Exists - ansible.builtin.file: - state: absent - path: "{{ path_name }}{{ file_name }}" - delegate_to: localhost - when: data_file_previous.stat.exists - -- name: Build Interface Po - ansible.builtin.template: - src: ndfc_interface_po_routed.j2 - dest: "{{ path_name }}{{ file_name }}" - mode: '0644' - delegate_to: localhost - -- name: Set interface_po_routed Var default - ansible.builtin.set_fact: - interface_po_routed: [] - delegate_to: localhost - -- name: Set interface_po_routed Var - ansible.builtin.set_fact: - interface_po_routed: "{{ lookup('file', path_name + file_name) | from_yaml }}" - when: MD_Extended.vxlan.topology.interfaces.modes.routed_po.count > 0 - delegate_to: localhost - -- name: Diff Previous and Current Data Files - cisco.nac_dc_vxlan.dtc.diff_model_changes: - file_name_previous: "{{ path_name }}{{ file_name }}.old" - file_name_current: "{{ path_name }}{{ file_name }}" - register: file_diff_result - delegate_to: localhost - -- name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_interface_po_routed: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] - -- name: Set File Change Flag Based on File Diff Result - cisco.nac_dc_vxlan.common.change_flag_manager: - fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" - fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" - change_flag: changes_detected_interface_po_routed - flag_value: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_interface_routed.yml b/roles/dtc/common/tasks/external/ndfc_interface_routed.yml deleted file mode 100644 index 6dedd3265..000000000 --- a/roles/dtc/common/tasks/external/ndfc_interface_routed.yml +++ /dev/null @@ -1,98 +0,0 @@ -# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in -# the Software without restriction, including without limitation the rights to -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -# the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# SPDX-License-Identifier: MIT - ---- - -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_interface_routed: false - delegate_to: localhost - -- name: Set file_name Var - ansible.builtin.set_fact: - file_name: "ndfc_interface_routed.yml" - delegate_to: localhost - -- name: Stat Previous File If It Exists - ansible.builtin.stat: - path: "{{ path_name }}{{ file_name }}" - register: data_file_previous - delegate_to: localhost - -- name: Backup Previous Data File If It Exists - ansible.builtin.copy: - src: "{{ path_name }}{{ file_name }}" - dest: "{{ path_name }}{{ file_name }}.old" - mode: preserve - when: data_file_previous.stat.exists - -- name: Delete Previous Data File If It Exists - ansible.builtin.file: - state: absent - path: "{{ path_name }}{{ file_name }}" - delegate_to: localhost - when: data_file_previous.stat.exists - -- name: Build Interface - ansible.builtin.template: - src: ndfc_interface_routed.j2 - dest: "{{ path_name }}{{ file_name }}" - mode: '0644' - delegate_to: localhost - -- name: Set interface_routed Var default - ansible.builtin.set_fact: - interface_routed: [] - delegate_to: localhost - -- name: Set interface_routed Var - ansible.builtin.set_fact: - interface_routed: "{{ lookup('file', path_name + file_name) | from_yaml }}" - when: MD_Extended.vxlan.topology.interfaces.modes.routed.count > 0 - delegate_to: localhost - -- name: Diff Previous and Current Data Files - cisco.nac_dc_vxlan.dtc.diff_model_changes: - file_name_previous: "{{ path_name }}{{ file_name }}.old" - file_name_current: "{{ path_name }}{{ file_name }}" - register: file_diff_result - delegate_to: localhost - -- name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_interface_routed: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] - -- name: Set File Change Flag Based on File Diff Result - cisco.nac_dc_vxlan.common.change_flag_manager: - fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" - fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" - change_flag: changes_detected_interface_routed - flag_value: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_interface_trunk.yml b/roles/dtc/common/tasks/external/ndfc_interface_trunk.yml deleted file mode 100644 index aaf446260..000000000 --- a/roles/dtc/common/tasks/external/ndfc_interface_trunk.yml +++ /dev/null @@ -1,98 +0,0 @@ -# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in -# the Software without restriction, including without limitation the rights to -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -# the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# SPDX-License-Identifier: MIT - ---- - -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_interface_trunk: false - delegate_to: localhost - -- name: Set file_name Var - ansible.builtin.set_fact: - file_name: "ndfc_interface_trunk.yml" - delegate_to: localhost - -- name: Stat Previous File If It Exists - ansible.builtin.stat: - path: "{{ path_name }}{{ file_name }}" - register: data_file_previous - delegate_to: localhost - -- name: Backup Previous Data File If It Exists - ansible.builtin.copy: - src: "{{ path_name }}{{ file_name }}" - dest: "{{ path_name }}{{ file_name }}.old" - mode: preserve - when: data_file_previous.stat.exists - -- name: Delete Previous Data File If It Exists - ansible.builtin.file: - state: absent - path: "{{ path_name }}{{ file_name }}" - delegate_to: localhost - when: data_file_previous.stat.exists - -- name: Build Interface - ansible.builtin.template: - src: ndfc_interface_trunk.j2 - dest: "{{ path_name }}{{ file_name }}" - mode: '0644' - delegate_to: localhost - -- name: Set interface_trunk Var - ansible.builtin.set_fact: - interface_trunk: [] - delegate_to: localhost - -- name: Set interface_trunk Var - ansible.builtin.set_fact: - interface_trunk: "{{ lookup('file', path_name + file_name) | from_yaml }}" - when: MD_Extended.vxlan.topology.interfaces.modes.trunk.count > 0 - delegate_to: localhost - -- name: Diff Previous and Current Data Files - cisco.nac_dc_vxlan.dtc.diff_model_changes: - file_name_previous: "{{ path_name }}{{ file_name }}.old" - file_name_current: "{{ path_name }}{{ file_name }}" - register: file_diff_result - delegate_to: localhost - -- name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_interface_trunk: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] - -- name: Set File Change Flag Based on File Diff Result - cisco.nac_dc_vxlan.common.change_flag_manager: - fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" - fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" - change_flag: changes_detected_interface_trunk - flag_value: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_interface_trunk_po.yml b/roles/dtc/common/tasks/external/ndfc_interface_trunk_po.yml deleted file mode 100644 index 52e21b47d..000000000 --- a/roles/dtc/common/tasks/external/ndfc_interface_trunk_po.yml +++ /dev/null @@ -1,98 +0,0 @@ -# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in -# the Software without restriction, including without limitation the rights to -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -# the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# SPDX-License-Identifier: MIT - ---- - -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_interface_trunk_po: false - delegate_to: localhost - -- name: Set file_name Var - ansible.builtin.set_fact: - file_name: "ndfc_interface_trunk_po.yml" - delegate_to: localhost - -- name: Stat Previous File If It Exists - ansible.builtin.stat: - path: "{{ path_name }}{{ file_name }}" - register: data_file_previous - delegate_to: localhost - -- name: Backup Previous Data File If It Exists - ansible.builtin.copy: - src: "{{ path_name }}{{ file_name }}" - dest: "{{ path_name }}{{ file_name }}.old" - mode: preserve - when: data_file_previous.stat.exists - -- name: Delete Previous Data File If It Exists - ansible.builtin.file: - state: absent - path: "{{ path_name }}{{ file_name }}" - delegate_to: localhost - when: data_file_previous.stat.exists - -- name: Build Interface - ansible.builtin.template: - src: ndfc_interface_trunk_po.j2 - dest: "{{ path_name }}{{ file_name }}" - mode: '0644' - delegate_to: localhost - -- name: Set interface_trunk_po Var - ansible.builtin.set_fact: - interface_trunk_po: [] - delegate_to: localhost - -- name: Set interface_trunk_po Var - ansible.builtin.set_fact: - interface_trunk_po: "{{ lookup('file', path_name + file_name) | from_yaml }}" - when: MD_Extended.vxlan.topology.interfaces.modes.trunk_po.count > 0 - delegate_to: localhost - -- name: Diff Previous and Current Data Files - cisco.nac_dc_vxlan.dtc.diff_model_changes: - file_name_previous: "{{ path_name }}{{ file_name }}.old" - file_name_current: "{{ path_name }}{{ file_name }}" - register: file_diff_result - delegate_to: localhost - -- name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_interface_trunk_po: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] - -- name: Set File Change Flag Based on File Diff Result - cisco.nac_dc_vxlan.common.change_flag_manager: - fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" - fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" - change_flag: changes_detected_interface_trunk_po - flag_value: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_interface_vpc.yml b/roles/dtc/common/tasks/external/ndfc_interface_vpc.yml deleted file mode 100644 index d31e655c4..000000000 --- a/roles/dtc/common/tasks/external/ndfc_interface_vpc.yml +++ /dev/null @@ -1,98 +0,0 @@ -# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in -# the Software without restriction, including without limitation the rights to -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -# the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# SPDX-License-Identifier: MIT - ---- - -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_interface_vpc: false - delegate_to: localhost - -- name: Set file_name Var - ansible.builtin.set_fact: - file_name: "ndfc_interface_vpc.yml" - delegate_to: localhost - -- name: Stat Previous File If It Exists - ansible.builtin.stat: - path: "{{ path_name }}{{ file_name }}" - register: data_file_previous - delegate_to: localhost - -- name: Backup Previous Data File If It Exists - ansible.builtin.copy: - src: "{{ path_name }}{{ file_name }}" - dest: "{{ path_name }}{{ file_name }}.old" - mode: preserve - when: data_file_previous.stat.exists - -- name: Delete Previous Data File If It Exists - ansible.builtin.file: - state: absent - path: "{{ path_name }}{{ file_name }}" - delegate_to: localhost - when: data_file_previous.stat.exists - -- name: Build vPC interface - ansible.builtin.template: - src: ndfc_interface_vpc.j2 - dest: "{{ path_name }}{{ file_name }}" - mode: '0644' - delegate_to: localhost - -- name: Set interface_vpc Var default - ansible.builtin.set_fact: - interface_vpc: [] - delegate_to: localhost - -- name: Set interface_vpc Var - ansible.builtin.set_fact: - interface_vpc: "{{ lookup('file', path_name + file_name) | from_yaml }}" - when: MD_Extended.vxlan.topology.interfaces.modes.access_vpc.count > 0 or MD_Extended.vxlan.topology.interfaces.modes.trunk_vpc.count > 0 - delegate_to: localhost - -- name: Diff Previous and Current Data Files - cisco.nac_dc_vxlan.dtc.diff_model_changes: - file_name_previous: "{{ path_name }}{{ file_name }}.old" - file_name_current: "{{ path_name }}{{ file_name }}" - register: file_diff_result - delegate_to: localhost - -- name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_interface_vpc: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] - -- name: Set File Change Flag Based on File Diff Result - cisco.nac_dc_vxlan.common.change_flag_manager: - fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" - fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" - change_flag: changes_detected_interface_vpc - flag_value: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_policy.yml b/roles/dtc/common/tasks/external/ndfc_policy.yml deleted file mode 100644 index 7e0a7d258..000000000 --- a/roles/dtc/common/tasks/external/ndfc_policy.yml +++ /dev/null @@ -1,94 +0,0 @@ -# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in -# the Software without restriction, including without limitation the rights to -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -# the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# SPDX-License-Identifier: MIT - ---- - -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_policy: false - delegate_to: localhost - -- name: Set file_name Var - ansible.builtin.set_fact: - file_name: "ndfc_policy.yml" - delegate_to: localhost - -- name: Stat Previous File If It Exists - ansible.builtin.stat: - path: "{{ path_name }}{{ file_name }}" - register: data_file_previous - delegate_to: localhost - # TODO: Add capability to overridde path variable above for CI/CD pipeline - -- name: Backup Previous Data File If It Exists - ansible.builtin.copy: - src: "{{ path_name }}{{ file_name }}" - dest: "{{ path_name }}{{ file_name }}.old" - mode: preserve - when: data_file_previous.stat.exists - -- name: Delete Previous Data File If It Exists - ansible.builtin.file: - state: absent - path: "{{ path_name }}{{ file_name }}" - delegate_to: localhost - when: data_file_previous.stat.exists - -- name: Build Policy List From Template - ansible.builtin.template: - src: ndfc_policy.j2 - dest: "{{ path_name }}{{ file_name }}" - mode: '0644' - delegate_to: localhost - -- name: Set policy_config Var - ansible.builtin.set_fact: - policy_config: "{{ lookup('file', path_name + file_name) | from_yaml }}" - when: (MD_Extended.vxlan.policy.policies | default([])) | length > 0 - delegate_to: localhost - -- name: Diff Previous and Current Data Files - cisco.nac_dc_vxlan.dtc.diff_model_changes: - file_name_previous: "{{ path_name }}{{ file_name }}.old" - file_name_current: "{{ path_name }}{{ file_name }}" - register: file_diff_result - delegate_to: localhost - -- name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_policy: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] - -- name: Set File Change Flag Based on File Diff Result - cisco.nac_dc_vxlan.common.change_flag_manager: - fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" - fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" - change_flag: changes_detected_policy - flag_value: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_sub_interface_routed.yml b/roles/dtc/common/tasks/external/ndfc_sub_interface_routed.yml deleted file mode 100644 index 7bbe70d8e..000000000 --- a/roles/dtc/common/tasks/external/ndfc_sub_interface_routed.yml +++ /dev/null @@ -1,98 +0,0 @@ -# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in -# the Software without restriction, including without limitation the rights to -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -# the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# SPDX-License-Identifier: MIT - ---- - -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_sub_interface_routed: false - delegate_to: localhost - -- name: Set file_name Var - ansible.builtin.set_fact: - file_name: "ndfc_sub_interface_routed.yml" - delegate_to: localhost - -- name: Stat Previous File If It Exists - ansible.builtin.stat: - path: "{{ path_name }}{{ file_name }}" - register: data_file_previous - delegate_to: localhost - -- name: Backup Previous Data File If It Exists - ansible.builtin.copy: - src: "{{ path_name }}{{ file_name }}" - dest: "{{ path_name }}{{ file_name }}.old" - mode: preserve - when: data_file_previous.stat.exists - -- name: Delete Previous Data File If It Exists - ansible.builtin.file: - state: absent - path: "{{ path_name }}{{ file_name }}" - delegate_to: localhost - when: data_file_previous.stat.exists - -- name: Build sub_interface - ansible.builtin.template: - src: ndfc_sub_interface_routed.j2 - dest: "{{ path_name }}{{ file_name }}" - mode: '0644' - delegate_to: localhost - -- name: Set sub_interface_routed Var default - ansible.builtin.set_fact: - sub_interface_routed: [] - delegate_to: localhost - -- name: Set sub_interface_routed Var - ansible.builtin.set_fact: - sub_interface_routed: "{{ lookup('file', path_name + file_name) | from_yaml }}" - when: MD_Extended.vxlan.topology.interfaces.modes.routed_sub.count > 0 - delegate_to: localhost - -- name: Diff Previous and Current Data Files - cisco.nac_dc_vxlan.dtc.diff_model_changes: - file_name_previous: "{{ path_name }}{{ file_name }}.old" - file_name_current: "{{ path_name }}{{ file_name }}" - register: file_diff_result - delegate_to: localhost - -- name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_sub_interface_routed: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] - -- name: Set File Change Flag Based on File Diff Result - cisco.nac_dc_vxlan.common.change_flag_manager: - fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" - fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" - change_flag: changes_detected_sub_interface_routed - flag_value: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] diff --git a/roles/dtc/common/tasks/external/ndfc_vpc_peering_pairs.yml b/roles/dtc/common/tasks/external/ndfc_vpc_peering_pairs.yml index 009373f24..5ecc936dd 100644 --- a/roles/dtc/common/tasks/external/ndfc_vpc_peering_pairs.yml +++ b/roles/dtc/common/tasks/external/ndfc_vpc_peering_pairs.yml @@ -21,11 +21,6 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_vpc_peering: false - delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_vpc_peering.yml" @@ -83,21 +78,13 @@ register: vpc_peering_diff_result delegate_to: localhost -- name: Diff Previous and Current Data Files +- name: Get MD5 Diff Previous and Current Data Files cisco.nac_dc_vxlan.dtc.diff_model_changes: file_name_previous: "{{ path_name }}{{ file_name }}.old" file_name_current: "{{ path_name }}{{ file_name }}" register: file_diff_result delegate_to: localhost -- name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_vpc_peering: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/isn/ndfc_inventory_no_bootstrap.yml b/roles/dtc/common/tasks/isn/ndfc_inventory_no_bootstrap.yml deleted file mode 100644 index c23498aed..000000000 --- a/roles/dtc/common/tasks/isn/ndfc_inventory_no_bootstrap.yml +++ /dev/null @@ -1,83 +0,0 @@ -# Copyright (c) 2025 Cisco Systems, Inc. and its affiliates -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in -# the Software without restriction, including without limitation the rights to -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -# the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# SPDX-License-Identifier: MIT - ---- - -- name: Set file_name Var - ansible.builtin.set_fact: - file_name: "ndfc_inventory_no_bootstrap.yml" - delegate_to: localhost - -- name: Stat Previous File If It Exists - ansible.builtin.stat: - path: "{{ path_name }}{{ file_name }}" - register: data_file_previous - delegate_to: localhost - -- name: Backup Previous Data File If It Exists - ansible.builtin.copy: - src: "{{ path_name }}{{ file_name }}" - dest: "{{ path_name }}{{ file_name }}.old" - mode: preserve - when: data_file_previous.stat.exists - -- name: Delete Previous Data File If It Exists - ansible.builtin.file: - state: absent - path: "{{ path_name }}{{ file_name }}" - delegate_to: localhost - when: data_file_previous.stat.exists - -- name: Set Path For Inventory File Lookup - ansible.builtin.set_fact: - inv_file_path: "{{ path_name }}{{ file_name }}" - delegate_to: localhost - -- name: Build Fabric Switch Inventory List From Template - ansible.builtin.template: - src: ndfc_inventory/isn_fabric/isn_fabric_inventory_no_bootstrap.j2 - dest: "{{ inv_file_path }}" - mode: '0644' - delegate_to: localhost - -- name: Create Empty inv_config Var - ansible.builtin.set_fact: - inv_config_no_bootstrap: [] - delegate_to: localhost - -- name: Set inv_config Var - ansible.builtin.set_fact: - inv_config_no_bootstrap: "{{ lookup('file', path_name + file_name) | from_yaml }}" - when: (MD_Extended.vxlan.topology.switches | default([])) | length > 0 - delegate_to: localhost - -- name: Retrieve NDFC Device Username and Password from Group Vars and update inv_config - cisco.nac_dc_vxlan.common.get_credentials: - inv_list: "{{ inv_config_no_bootstrap }}" - model_data: "{{ MD_Extended }}" - register: updated_inv_config_no_bootstrap - no_log: true - -- name: Credential Retrieval Failed - ansible.builtin.fail: - msg: "{{ updated_inv_config }}" - when: updated_inv_config_no_bootstrap['retrieve_failed'] - delegate_to: localhost diff --git a/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml b/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml index f60b04df4..6aa799918 100644 --- a/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml +++ b/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml @@ -220,8 +220,8 @@ # edge_connections: "{{ edge_connections }}" interface_access_po: "{{ interface_access_po }}" interface_access: "{{ interface_access }}" - interface_all: "{{ interface_all }}" - interface_diff_result: "{{ interface_diff_result }}" + interface_all_create: "{{ interface_all_create }}" + interface_all_remove_overridden: "{{ interface_all_remove_overridden }}" int_loopback_config: "{{ int_loopback_config }}" interface_po_routed: "{{ interface_po_routed }}" interface_routed: "{{ interface_routed }}" @@ -238,7 +238,11 @@ updated_inv_config: "{{ updated_inv_config }}" updated_inv_config_no_bootstrap: "{{ updated_inv_config_no_bootstrap }}" vpc_peering: "{{ vpc_peering }}" - vpc_peering_diff_result: "{{ vpc_peering_diff_result }}" vpc_domain_id_resource: "{{ vpc_domain_id_resource }}" vrf_config: "{{ vrf_config }}" vrf_attach_config: "{{ vrf_attach_config }}" + # Diff Result Data + interface_diff_result: "{{ interface_diff_result }}" + network_diff_result: "{{ network_diff_result }}" + vpc_peering_diff_result: "{{ vpc_peering_diff_result }}" + vpc_domain_id_resource_diff_result: "{{ vpc_domain_id_resource_diff_result }}" diff --git a/roles/dtc/common/tasks/sub_main_external.yml b/roles/dtc/common/tasks/sub_main_external.yml index 3d96023bd..b3bc10dcf 100644 --- a/roles/dtc/common/tasks/sub_main_external.yml +++ b/roles/dtc/common/tasks/sub_main_external.yml @@ -183,7 +183,8 @@ interface_breakout_preprov: "{{ interface_breakout_preprov }}" interface_access_po: "{{ interface_access_po }}" interface_access: "{{ interface_access }}" - interface_all: "{{ interface_all }}" + interface_all_create: "{{ interface_all_create }}" + interface_all_remove_overridden: "{{ interface_all_remove_overridden }}" interface_diff_result: "{{ interface_diff_result }}" int_loopback_config: "{{ int_loopback_config }}" interface_po_routed: "{{ interface_po_routed }}" diff --git a/roles/dtc/common/tasks/sub_main_isn.yml b/roles/dtc/common/tasks/sub_main_isn.yml index 93b2827fc..571f2dd5c 100644 --- a/roles/dtc/common/tasks/sub_main_isn.yml +++ b/roles/dtc/common/tasks/sub_main_isn.yml @@ -175,7 +175,8 @@ interface_breakout_preprov: "{{ interface_breakout_preprov }}" interface_access_po: "{{ interface_access_po }}" interface_access: "{{ interface_access }}" - interface_all: "{{ interface_all }}" + interface_all_create: "{{ interface_all_create }}" + interface_all_remove_overridden: "{{ interface_all_remove_overridden }}" interface_diff_result: "{{ interface_diff_result }}" int_loopback_config: "{{ int_loopback_config }}" interface_po_routed: "{{ interface_po_routed }}" diff --git a/roles/dtc/common/tasks/sub_main_vxlan.yml b/roles/dtc/common/tasks/sub_main_vxlan.yml index 6a51d9da9..5e9cb3f35 100644 --- a/roles/dtc/common/tasks/sub_main_vxlan.yml +++ b/roles/dtc/common/tasks/sub_main_vxlan.yml @@ -221,14 +221,13 @@ vars_common_vxlan: fabric_config: "{{ fabric_config }}" fabric_links: "{{ fabric_links }}" - fabric_links_diff_result: "{{ fabric_links_diff_result }}" edge_connections: "{{ edge_connections }}" interface_breakout: "{{ interface_breakout }}" interface_breakout_preprov: "{{ interface_breakout_preprov }}" interface_access_po: "{{ interface_access_po }}" interface_access: "{{ interface_access }}" - interface_all: "{{ interface_all }}" - interface_diff_result: "{{ interface_diff_result }}" + interface_all_create: "{{ interface_all_create }}" + interface_all_remove_overridden: "{{ interface_all_remove_overridden }}" int_loopback_config: "{{ int_loopback_config }}" interface_po_routed: "{{ interface_po_routed }}" interface_routed: "{{ interface_routed }}" @@ -245,10 +244,14 @@ updated_inv_config: "{{ updated_inv_config }}" updated_inv_config_no_bootstrap: "{{ updated_inv_config_no_bootstrap }}" vpc_peering: "{{ vpc_peering }}" - vpc_peering_diff_result: "{{ vpc_peering_diff_result }}" vpc_domain_id_resource: "{{ vpc_domain_id_resource }}" - vpc_domain_id_resource_diff_result: "{{ vpc_domain_id_resource_diff_result }}" vrf_config: "{{ vrf_config }}" vrf_attach_config: "{{ vrf_attach_config }}" underlay_ip_address: "{{ underlay_ip_address }}" + # Diff Result Data + fabric_links_diff_result: "{{ fabric_links_diff_result }}" + interface_diff_result: "{{ interface_diff_result }}" + network_diff_result: "{{ network_diff_result }}" + vpc_peering_diff_result: "{{ vpc_peering_diff_result }}" + vpc_domain_id_resource_diff_result: "{{ vpc_domain_id_resource_diff_result }}" underlay_ip_address_diff_result: "{{ underlay_ip_address_diff_result }}" diff --git a/roles/dtc/common/tasks/vxlan/ndfc_networks.yml b/roles/dtc/common/tasks/vxlan/ndfc_networks.yml index 8e7bcf2a5..f11f895d3 100644 --- a/roles/dtc/common/tasks/vxlan/ndfc_networks.yml +++ b/roles/dtc/common/tasks/vxlan/ndfc_networks.yml @@ -21,11 +21,6 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_networks: false - delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_attach_networks.yml" @@ -70,6 +65,15 @@ (MD_Extended.vxlan.overlay.networks | default([])) | length > 0 delegate_to: localhost +- name: Build vPC Domain ID Diff Between Previous and Current Run + # This task must be run before the next task because + # dtc.diff_model_changes deletes the .old file if it exists + cisco.nac_dc_vxlan.dtc.diff_compare: + old_file: "{{ path_name }}{{ file_name }}.old" + new_file: "{{ path_name }}{{ file_name }}" + register: network_diff_result + delegate_to: localhost + - name: Diff Previous and Current Data Files cisco.nac_dc_vxlan.dtc.diff_model_changes: file_name_previous: "{{ path_name }}{{ file_name }}.old" @@ -77,14 +81,6 @@ register: file_diff_result delegate_to: localhost -- name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_networks: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/create/tasks/common/devices_discovery.yml b/roles/dtc/create/tasks/common/devices_discovery.yml index 01abfc316..d8bd6dfe8 100644 --- a/roles/dtc/create/tasks/common/devices_discovery.yml +++ b/roles/dtc/create/tasks/common/devices_discovery.yml @@ -60,13 +60,6 @@ - MD_Extended.vxlan.topology.switches | length > 0 - change_flags.changes_detected_inventory -# - debug: msg="{{ vars_common_local.underlay_ip_address_diff_result.updated }}" -# - debug: msg="{{ vars_common_local.underlay_ip_address_diff_result.updated | length }}" - -- name: Sleep for 5 seconds - ansible.builtin.pause: - seconds: 5 - - name: Allocate Underlay IP Address cisco.dcnm.dcnm_resource_manager: state: merged @@ -76,8 +69,7 @@ when: - MD_Extended.vxlan.underlay.general.manual_underlay_allocation is defined - MD_Extended.vxlan.underlay.general.manual_underlay_allocation - # - (change_flags.changes_detected_underlay_ip_address is defined and change_flags.changes_detected_underlay_ip_address) - - (change_flags.underlay_ip_address_diff_result is defined and change_flags.underlay_ip_address_diff_result.updated | length > 0) + - (change_flags.underlay_ip_address_diff_result is defined change_flags.underlay_ip_address_diff_result.updated | length > 0) # With the addition of the Allocate Underlay IP Address change above we # cannot call cisco.dcnm.dcnm_inventory with save: true until after diff --git a/roles/dtc/create/tasks/common/interfaces.yml b/roles/dtc/create/tasks/common/interfaces.yml index f208ed4dc..6407d65ca 100644 --- a/roles/dtc/create/tasks/common/interfaces.yml +++ b/roles/dtc/create/tasks/common/interfaces.yml @@ -65,7 +65,7 @@ - name: Initialize Interface Config List to All Interfaces set_fact: - interface_config_list: "{{ vars_common_local.interface_all }}" + interface_config_list: "{{ vars_common_local.interface_all_create }}" - name: Override Interface Config List Based On Diff Run Settings set_fact: @@ -73,14 +73,6 @@ when: - run_map_read_result.diff_run is true|bool -- name: Diff Run Feature Status - ansible.builtin.debug: - msg: - - "-------------------------------------------------------------------------" - - "+ Diff Run Feature Status: {{ run_map_read_result.diff_run }}" - - "+ Interface Config List Count: {{ interface_config_list | length }}" - - "-------------------------------------------------------------------------" - - name: Manage Interface All in Nexus Dashboard cisco.dcnm.dcnm_interface: fabric: "{{ MD_Extended.vxlan.fabric.name }}" diff --git a/roles/dtc/create/tasks/common/links.yml b/roles/dtc/create/tasks/common/links.yml index 14a406a9d..0c01a5cff 100644 --- a/roles/dtc/create/tasks/common/links.yml +++ b/roles/dtc/create/tasks/common/links.yml @@ -56,6 +56,16 @@ - dst_fabric: "{{ MD_Extended.vxlan.fabric.name }}" register: result_links +- name: Initialize Fabric Links Config List to All Links + set_fact: + fabric_links_config_list: "{{ fabric_links }}" + +- name: Override Fabric Links Config List Based On Diff Run Settings + set_fact: + fabric_links_config_list: "{{ fabric_links_diff_result.updated }}" + when: + - run_map_read_result.diff_run is true|bool + - name: Create empty result List ansible.builtin.set_fact: required_links: [] @@ -63,14 +73,11 @@ - name: Create a List of Links that Already Exist from Nexus Dashboard cisco.nac_dc_vxlan.dtc.existing_links_check: existing_links: "{{ result_links.response }}" - # fabric_links: "{{ fabric_links }}" - fabric_links: "{{ fabric_links_diff_result.updated }}" + fabric_links: "{{ fabric_links_config_list }}" switch_data_model: "{{ MD_Extended.vxlan.topology.switches }}" register: required_links when: result_links.response is defined -- debug: msg="{{ required_links }}" - # -------------------------------------------------------------------- # Manage Links Configuration in Nexus Dashboard # -------------------------------------------------------------------- diff --git a/roles/dtc/create/tasks/common/vpc_peering.yml b/roles/dtc/create/tasks/common/vpc_peering.yml index d7f6f9082..0907c86d9 100644 --- a/roles/dtc/create/tasks/common/vpc_peering.yml +++ b/roles/dtc/create/tasks/common/vpc_peering.yml @@ -57,20 +57,29 @@ # Manage vPC Domain ID # -------------------------------------------------------------------- -- name: Debug Domain ID - ansible.builtin.debug: - msg: - - "{{ vars_common_vxlan.vpc_domain_id_resource_diff_result }}" +- name: Initialize vPC Domain ID Resource Config List to All Interfaces + set_fact: + vpc_domain_id_resource_config_list: "{{ vars_common_vxlan.vpc_domain_id_resource }}" + when: + - vars_common_vxlan.vpc_domain_id_resource_diff_result is defined + - vars_common_vxlan.vpc_domain_id_resource_diff_result.updated | length > 0 + +- name: Override vPC Domain ID Resource Config List Based On Diff Run Settings + set_fact: + vpc_domain_id_resource_config_list: "{{ vars_common_vxlan.vpc_domain_id_resource_diff_result.updated }}" + when: + - run_map_read_result.diff_run is true|bool + - vars_common_vxlan.vpc_domain_id_resource_diff_result is defined + - vars_common_vxlan.vpc_domain_id_resource_diff_result.updated | length > 0 - name: Manage vPC Domain ID Resource in Nexus Dashboard cisco.dcnm.dcnm_resource_manager: state: merged fabric: "{{ MD_Extended.vxlan.fabric.name }}" - # config: "{{ vars_common_vxlan.vpc_domain_id_resource }}" - config: "{{ vars_common_vxlan.vpc_domain_id_resource_diff_result.updated }}" + config: "{{ vpc_domain_id_resource_config_list }}" when: - - vars_common_vxlan.vpc_domain_id_resource_diff_result is defined - - vars_common_vxlan.vpc_domain_id_resource_diff_result.updated | length > 0 + - vpc_domain_id_resource_config_list is defined + - vpc_domain_id_resource_config_list | length > 0 # -------------------------------------------------------------------- # Manage Intra Fabric Links for vPC Peering in Nexus Dashboard @@ -90,17 +99,27 @@ # Manage vPC Peering in Nexus Dashboard # -------------------------------------------------------------------- -- name: Debug vPC Peering - ansible.builtin.debug: - msg: - # - "{{ vars_common_vxlan }}" - - "{{ vars_common_local.vpc_peering_diff_result }}" +- name: Initialize vPC Peering Config List to All Interfaces + set_fact: + vpc_peering_config_list: "{{ vars_common_vxlan.vpc_peering }}" + when: + - vars_common_vxlan.vpc_peering_diff_result is defined + - vars_common_vxlan.vpc_peering_diff_result.updated | length > 0 + +- name: Override vPC Peering Config List Based On Diff Run Settings + set_fact: + vpc_peering_config_list: "{{ vars_common_vxlan.vpc_peering_diff_result.updated }}" + when: + - run_map_read_result.diff_run is true|bool + - vars_common_vxlan.vpc_peering_diff_result is defined + - vars_common_vxlan.vpc_peering_diff_result.updated | length > 0 - name: Manage vPC Peering in Nexus Dashboard cisco.dcnm.dcnm_vpc_pair: src_fabric: "{{ MD_Extended.vxlan.fabric.name }}" deploy: false state: replaced - # config: "{{ vars_common_local.vpc_peering }}" - config: "{{ vars_common_local.vpc_peering_diff_result.updated }}" - when: vars_common_local.vpc_peering_diff_result is defined and vars_common_local.vpc_peering_diff_result.updated | length > 0 + config: "{{ vpc_peering_config_list }}" + when: + - vpc_peering_config_list is defined + - vpc_peering_config_list | length > 0 diff --git a/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml b/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml index 9d436a6bf..2cb85b0b6 100644 --- a/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml +++ b/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml @@ -102,11 +102,21 @@ # -------------------------------------------------------------------- # Manage Network Configuration in Nexus Dashboard # -------------------------------------------------------------------- +- name: Initialize Network Config List to All Networks + set_fact: + network_config_list: "{{ vars_common_local.net_config }}" + +- name: Override Network Config List Based On Diff Run Settings + set_fact: + network_config_list: "{{ vars_common_local.network_diff_result.updated }}" + when: + - run_map_read_result.diff_run is true|bool + - name: Manage Fabric Networks in Nexus Dashboard cisco.dcnm.dcnm_network: fabric: "{{ MD_Extended.vxlan.fabric.name }}" state: replaced - config: "{{ vars_common_local.net_config }}" + config: "{{ network_config_list }}" register: manage_network_result when: - MD_Extended.vxlan.overlay.networks is defined diff --git a/roles/dtc/create/tasks/external/devices.yml b/roles/dtc/create/tasks/external/devices.yml deleted file mode 100644 index ead6b9a8d..000000000 --- a/roles/dtc/create/tasks/external/devices.yml +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in -# the Software without restriction, including without limitation the rights to -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -# the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# SPDX-License-Identifier: MIT - ---- - -- name: Manage Devices Entry Point - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ Manage Devices Fabric {{ MD_Extended.vxlan.fabric.name }}" - - "----------------------------------------------------------------" - -- name: Manage Devices Discovery in Nexus Dashboard - ansible.builtin.import_tasks: devices_discovery.yml diff --git a/roles/dtc/create/tasks/external/devices_discovery.yml b/roles/dtc/create/tasks/external/devices_discovery.yml deleted file mode 100644 index c131ac6fe..000000000 --- a/roles/dtc/create/tasks/external/devices_discovery.yml +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in -# the Software without restriction, including without limitation the rights to -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -# the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# SPDX-License-Identifier: MIT - ---- - -- name: Add Fabric Devices in Nexus Dashboard - cisco.dcnm.dcnm_inventory: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - config: "{{ vars_common_external.updated_inv_config['updated_inv_list'] }}" - deploy: false - save: true - state: merged - vars: - ansible_command_timeout: 3000 - ansible_connect_timeout: 3000 - when: MD_Extended.vxlan.topology.switches | length > 0 - -- name: Create List of Switch Serial Numbers from Data Model - ansible.builtin.set_fact: - md_serial_numbers: "{{ MD_Extended.vxlan.topology.switches | map(attribute='serial_number') | list }}" - delegate_to: localhost - -- name: Build Switch Hostname Policy Payload from Data Model Update - cisco.nac_dc_vxlan.dtc.update_switch_hostname_policy: - model_data: "{{ MD_Extended }}" - switch_serial_numbers: "{{ md_serial_numbers }}" - template_name: host_11_1 - register: results -# do not delegate_to: localhost as this action plugin uses Python to execute cisco.dcnm.dcnm_rest - -- name: Join List of Switch Hostname Policy IDs from Nexus Dashboard - ansible.builtin.set_fact: - policy_ids: "{{ results.policy_update.values() | map(attribute='policyId') | list | join('%2C') }}" - when: results.policy_update | length > 0 - delegate_to: localhost - -- name: Update Switch Hostname Policy in Nexus Dashboard - cisco.dcnm.dcnm_rest: - method: PUT - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/policies/{{ policy_ids }}/bulk" - json_data: "{{ results.policy_update.values() | list | to_json }}" - when: results.policy_update | length > 0 diff --git a/roles/dtc/create/tasks/external/interfaces.yml b/roles/dtc/create/tasks/external/interfaces.yml deleted file mode 100644 index d8230dab5..000000000 --- a/roles/dtc/create/tasks/external/interfaces.yml +++ /dev/null @@ -1,147 +0,0 @@ -# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in -# the Software without restriction, including without limitation the rights to -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -# the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# SPDX-License-Identifier: MIT - ---- - -- name: Manage Fabric Interfaces Entry Point - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ Manage Fabric Interfaces {{ MD_Extended.vxlan.fabric.name }}" - - "----------------------------------------------------------------" - -# ---------------------------------------------------------------------- -# Manage Interface Trunk Configuration in Nexus Dashboard -# ---------------------------------------------------------------------- - -- name: Manage Interface Trunk in Nexus Dashboard - cisco.dcnm.dcnm_interface: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - state: replaced - config: "{{ interface_trunk }}" - when: MD_Extended.vxlan.topology.interfaces.modes.trunk.count > 0 - -# ---------------------------------------------------------------------- -# Manage Interface Access Routed Configuration in Nexus Dashboard -# ---------------------------------------------------------------------- - -- name: Manage Interface Access in Nexus Dashboard - cisco.dcnm.dcnm_interface: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - state: replaced - config: "{{ interface_access }}" - when: MD_Extended.vxlan.topology.interfaces.modes.access.count > 0 - -# ---------------------------------------------------------------------- -# Manage Interface Access Portchannel Configuration in Nexus Dashboard -# ---------------------------------------------------------------------- - -- name: Manage Access Portchannel Interface in Nexus Dashboard - cisco.dcnm.dcnm_interface: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - state: replaced - config: "{{ vars_common_external.interface_access_po }}" - when: MD_Extended.vxlan.topology.interfaces.modes.access_po.count > 0 - -# ---------------------------------------------------------------------- -# Manage Interface Trunk Portchannel Configuration in Nexus Dashboard -# ---------------------------------------------------------------------- - -- name: Manage Trunk Portchannel Interface in Nexus Dashboard - cisco.dcnm.dcnm_interface: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - state: replaced - config: "{{ vars_common_external.interface_trunk_po }}" - when: MD_Extended.vxlan.topology.interfaces.modes.trunk_po.count > 0 - -# ---------------------------------------------------------------------- -# Manage Interface Routed Configuration in Nexus Dashboard -# ---------------------------------------------------------------------- - -- name: Manage Interface Routed in Nexus Dashboard - cisco.dcnm.dcnm_interface: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - state: replaced - config: "{{ vars_common_external.interface_routed }}" - when: MD_Extended.vxlan.topology.interfaces.modes.routed.count > 0 - -# ---------------------------------------------------------------------- -# Manage Sub-Interface Routed Configuration in Nexus Dashboard -# ---------------------------------------------------------------------- - -- name: Manage Sub-interface Routed in Nexus Dashboard - cisco.dcnm.dcnm_interface: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - state: replaced - config: "{{ vars_common_external.sub_interface_routed }}" - when: MD_Extended.vxlan.topology.interfaces.modes.routed_sub.count > 0 - -# ---------------------------------------------------------------------- -# Manage Interface Port-Channel Routed Configuration in Nexus Dashboard -# ---------------------------------------------------------------------- - -- name: Manage Interface Port-Channel Routed in Nexus Dashboard - cisco.dcnm.dcnm_interface: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - state: replaced - config: "{{ vars_common_external.interface_po_routed }}" - when: MD_Extended.vxlan.topology.interfaces.modes.routed_po.count > 0 - -# ---------------------------------------------------------------------- -# Manage Interface Loopback Configuration in Nexus Dashboard -# ---------------------------------------------------------------------- - -- name: Manage NDFC Fabric Loopback in Nexus Dashboard - cisco.dcnm.dcnm_interface: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - state: replaced - config: "{{ vars_common_external.int_loopback_config }}" - when: > - (MD_Extended.vxlan.topology.interfaces.modes.loopback.count > 0) or - (MD_Extended.vxlan.topology.interfaces.modes.fabric_loopback.count > 0) or - (MD_Extended.vxlan.topology.interfaces.modes.mpls_loopback.count > 0) - -# ---------------------------------------------------------------------- -# Manage Interface vPC Configuration in Nexus Dashboard -# ---------------------------------------------------------------------- - -- name: Manage NDFC Fabric vPCs in Nexus Dashboard - cisco.dcnm.dcnm_interface: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - state: replaced - config: "{{ interface_vpc }}" - when: MD_Extended.vxlan.topology.interfaces.modes.access_vpc.count > 0 or MD_Extended.vxlan.topology.interfaces.modes.trunk_vpc.count > 0 - -## Will discuss with team and switchover to the below code and remove the above code -# # -------------------------------------------------------------------- -# # Manage Interface All Configuration in Nexus Dashboard -# # -------------------------------------------------------------------- - -# - name: Manage Interface All in Nexus Dashboard -# cisco.dcnm.dcnm_interface: -# fabric: "{{ MD_Extended.vxlan.fabric.name }}" -# state: replaced -# config: "{{ vars_common_vxlan.interface_all }}" -# vars: -# ansible_command_timeout: 3000 -# ansible_connect_timeout: 3000 -# when: MD_Extended.vxlan.topology.interfaces.modes.all.count > 0 -# delegate_to: localhost diff --git a/roles/dtc/create/tasks/external/policies.yml b/roles/dtc/create/tasks/external/policies.yml deleted file mode 100644 index 12570948a..000000000 --- a/roles/dtc/create/tasks/external/policies.yml +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in -# the Software without restriction, including without limitation the rights to -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -# the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# SPDX-License-Identifier: MIT - ---- - -- name: Manage Policies Entry Point - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ Manage Policies Fabric {{ MD_Extended.vxlan.fabric.name }}" - - "----------------------------------------------------------------" - -# -------------------------------------------------------------------- -# Manage Fabric Policy Configuration in Nexus Dashboard -# -------------------------------------------------------------------- -- name: Manage Fabric Policies in Nexus Dashboard - cisco.dcnm.dcnm_policy: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - use_desc_as_key: true - config: "{{ vars_common_external.policy_config }}" - deploy: false - state: merged - register: manage_policies_result diff --git a/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml b/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml index 99ec77a22..d6b88b425 100644 --- a/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml +++ b/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml @@ -71,13 +71,18 @@ cisco.dcnm.dcnm_rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" - when: MD_Extended.vxlan.topology.switches | length > 0 + when: + - MD_Extended.vxlan.topology.switches | length > 0 + - change_flags.changes_detected_vpc_peering or change_flags.changes_detected_vpc_domain_id_resource register: config_save rescue: - name: Config-Save for eBGP VXLAN Fabric in Nexus Dashboard - Failed ansible.builtin.debug: msg: "{{ config_save.msg.DATA }}" + when: + - config_save.msg.RETURN_CODE is defined and config_save.msg.RETURN_CODE == 500 + - change_flags.changes_detected_vpc_peering or change_flags.changes_detected_vpc_domain_id_resource - name: Manage eBGP VXLAN Fabric Interfaces in Nexus Dashboard ansible.builtin.import_tasks: common/interfaces.yml diff --git a/roles/dtc/create/tasks/sub_main_vxlan.yml b/roles/dtc/create/tasks/sub_main_vxlan.yml index b20773a59..d13f1eae4 100644 --- a/roles/dtc/create/tasks/sub_main_vxlan.yml +++ b/roles/dtc/create/tasks/sub_main_vxlan.yml @@ -71,7 +71,9 @@ cisco.dcnm.dcnm_rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" - when: MD_Extended.vxlan.topology.switches | length > 0 + when: + - MD_Extended.vxlan.topology.switches | length > 0 + - change_flags.changes_detected_vpc_peering or change_flags.changes_detected_vpc_domain_id_resource register: config_save # TODO: Need to add logic to only save if changes are made @@ -79,7 +81,9 @@ - name: Config-Save for iBGP VXLAN Fabric in Nexus Dashboard - Failed ansible.builtin.debug: msg: "{{ config_save.msg.DATA }}" - when: config_save.msg.RETURN_CODE is defined and config_save.msg.RETURN_CODE == 500 + when: + - config_save.msg.RETURN_CODE is defined and config_save.msg.RETURN_CODE == 500 + - change_flags.changes_detected_vpc_peering or change_flags.changes_detected_vpc_domain_id_resource - name: Manage iBGP VXLAN Fabric Interfaces in Nexus Dashboard ansible.builtin.import_tasks: common/interfaces.yml diff --git a/roles/dtc/deploy/tasks/main.yml b/roles/dtc/deploy/tasks/main.yml index e30f8f425..4a9f0c008 100644 --- a/roles/dtc/deploy/tasks/main.yml +++ b/roles/dtc/deploy/tasks/main.yml @@ -21,33 +21,6 @@ --- -# - name: Import iBGP VXLAN EVPN Role Tasks -# ansible.builtin.import_tasks: sub_main_vxlan.yml -# tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml -# when: > -# (MD_Extended.vxlan.fabric.type == 'VXLAN_EVPN') and -# (vars_common_vxlan.changes_detected_fabric or -# vars_common_vxlan.changes_detected_fabric_links or -# vars_common_vxlan.changes_detected_interface_access_po or -# vars_common_vxlan.changes_detected_interface_access or -# vars_common_vxlan.changes_detected_interfaces or -# vars_common_vxlan.changes_detected_interface_loopback or -# vars_common_vxlan.changes_detected_interface_po_routed or -# vars_common_vxlan.changes_detected_interface_routed or -# vars_common_vxlan.changes_detected_interface_trunk_po or -# vars_common_vxlan.changes_detected_interface_trunk or -# vars_common_vxlan.changes_detected_interface_vpc or -# vars_common_vxlan.changes_detected_inventory or -# vars_common_vxlan.changes_detected_link_vpc_peering or -# vars_common_vxlan.changes_detected_networks or -# vars_common_vxlan.changes_detected_policy or -# vars_common_vxlan.changes_detected_sub_interface_routed or -# vars_common_vxlan.changes_detected_vpc_peering or -# vars_common_vxlan.changes_detected_vrfs or -# vars_common_vxlan.changes_detected_edge_connections or -# vars_common_vxlan.changes_detected_underlay_ip_address or -# vars_common_vxlan.changes_detected_vpc_domain_id_resource) - # - name: Import MSD Fabric Role Tasks # ansible.builtin.import_tasks: sub_main_msd.yml # tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml @@ -59,68 +32,6 @@ # (child_fabrics_vrfs_networks_changed is defined and child_fabrics_vrfs_networks_changed | length > 0) or # vars_common_msd.changes_detected_bgw_anycast_vip) -# - name: Import ISN Fabric Role Tasks -# ansible.builtin.import_tasks: sub_main_isn.yml -# tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml -# when: > -# (MD_Extended.vxlan.fabric.type == 'ISN') and -# (vars_common_isn.changes_detected_fabric or -# vars_common_isn.changes_detected_interface_access_po or -# vars_common_isn.changes_detected_interface_access or -# vars_common_isn.changes_detected_interfaces or -# vars_common_isn.changes_detected_interface_loopback or -# vars_common_isn.changes_detected_interface_po_routed or -# vars_common_isn.changes_detected_interface_routed or -# vars_common_isn.changes_detected_interface_trunk_po or -# vars_common_isn.changes_detected_interface_trunk or -# vars_common_isn.changes_detected_interface_vpc or -# vars_common_isn.changes_detected_inventory or -# vars_common_isn.changes_detected_policy or -# vars_common_isn.changes_detected_sub_interface_routed) - -# - name: Import External Fabric Role Tasks -# ansible.builtin.import_tasks: sub_main_external.yml -# tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml -# when: > -# (MD_Extended.vxlan.fabric.type == 'External') and -# (vars_common_external.changes_detected_fabric or -# vars_common_external.changes_detected_interface_access_po or -# vars_common_external.changes_detected_interface_access or -# vars_common_external.changes_detected_interfaces or -# vars_common_external.changes_detected_interface_loopback or -# vars_common_external.changes_detected_interface_po_routed or -# vars_common_external.changes_detected_interface_routed or -# vars_common_external.changes_detected_interface_trunk_po or -# vars_common_external.changes_detected_interface_trunk or -# vars_common_external.changes_detected_interface_vpc or -# vars_common_external.changes_detected_inventory or -# vars_common_external.changes_detected_policy or -# vars_common_external.changes_detected_sub_interface_routed) - -# - name: Import Role Tasks -# ansible.builtin.import_tasks: sub_main_ebgp_vxlan.yml -# tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml -# when: > -# (MD_Extended.vxlan.fabric.type == 'eBGP_VXLAN') and -# (vars_common_ebgp_vxlan.changes_detected_fabric or -# vars_common_ebgp_vxlan.changes_detected_interface_access or -# vars_common_ebgp_vxlan.changes_detected_interface_access_po or -# vars_common_ebgp_vxlan.changes_detected_interface_trunk or -# vars_common_ebgp_vxlan.changes_detected_interface_trunk_po or -# vars_common_ebgp_vxlan.changes_detected_interface_vpc or -# vars_common_ebgp_vxlan.changes_detected_interface_po_routed or -# vars_common_ebgp_vxlan.changes_detected_interface_routed or -# vars_common_ebgp_vxlan.changes_detected_sub_interface_routed or -# vars_common_ebgp_vxlan.changes_detected_interfaces or -# vars_common_ebgp_vxlan.changes_detected_interface_loopback or -# vars_common_ebgp_vxlan.changes_detected_inventory or -# vars_common_ebgp_vxlan.changes_detected_vpc_peering or -# vars_common_ebgp_vxlan.changes_detected_link_vpc_peering or -# vars_common_ebgp_vxlan.changes_detected_interface_vpc or -# vars_common_ebgp_vxlan.changes_detected_policy or -# vars_common_ebgp_vxlan.changes_detected_vrfs or -# vars_common_ebgp_vxlan.changes_detected_networks) - - name: Import iBGP VXLAN EVPN Role Tasks ansible.builtin.import_tasks: sub_main_vxlan.yml tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml @@ -130,28 +41,29 @@ - name: Import MSD Fabric Role Tasks ansible.builtin.import_tasks: sub_main_msd.yml - tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml - when: - - MD_Extended.vxlan.fabric.type == 'MSD' - - change_flags.changes_detected_any + tags: "{{ nac_tags.deploy }}" + when: > + (MD_Extended.vxlan.fabric.type == 'MSD') and + (change_flags.changes_detected_any or + (child_fabrics_vrfs_networks_changed is defined and child_fabrics_vrfs_networks_changed | length > 0)) - name: Import ISN Fabric Role Tasks ansible.builtin.import_tasks: sub_main_isn.yml - tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml + tags: "{{ nac_tags.deploy }}" when: - MD_Extended.vxlan.fabric.type == 'ISN' - change_flags.changes_detected_any - name: Import External Fabric Role Tasks ansible.builtin.import_tasks: sub_main_external.yml - tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml + tags: "{{ nac_tags.deploy }}" when: - MD_Extended.vxlan.fabric.type == 'External' - change_flags.changes_detected_any - name: Import Role Tasks ansible.builtin.import_tasks: sub_main_ebgp_vxlan.yml - tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml + tags: "{{ nac_tags.deploy }}" when: - MD_Extended.vxlan.fabric.type == 'eBGP_VXLAN' - change_flags.changes_detected_any @@ -161,4 +73,5 @@ model_data: "{{ MD_Extended }}" stage: role_deploy_completed register: run_map + tags: "{{ nac_tags.deploy }}" delegate_to: localhost diff --git a/roles/dtc/remove/tasks/common/interfaces.yml b/roles/dtc/remove/tasks/common/interfaces.yml index 7d0390fe3..b5d9795be 100644 --- a/roles/dtc/remove/tasks/common/interfaces.yml +++ b/roles/dtc/remove/tasks/common/interfaces.yml @@ -95,7 +95,7 @@ cisco.dcnm.dcnm_interface: fabric: "{{ MD_Extended.vxlan.fabric.name }}" state: overridden - config: "{{ vars_common_local.interface_all }}" + config: "{{ vars_common_local.interface_all_remove_overridden }}" # Might need to set this back to true to keep default behavior deploy: false vars: diff --git a/roles/dtc/remove/tasks/common/vpc_peers.yml b/roles/dtc/remove/tasks/common/vpc_peers.yml index 526b3a2b6..89634e319 100644 --- a/roles/dtc/remove/tasks/common/vpc_peers.yml +++ b/roles/dtc/remove/tasks/common/vpc_peers.yml @@ -68,12 +68,6 @@ - run_map_read_result.diff_run is true|bool - force_run_all is false|bool -- debug: msg="Config {{ vars_common_local.vpc_peering_diff_result.removed }}" -- debug: msg="{{ vars_common_local.vpc_peering_diff_result.removed | length }}" -- name: Sleep for 5 seconds - ansible.builtin.pause: - seconds: 5 - - name: Remove Unmanaged vPC Peering from Nexus Dashboard - Diff Run False cisco.dcnm.dcnm_vpc_pair: src_fabric: "{{ MD_Extended.vxlan.fabric.name }}" diff --git a/roles/dtc/remove/tasks/common_vxlan/networks.yml b/roles/dtc/remove/tasks/common_vxlan/networks.yml index e2ed0efe1..fdd00d7da 100644 --- a/roles/dtc/remove/tasks/common_vxlan/networks.yml +++ b/roles/dtc/remove/tasks/common_vxlan/networks.yml @@ -64,7 +64,35 @@ - (network_delete_mode is defined) and (network_delete_mode is true|bool) - not is_active_child_fabric -- name: Remove Unmanaged Fabric Networks in Nexus Dashboard +# ----------------------------------------------------------------------------- +# Remove Networks Using Diff Run Framework +# ----------------------------------------------------------------------------- +# +# The following conditions must be met for this task to execute: +# - The number of networks to be removed/defaulted as compared to the +# previous run must be non-zero. +# - The diff_run feature must be active +# Combination of the (diff_run flag and force_run_all_flag state) +- name: Remove Unmanaged Fabric Networks in Nexus Dashboard - Diff Run Feature Active + cisco.dcnm.dcnm_network: + fabric: "{{ MD_Extended.vxlan.fabric.name }}" + state: deleted + config: "{{ vars_common_local.network_diff_result.removed }}" + vars: + ansible_command_timeout: 3000 + ansible_connect_timeout: 3000 + when: + - switch_list.response.DATA | length > 0 + - vars_common_local.network_diff_result.removed | length > 0 + - (network_delete_mode is defined) and (network_delete_mode is true|bool) + - run_map_read_result.diff_run is true|bool + - force_run_all is false|bool + - not is_active_child_fabric + +# ----------------------------------------------------------------------------- +# Remove Networks Default Mode +# ----------------------------------------------------------------------------- +- name: Remove Unmanaged Fabric Networks in Nexus Dashboard - Diff Run Feature Disabled cisco.dcnm.dcnm_network: fabric: "{{ MD_Extended.vxlan.fabric.name }}" state: overridden @@ -75,6 +103,7 @@ when: - switch_list.response.DATA | length > 0 - (network_delete_mode is defined) and (network_delete_mode is true|bool) + - run_map_read_result.diff_run is false|bool or force_run_all is true|bool - not is_active_child_fabric - name: Skip Remove Unmanaged Fabric Networks Task If network_delete_mode is False From 3bfb776b1f90255cc8dba5c167ff2ee6b1e9c93c Mon Sep 17 00:00:00 2001 From: mwiebe Date: Thu, 9 Oct 2025 09:23:16 -0400 Subject: [PATCH 26/65] More cleanup --- plugins/action/dtc/diff_compare.py | 6 ------ .../common/tasks/common/ndfc_interface_routed.yml | 5 ----- .../common/tasks/common/ndfc_interface_vpc.yml | 5 ----- roles/dtc/common/tasks/common/ndfc_policy.yml | 8 -------- .../tasks/common/ndfc_underlay_ip_address.yml | 15 --------------- .../dtc/common/tasks/msd/ndfc_bgw_anycast_vip.yml | 12 ------------ roles/dtc/common/tasks/msd/ndfc_child_vrfs.yml | 13 ------------- roles/dtc/common/tasks/msd/ndfc_fabric.yml | 13 ------------- roles/dtc/common/tasks/msd/ndfc_networks.yml | 13 ------------- roles/dtc/common/tasks/msd/ndfc_vrfs.yml | 13 ------------- roles/dtc/common/tasks/vxlan/ndfc_networks.yml | 2 +- 11 files changed, 1 insertion(+), 104 deletions(-) diff --git a/plugins/action/dtc/diff_compare.py b/plugins/action/dtc/diff_compare.py index b1c6013b1..428b70c4e 100644 --- a/plugins/action/dtc/diff_compare.py +++ b/plugins/action/dtc/diff_compare.py @@ -86,12 +86,6 @@ def run(self, tmp=None, task_vars=None): if self.new_file_path.endswith('ndfc_interface_all.yml'): removed_items = self.order_interface_remove(removed_items) - display.v("New or Modified Items:\n%s", yaml.dump(updated_items, default_flow_style=False)) - display.v("---------------------------------") - display.v("Remove Items:\n%s", yaml.dump(removed_items, default_flow_style=False)) - display.v("---------------------------------") - display.v("Unchanged Items:\n%s", yaml.dump(equal_items, default_flow_style=False)) - results['compare'] = {"updated": updated_items, "removed": removed_items, "equal": equal_items} # Write comparison results to file diff --git a/roles/dtc/common/tasks/common/ndfc_interface_routed.yml b/roles/dtc/common/tasks/common/ndfc_interface_routed.yml index 8167595d0..2f456185a 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_routed.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_routed.yml @@ -21,11 +21,6 @@ --- -# - name: Initialize changes_detected Var -# ansible.builtin.set_fact: -# changes_detected_interface_routed: false -# delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_interface_routed.yml" diff --git a/roles/dtc/common/tasks/common/ndfc_interface_vpc.yml b/roles/dtc/common/tasks/common/ndfc_interface_vpc.yml index b4124e79a..1eab80264 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_vpc.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_vpc.yml @@ -21,11 +21,6 @@ --- -# - name: Initialize changes_detected Var -# ansible.builtin.set_fact: -# changes_detected_interface_vpc: false -# delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_interface_vpc.yml" diff --git a/roles/dtc/common/tasks/common/ndfc_policy.yml b/roles/dtc/common/tasks/common/ndfc_policy.yml index ae78414be..b24caa79d 100644 --- a/roles/dtc/common/tasks/common/ndfc_policy.yml +++ b/roles/dtc/common/tasks/common/ndfc_policy.yml @@ -71,14 +71,6 @@ register: file_diff_result delegate_to: localhost -# - name: Set File Change Flag Based on File Diff Result -# ansible.builtin.set_fact: -# changes_detected_policy: true -# delegate_to: localhost -# when: -# - file_diff_result.file_data_changed -# - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml b/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml index 800359086..5646335be 100644 --- a/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml +++ b/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml @@ -76,13 +76,6 @@ register: underlay_ip_address_diff_result delegate_to: localhost -- debug: msg="EQUAL {{ underlay_ip_address_diff_result['equal'] }}" -- debug: msg="REMOVED {{ underlay_ip_address_diff_result['removed'] }}" -- debug: msg="UPDATED {{ underlay_ip_address_diff_result['updated'] }}" -- debug: msg="EQUAL {{ underlay_ip_address_diff_result['equal'] | length }}" -- debug: msg="REMOVED {{ underlay_ip_address_diff_result['removed'] | length }}" -- debug: msg="UPDATED {{ underlay_ip_address_diff_result['updated'] | length }}" - - name: Get MD5 Diff For Previous and Current Data Files cisco.nac_dc_vxlan.dtc.diff_model_changes: file_name_previous: "{{ path_name }}{{ file_name }}.old" @@ -90,14 +83,6 @@ register: file_diff_result delegate_to: localhost -# - name: Set File Change Flag Based on File Diff Result -# ansible.builtin.set_fact: -# changes_detected_underlay_ip_address: true -# delegate_to: localhost -# when: -# - file_diff_result.file_data_changed -# - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/msd/ndfc_bgw_anycast_vip.yml b/roles/dtc/common/tasks/msd/ndfc_bgw_anycast_vip.yml index 661852836..cfc8e6e36 100644 --- a/roles/dtc/common/tasks/msd/ndfc_bgw_anycast_vip.yml +++ b/roles/dtc/common/tasks/msd/ndfc_bgw_anycast_vip.yml @@ -20,10 +20,6 @@ # SPDX-License-Identifier: MIT --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_bgw_anycast_vip: false - delegate_to: localhost - name: Set file_name Var ansible.builtin.set_fact: @@ -74,14 +70,6 @@ register: file_diff_result delegate_to: localhost -- name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_bgw_anycast_vip: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/msd/ndfc_child_vrfs.yml b/roles/dtc/common/tasks/msd/ndfc_child_vrfs.yml index e3a7b351d..96d7af005 100644 --- a/roles/dtc/common/tasks/msd/ndfc_child_vrfs.yml +++ b/roles/dtc/common/tasks/msd/ndfc_child_vrfs.yml @@ -21,11 +21,6 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_vrfs: false - delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_child_vrfs.yml" @@ -76,14 +71,6 @@ register: file_diff_result delegate_to: localhost -- name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_vrfs: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/msd/ndfc_fabric.yml b/roles/dtc/common/tasks/msd/ndfc_fabric.yml index 6dcecb123..4b9f724e1 100644 --- a/roles/dtc/common/tasks/msd/ndfc_fabric.yml +++ b/roles/dtc/common/tasks/msd/ndfc_fabric.yml @@ -21,11 +21,6 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_fabric: false - delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_fabric.yml" @@ -76,14 +71,6 @@ register: file_diff_result delegate_to: localhost -- name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_fabric: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/msd/ndfc_networks.yml b/roles/dtc/common/tasks/msd/ndfc_networks.yml index b4f187454..e4358686d 100644 --- a/roles/dtc/common/tasks/msd/ndfc_networks.yml +++ b/roles/dtc/common/tasks/msd/ndfc_networks.yml @@ -21,11 +21,6 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_networks: false - delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_attach_networks.yml" @@ -76,14 +71,6 @@ register: file_diff_result delegate_to: localhost -- name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_networks: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/msd/ndfc_vrfs.yml b/roles/dtc/common/tasks/msd/ndfc_vrfs.yml index 84a91e1a0..7031516fb 100644 --- a/roles/dtc/common/tasks/msd/ndfc_vrfs.yml +++ b/roles/dtc/common/tasks/msd/ndfc_vrfs.yml @@ -21,11 +21,6 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_vrfs: false - delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_attach_vrfs.yml" @@ -76,14 +71,6 @@ register: file_diff_result delegate_to: localhost -- name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_vrfs: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/common/tasks/vxlan/ndfc_networks.yml b/roles/dtc/common/tasks/vxlan/ndfc_networks.yml index f11f895d3..7b674a98d 100644 --- a/roles/dtc/common/tasks/vxlan/ndfc_networks.yml +++ b/roles/dtc/common/tasks/vxlan/ndfc_networks.yml @@ -65,7 +65,7 @@ (MD_Extended.vxlan.overlay.networks | default([])) | length > 0 delegate_to: localhost -- name: Build vPC Domain ID Diff Between Previous and Current Run +- name: Build Network Diff Between Previous and Current Run # This task must be run before the next task because # dtc.diff_model_changes deletes the .old file if it exists cisco.nac_dc_vxlan.dtc.diff_compare: From faff4550ad0d606a45d71dca1eded79998cc3958 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Thu, 9 Oct 2025 12:29:10 -0400 Subject: [PATCH 27/65] Fix Github Actions Failures --- plugins/action/common/change_flag_manager.py | 8 ++- plugins/action/dtc/diff_compare.py | 5 +- roles/dtc/remove/tasks/main.yml | 60 -------------------- tests/sanity/ignore-2.14.txt | 1 + tests/sanity/ignore-2.15.txt | 1 + tests/sanity/ignore-2.16.txt | 1 + tests/sanity/ignore-2.17.txt | 1 + 7 files changed, 11 insertions(+), 66 deletions(-) diff --git a/plugins/action/common/change_flag_manager.py b/plugins/action/common/change_flag_manager.py index 9d9f7f098..8b7968f55 100644 --- a/plugins/action/common/change_flag_manager.py +++ b/plugins/action/common/change_flag_manager.py @@ -30,6 +30,7 @@ import inspect import os + class ChangeDetectionManager: """Manages change detection flags for fabric configurations.""" @@ -224,9 +225,9 @@ def display_flag_values(self, task_vars): print("-" * 40) # Print header - print("\n" + "="*80) + print("\n" + "=" * 80) print(f"Change Detection Flags for Fabric: {self.fabric_name}, Type: {self.fabric_type}") - print("="*80) + print("=" * 80) if self.fabric_name in self.changes_detected_flags: if self.fabric_type in self.changes_detected_flags[self.fabric_name]: @@ -257,7 +258,8 @@ def display_flag_values(self, task_vars): else: print(f"Fabric '{self.fabric_name}' not found") - print("="*80 + "\n") + print("=" * 80 + "\n") + class ActionModule(ActionBase): diff --git a/plugins/action/dtc/diff_compare.py b/plugins/action/dtc/diff_compare.py index 428b70c4e..bf0919ef6 100644 --- a/plugins/action/dtc/diff_compare.py +++ b/plugins/action/dtc/diff_compare.py @@ -129,11 +129,10 @@ def write_comparison_results(self, compare_results): try: # Remove old file if it exists if os.path.exists(output_path): - os.remove(output_path) - display.v(f"Removed existing file: {output_path}") + os.remove(output_path) with open(output_path, 'w', encoding='utf-8') as f: - yaml.dump(output_data, f, default_flow_style=False, sort_keys=False) + yaml.dump(output_data, f, default_flow_style=False, sort_keys=False) except Exception as e: display.warning(f"Failed to write comparison results to {output_path}: {str(e)}") diff --git a/roles/dtc/remove/tasks/main.yml b/roles/dtc/remove/tasks/main.yml index 70c8c8d93..21487455e 100644 --- a/roles/dtc/remove/tasks/main.yml +++ b/roles/dtc/remove/tasks/main.yml @@ -21,66 +21,6 @@ --- -# - name: Import iBGP VXLAN Fabric Role Tasks -# ansible.builtin.import_tasks: sub_main_vxlan.yml -# # Check with Matt on changes_detected_policy here -# # Was not there previously -# when: > -# (MD_Extended.vxlan.fabric.type == 'VXLAN_EVPN') and -# (vars_common_vxlan.changes_detected_fabric_links or -# vars_common_vxlan.changes_detected_interfaces or -# vars_common_vxlan.changes_detected_inventory or -# vars_common_vxlan.changes_detected_networks or -# vars_common_vxlan.changes_detected_policy or -# vars_common_vxlan.changes_detected_vpc_peering or -# vars_common_vxlan.changes_detected_vrfs or -# vars_common_vxlan.changes_detected_edge_connections) - -# - name: Import MSD Fabric Role Tasks -# ansible.builtin.import_tasks: sub_main_msd.yml -# when: > -# MD_Extended.vxlan.fabric.type == 'MSD' -# # Current implementation has to leverage the changes_detected flags -# # in the sub_main files to determine if the tasks should be run - -# - name: Import ISN Fabric Role Tasks -# ansible.builtin.import_tasks: sub_main_isn.yml -# when: > -# (MD_Extended.vxlan.fabric.type == 'ISN') and -# (vars_common_isn.changes_detected_interfaces or -# vars_common_isn.changes_detected_inventory or -# vars_common_isn.changes_detected_policy or -# vars_common_isn.changes_detected_edge_connections) - -# - name: Import External Fabric Role Tasks -# ansible.builtin.import_tasks: sub_main_external.yml -# when: > -# (MD_Extended.vxlan.fabric.type == 'External') and -# (vars_common_external.changes_detected_interfaces or -# vars_common_external.changes_detected_inventory or -# vars_common_external.changes_detected_policy or -# vars_common_external.changes_detected_edge_connections) - -# - name: Import eBGP Role Tasks -# ansible.builtin.import_tasks: sub_main_ebgp_vxlan.yml -# # Check with Matt on changes_detected_policy here -# # Was not there previously -# when: > -# (MD_Extended.vxlan.fabric.type == 'eBGP_VXLAN') and -# (vars_common_ebgp_vxlan.changes_detected_fabric_links or -# vars_common_ebgp_vxlan.changes_detected_vpc_peering or -# vars_common_ebgp_vxlan.changes_detected_vrfs or -# vars_common_ebgp_vxlan.changes_detected_interfaces or -# vars_common_ebgp_vxlan.changes_detected_policy or -# vars_common_ebgp_vxlan.changes_detected_inventory or -# vars_common_ebgp_vxlan.changes_detected_networks) -# # Additional conditions to be added when needed: - - - - - - - name: Import iBGP VXLAN Fabric Role Tasks ansible.builtin.import_tasks: sub_main_vxlan.yml # Check with Matt on changes_detected_policy here diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index a94438401..82eca273f 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -43,6 +43,7 @@ plugins/action/common/nac_dc_validate.py import-3.10!skip plugins/action/test/inventory.py import-3.10!skip plugins/action/common/run_map.py import-3.10!skip plugins/action/common/read_run_map.py import-3.10!skip +plugins/action/common/change_flag_manager.py import-3.10!skip plugins/action/dtc/diff_model_changes.py import-3.10!skip plugins/filter/version_compare.py import-3.10!skip plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index 3be18f6cf..3c9663954 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -43,6 +43,7 @@ plugins/action/common/nac_dc_validate.py import-3.10!skip plugins/action/test/inventory.py import-3.10!skip plugins/action/common/run_map.py import-3.10!skip plugins/action/common/read_run_map.py import-3.10!skip +plugins/action/common/change_flag_manager.py import-3.10!skip plugins/action/dtc/diff_model_changes.py import-3.10!skip plugins/filter/version_compare.py import-3.10!skip plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation \ No newline at end of file diff --git a/tests/sanity/ignore-2.16.txt b/tests/sanity/ignore-2.16.txt index 3be18f6cf..3c9663954 100644 --- a/tests/sanity/ignore-2.16.txt +++ b/tests/sanity/ignore-2.16.txt @@ -43,6 +43,7 @@ plugins/action/common/nac_dc_validate.py import-3.10!skip plugins/action/test/inventory.py import-3.10!skip plugins/action/common/run_map.py import-3.10!skip plugins/action/common/read_run_map.py import-3.10!skip +plugins/action/common/change_flag_manager.py import-3.10!skip plugins/action/dtc/diff_model_changes.py import-3.10!skip plugins/filter/version_compare.py import-3.10!skip plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation \ No newline at end of file diff --git a/tests/sanity/ignore-2.17.txt b/tests/sanity/ignore-2.17.txt index 3be18f6cf..3c9663954 100644 --- a/tests/sanity/ignore-2.17.txt +++ b/tests/sanity/ignore-2.17.txt @@ -43,6 +43,7 @@ plugins/action/common/nac_dc_validate.py import-3.10!skip plugins/action/test/inventory.py import-3.10!skip plugins/action/common/run_map.py import-3.10!skip plugins/action/common/read_run_map.py import-3.10!skip +plugins/action/common/change_flag_manager.py import-3.10!skip plugins/action/dtc/diff_model_changes.py import-3.10!skip plugins/filter/version_compare.py import-3.10!skip plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation \ No newline at end of file From 0c6bf40fa035822afb59a129d2dc23a9065432dc Mon Sep 17 00:00:00 2001 From: mwiebe Date: Thu, 9 Oct 2025 12:52:20 -0400 Subject: [PATCH 28/65] Github Actions Fixes --- tests/sanity/ignore-2.14.txt | 1 + tests/sanity/ignore-2.15.txt | 3 ++- tests/sanity/ignore-2.16.txt | 3 ++- tests/sanity/ignore-2.17.txt | 3 ++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index 82eca273f..38f4f91a5 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -47,3 +47,4 @@ plugins/action/common/change_flag_manager.py import-3.10!skip plugins/action/dtc/diff_model_changes.py import-3.10!skip plugins/filter/version_compare.py import-3.10!skip plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation +plugins/action/common/change_flag_manager.py # action plugin has no matching module to provide documentation diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index 3c9663954..38f4f91a5 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -46,4 +46,5 @@ plugins/action/common/read_run_map.py import-3.10!skip plugins/action/common/change_flag_manager.py import-3.10!skip plugins/action/dtc/diff_model_changes.py import-3.10!skip plugins/filter/version_compare.py import-3.10!skip -plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation \ No newline at end of file +plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation +plugins/action/common/change_flag_manager.py # action plugin has no matching module to provide documentation diff --git a/tests/sanity/ignore-2.16.txt b/tests/sanity/ignore-2.16.txt index 3c9663954..38f4f91a5 100644 --- a/tests/sanity/ignore-2.16.txt +++ b/tests/sanity/ignore-2.16.txt @@ -46,4 +46,5 @@ plugins/action/common/read_run_map.py import-3.10!skip plugins/action/common/change_flag_manager.py import-3.10!skip plugins/action/dtc/diff_model_changes.py import-3.10!skip plugins/filter/version_compare.py import-3.10!skip -plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation \ No newline at end of file +plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation +plugins/action/common/change_flag_manager.py # action plugin has no matching module to provide documentation diff --git a/tests/sanity/ignore-2.17.txt b/tests/sanity/ignore-2.17.txt index 3c9663954..38f4f91a5 100644 --- a/tests/sanity/ignore-2.17.txt +++ b/tests/sanity/ignore-2.17.txt @@ -46,4 +46,5 @@ plugins/action/common/read_run_map.py import-3.10!skip plugins/action/common/change_flag_manager.py import-3.10!skip plugins/action/dtc/diff_model_changes.py import-3.10!skip plugins/filter/version_compare.py import-3.10!skip -plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation \ No newline at end of file +plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation +plugins/action/common/change_flag_manager.py # action plugin has no matching module to provide documentation From be2bee884bf48602ffdeaffe7f56c3aa99a738a7 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Thu, 9 Oct 2025 14:15:30 -0400 Subject: [PATCH 29/65] More actions fixes --- plugins/action/common/change_flag_manager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/action/common/change_flag_manager.py b/plugins/action/common/change_flag_manager.py index 8b7968f55..90a85abb9 100644 --- a/plugins/action/common/change_flag_manager.py +++ b/plugins/action/common/change_flag_manager.py @@ -26,7 +26,6 @@ from ansible.plugins.action import ActionBase import json -import re import inspect import os From 26ab2917445ba3e3daa39c85a0fddb92320bf06e Mon Sep 17 00:00:00 2001 From: mwiebe Date: Thu, 9 Oct 2025 14:21:51 -0400 Subject: [PATCH 30/65] Actions fixes --- tests/sanity/ignore-2.14.txt | 2 +- tests/sanity/ignore-2.15.txt | 2 +- tests/sanity/ignore-2.16.txt | 2 +- tests/sanity/ignore-2.17.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index 38f4f91a5..20aa0be4c 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -47,4 +47,4 @@ plugins/action/common/change_flag_manager.py import-3.10!skip plugins/action/dtc/diff_model_changes.py import-3.10!skip plugins/filter/version_compare.py import-3.10!skip plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation -plugins/action/common/change_flag_manager.py # action plugin has no matching module to provide documentation +plugins/action/common/change_flag_manager.py action-plugin-docs # action plugin has no matching module to provide documentation \ No newline at end of file diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index 38f4f91a5..20aa0be4c 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -47,4 +47,4 @@ plugins/action/common/change_flag_manager.py import-3.10!skip plugins/action/dtc/diff_model_changes.py import-3.10!skip plugins/filter/version_compare.py import-3.10!skip plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation -plugins/action/common/change_flag_manager.py # action plugin has no matching module to provide documentation +plugins/action/common/change_flag_manager.py action-plugin-docs # action plugin has no matching module to provide documentation \ No newline at end of file diff --git a/tests/sanity/ignore-2.16.txt b/tests/sanity/ignore-2.16.txt index 38f4f91a5..20aa0be4c 100644 --- a/tests/sanity/ignore-2.16.txt +++ b/tests/sanity/ignore-2.16.txt @@ -47,4 +47,4 @@ plugins/action/common/change_flag_manager.py import-3.10!skip plugins/action/dtc/diff_model_changes.py import-3.10!skip plugins/filter/version_compare.py import-3.10!skip plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation -plugins/action/common/change_flag_manager.py # action plugin has no matching module to provide documentation +plugins/action/common/change_flag_manager.py action-plugin-docs # action plugin has no matching module to provide documentation \ No newline at end of file diff --git a/tests/sanity/ignore-2.17.txt b/tests/sanity/ignore-2.17.txt index 38f4f91a5..20aa0be4c 100644 --- a/tests/sanity/ignore-2.17.txt +++ b/tests/sanity/ignore-2.17.txt @@ -47,4 +47,4 @@ plugins/action/common/change_flag_manager.py import-3.10!skip plugins/action/dtc/diff_model_changes.py import-3.10!skip plugins/filter/version_compare.py import-3.10!skip plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation -plugins/action/common/change_flag_manager.py # action plugin has no matching module to provide documentation +plugins/action/common/change_flag_manager.py action-plugin-docs # action plugin has no matching module to provide documentation \ No newline at end of file From befb9d19de22933c625534038c607fe0e2a1a76b Mon Sep 17 00:00:00 2001 From: Matt Tarkington Date: Thu, 9 Oct 2025 19:25:18 -0400 Subject: [PATCH 31/65] updates for vrfs --- roles/dtc/common/tasks/sub_main_vxlan.yml | 1 + roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml | 17 ++++---- .../tasks/common_vxlan/vrfs_networks.yml | 30 ++++++++++---- roles/dtc/remove/tasks/common_vxlan/vrfs.yml | 40 ++++++++++++++++++- 4 files changed, 72 insertions(+), 16 deletions(-) diff --git a/roles/dtc/common/tasks/sub_main_vxlan.yml b/roles/dtc/common/tasks/sub_main_vxlan.yml index 5e9cb3f35..3c704bee1 100644 --- a/roles/dtc/common/tasks/sub_main_vxlan.yml +++ b/roles/dtc/common/tasks/sub_main_vxlan.yml @@ -254,4 +254,5 @@ network_diff_result: "{{ network_diff_result }}" vpc_peering_diff_result: "{{ vpc_peering_diff_result }}" vpc_domain_id_resource_diff_result: "{{ vpc_domain_id_resource_diff_result }}" + vrf_diff_result: "{{ vrf_diff_result }}" underlay_ip_address_diff_result: "{{ underlay_ip_address_diff_result }}" diff --git a/roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml b/roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml index ce3a33bc3..19c28d964 100644 --- a/roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml +++ b/roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml @@ -70,6 +70,15 @@ (MD_Extended.vxlan.overlay.vrfs | default([])) | length > 0 delegate_to: localhost +- name: Build Network Diff Between Previous and Current Run + # This task must be run before the next task because + # dtc.diff_model_changes deletes the .old file if it exists + cisco.nac_dc_vxlan.dtc.diff_compare: + old_file: "{{ path_name }}{{ file_name }}.old" + new_file: "{{ path_name }}{{ file_name }}" + register: vrf_diff_result + delegate_to: localhost + - name: Diff Previous and Current Data Files cisco.nac_dc_vxlan.dtc.diff_model_changes: file_name_previous: "{{ path_name }}{{ file_name }}.old" @@ -77,14 +86,6 @@ register: file_diff_result delegate_to: localhost -- name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_vrfs: true - delegate_to: localhost - when: - - file_diff_result.file_data_changed - - check_roles['save_previous'] - - name: Set File Change Flag Based on File Diff Result cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" diff --git a/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml b/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml index 2cb85b0b6..a5028c5fc 100644 --- a/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml +++ b/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml @@ -56,6 +56,9 @@ ansible.builtin.set_fact: is_active_child_fabric: "{{ true if selected_fabric[0]['fabricParent'] != 'None' else false }}" +# -------------------------------------------------------------------- +# Manage VRF Configuration in Nexus Dashboard +# -------------------------------------------------------------------- - name: Fail If Current Fabric is Part of Multisite And Attempting to Manage VRFs ansible.builtin.fail: msg: VRFs cannot be managed from the current fabric {{ MD_Extended.vxlan.fabric.name }} as it is a child fabric part of a Multisite fabric. @@ -63,14 +66,27 @@ - is_active_child_fabric - vars_common_local.vrf_config | length > 0 -# -------------------------------------------------------------------- -# Manage VRF Configuration in Nexus Dashboard -# -------------------------------------------------------------------- +- name: Initialize VRF Config List to All VRFs + set_fact: + vrf_config_list: "{{ vars_common_local.vrf_config }}" + +- name: Override VRF Config List Based On Diff Run Settings + set_fact: + vrf_config_list: "{{ vars_common_local.vrf_diff_result.updated }}" + when: + - run_map_read_result.diff_run is true|bool + +- ansible.builtin.debug: + var: vrf_config_list + +- ansible.builtin.pause: + seconds: 300 + - name: Manage Fabric VRFs in Nexus Dashboard cisco.dcnm.dcnm_vrf: fabric: "{{ MD_Extended.vxlan.fabric.name }}" state: replaced - config: "{{ vars_common_local.vrf_config }}" + config: "{{ vrf_config_list }}" register: manage_vrf_result when: - MD_Extended.vxlan.overlay.vrfs is defined @@ -92,6 +108,9 @@ - change_flags.changes_detected_vrfs - not is_active_child_fabric +# -------------------------------------------------------------------- +# Manage Network Configuration in Nexus Dashboard +# -------------------------------------------------------------------- - name: Fail If Current Fabric is Part of Multisite And Attempting to Manage Networks ansible.builtin.fail: msg: Networks cannot be managed from the current fabric {{ MD_Extended.vxlan.fabric.name }} as it is a child fabric part of a Multisite fabric. @@ -99,9 +118,6 @@ - is_active_child_fabric - vars_common_local.net_config | length > 0 -# -------------------------------------------------------------------- -# Manage Network Configuration in Nexus Dashboard -# -------------------------------------------------------------------- - name: Initialize Network Config List to All Networks set_fact: network_config_list: "{{ vars_common_local.net_config }}" diff --git a/roles/dtc/remove/tasks/common_vxlan/vrfs.yml b/roles/dtc/remove/tasks/common_vxlan/vrfs.yml index 1ab131658..48c9fafbf 100644 --- a/roles/dtc/remove/tasks/common_vxlan/vrfs.yml +++ b/roles/dtc/remove/tasks/common_vxlan/vrfs.yml @@ -64,7 +64,44 @@ - (vrf_delete_mode is defined) and (vrf_delete_mode is true|bool) - not is_active_child_fabric -- name: Remove Unmanaged Fabric VRFs in Nexus Dashboard +- ansible.builtin.debug: + var: vars_common_local.vrf_diff_result + +- ansible.builtin.debug: + var: vars_common_local.vrf_config + +- ansible.builtin.pause: + seconds: 300 + +# ----------------------------------------------------------------------------- +# Remove VRFs Using Diff Run Framework +# ----------------------------------------------------------------------------- +# +# The following conditions must be met for this task to execute: +# - The number of VRFs to be removed/defaulted as compared to the +# previous run must be non-zero. +# - The diff_run feature must be active +# Combination of the (diff_run flag and force_run_all_flag state) +- name: Remove Unmanaged Fabric VRFs in Nexus Dashboard - Diff Run Feature Active + cisco.dcnm.dcnm_vrf: + fabric: "{{ MD_Extended.vxlan.fabric.name }}" + state: deleted + config: "{{ vars_common_local.vrf_diff_result.removed }}" + vars: + ansible_command_timeout: 3000 + ansible_connect_timeout: 3000 + when: + - switch_list.response.DATA | length > 0 + - vars_common_local.vrf_diff_result.removed | length > 0 + - (vrf_delete_mode is defined) and (vrf_delete_mode is true|bool) + - run_map_read_result.diff_run is true|bool + - force_run_all is false|bool + - not is_active_child_fabric + +# ----------------------------------------------------------------------------- +# Remove VRFs Default Mode +# ----------------------------------------------------------------------------- +- name: Remove Unmanaged Fabric VRFs in Nexus Dashboard - Diff Run Feature Disabled cisco.dcnm.dcnm_vrf: fabric: "{{ MD_Extended.vxlan.fabric.name }}" state: overridden @@ -75,6 +112,7 @@ when: - switch_list.response.DATA | length > 0 - (vrf_delete_mode is defined) and (vrf_delete_mode is true|bool) + - run_map_read_result.diff_run is false|bool or force_run_all is true|bool - not is_active_child_fabric - name: Skip Remove Unmanaged Fabric VRFs Task If vrf_delete_mode is False From 574b636df8d28b34a8510720fbaa46ae627dbbbe Mon Sep 17 00:00:00 2001 From: mwiebe Date: Fri, 10 Oct 2025 11:05:59 -0400 Subject: [PATCH 32/65] Fixes and cleanup --- roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml | 5 -- .../create/tasks/common/devices_discovery.yml | 34 +++++++- .../tasks/common/devices_preprovision.yml | 78 ------------------- roles/dtc/create/tasks/common/vpc_peering.yml | 4 +- .../tasks/common_vxlan/vrfs_networks.yml | 6 -- roles/dtc/remove/tasks/common_vxlan/vrfs.yml | 9 --- 6 files changed, 33 insertions(+), 103 deletions(-) delete mode 100644 roles/dtc/create/tasks/common/devices_preprovision.yml diff --git a/roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml b/roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml index 19c28d964..46cf1206e 100644 --- a/roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml +++ b/roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml @@ -21,11 +21,6 @@ --- -- name: Initialize changes_detected Var - ansible.builtin.set_fact: - changes_detected_vrfs: false - delegate_to: localhost - - name: Set file_name Var ansible.builtin.set_fact: file_name: "ndfc_attach_vrfs.yml" diff --git a/roles/dtc/create/tasks/common/devices_discovery.yml b/roles/dtc/create/tasks/common/devices_discovery.yml index d8bd6dfe8..3b39cd9c6 100644 --- a/roles/dtc/create/tasks/common/devices_discovery.yml +++ b/roles/dtc/create/tasks/common/devices_discovery.yml @@ -60,16 +60,44 @@ - MD_Extended.vxlan.topology.switches | length > 0 - change_flags.changes_detected_inventory +# -------------------------------------------------------------------- +# Manage Underlay IP Address Configuration in Nexus Dashboard +# -------------------------------------------------------------------- +# +# This section manages the underlay IP address configuration based on the diff_run setting. +# +# When the diff_run feature is active we only manage the difference between +# the previous run and the current run, otherwise we manage all underlay IP address's +# defined in the data model. + +- name: Initialize Underlay IP Config List to All Interfaces + set_fact: + underlay_ip_config_list: "{{ vars_common_local.underlay_ip_address }}" + when: + - MD_Extended.vxlan.underlay.general.manual_underlay_allocation is defined + - MD_Extended.vxlan.underlay.general.manual_underlay_allocation + - (change_flags.changes_detected_underlay_ip_address is defined and change_flags.changes_detected_underlay_ip_address) + - (vars_common_local.underlay_ip_address is defined and vars_common_local.underlay_ip_address | length > 0) + +- name: Override Underlay IP Config List Based On Diff Run Settings + set_fact: + underlay_ip_config_list: "{{ vars_common_local.underlay_ip_address_diff_result.updated }}" + when: + - run_map_read_result.diff_run is true|bool + - MD_Extended.vxlan.underlay.general.manual_underlay_allocation is defined + - MD_Extended.vxlan.underlay.general.manual_underlay_allocation + - (change_flags.changes_detected_underlay_ip_address is defined and change_flags.changes_detected_underlay_ip_address) + - (vars_common_local.underlay_ip_address_diff_result is defined and vars_common_local.underlay_ip_address_diff_result.updated | length > 0) + - name: Allocate Underlay IP Address cisco.dcnm.dcnm_resource_manager: state: merged fabric: "{{ MD_Extended.vxlan.fabric.name }}" - # config: "{{ vars_common_vxlan.underlay_ip_address }}" - config: "{{ vars_common_local.underlay_ip_address_diff_result.updated }}" + config: "{{ underlay_ip_config_list }}" when: - MD_Extended.vxlan.underlay.general.manual_underlay_allocation is defined - MD_Extended.vxlan.underlay.general.manual_underlay_allocation - - (change_flags.underlay_ip_address_diff_result is defined change_flags.underlay_ip_address_diff_result.updated | length > 0) + - (change_flags.changes_detected_underlay_ip_address is defined and change_flags.changes_detected_underlay_ip_address) # With the addition of the Allocate Underlay IP Address change above we # cannot call cisco.dcnm.dcnm_inventory with save: true until after diff --git a/roles/dtc/create/tasks/common/devices_preprovision.yml b/roles/dtc/create/tasks/common/devices_preprovision.yml deleted file mode 100644 index 87640832f..000000000 --- a/roles/dtc/create/tasks/common/devices_preprovision.yml +++ /dev/null @@ -1,78 +0,0 @@ -# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in -# the Software without restriction, including without limitation the rights to -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -# the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# SPDX-License-Identifier: MIT - ---- - -# This is just a placeholder example and is not currently enabled as part of -# the solution workflow. The module calls below represent a pre-provision -# workflow and how the dcnm_inventory module can be used to pre-provision -# a switch. - -- name: Pre-Provision Switch Configuration in Nexus Dashboard - cisco.dcnm.dcnm_inventory: - fabric: nac-ndfc1 - state: merged # Only 2 options supported merged/query for poap config - config: - # All the values below are mandatory if poap configuration is being done - state is merged - - seed_ip: 192.168.9.14 - user_name: admin - password: cisco.123 - role: border - poap: - - preprovision_serial: 9Y0K4YPFFFF - model: N9K-C9300v - version: 9.3(7) - hostname: netascode-leaf3 - # image_policy: "prepro_image_policy" - config_data: - modulesModel: [N9K-X9364v, N9K-vSUP] - gateway: 192.168.9.1/24 - vars: - ansible_command_timeout: 1000 - ansible_connect_timeout: 1000 - -# Note: Calling the module in this way will switch out the fake -# serial number with the actual switch serial number and also -# poap the switch if it's in poap mode and appears in the NDFC -# poap list. -- name: Pre-Provision Switch Configuration in Nexus Dashboard - cisco.dcnm.dcnm_inventory: - fabric: nac-ndfc1 - state: merged # Only 2 options supported merged/query for poap config - config: - # All the values below are mandatory if poap configuration is being done - state is merged - - seed_ip: 192.168.9.14 - user_name: admin - password: cisco.123 - role: border - poap: - - preprovision_serial: 9Y0K4YPFFFF - serial_number: 9Y0K4YPFV64 - vars: - ansible_command_timeout: 1000 - ansible_connect_timeout: 1000 - - # preprovision: - # serial: 9Y0K4YPFFFF - # model: N9K-C9300v - # version: 9.4(8) - # modulesModel: [N9K-X9364v, N9K-vSUP] - # gateway: 10.15.9.1/24 # Add netmask to management key diff --git a/roles/dtc/create/tasks/common/vpc_peering.yml b/roles/dtc/create/tasks/common/vpc_peering.yml index 0907c86d9..09baf5dd2 100644 --- a/roles/dtc/create/tasks/common/vpc_peering.yml +++ b/roles/dtc/create/tasks/common/vpc_peering.yml @@ -61,8 +61,8 @@ set_fact: vpc_domain_id_resource_config_list: "{{ vars_common_vxlan.vpc_domain_id_resource }}" when: - - vars_common_vxlan.vpc_domain_id_resource_diff_result is defined - - vars_common_vxlan.vpc_domain_id_resource_diff_result.updated | length > 0 + - vars_common_vxlan.vpc_domain_id_resource is defined + - vars_common_vxlan.vpc_domain_id_resource | length > 0 - name: Override vPC Domain ID Resource Config List Based On Diff Run Settings set_fact: diff --git a/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml b/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml index a5028c5fc..cc8614618 100644 --- a/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml +++ b/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml @@ -76,12 +76,6 @@ when: - run_map_read_result.diff_run is true|bool -- ansible.builtin.debug: - var: vrf_config_list - -- ansible.builtin.pause: - seconds: 300 - - name: Manage Fabric VRFs in Nexus Dashboard cisco.dcnm.dcnm_vrf: fabric: "{{ MD_Extended.vxlan.fabric.name }}" diff --git a/roles/dtc/remove/tasks/common_vxlan/vrfs.yml b/roles/dtc/remove/tasks/common_vxlan/vrfs.yml index 48c9fafbf..226c62bbf 100644 --- a/roles/dtc/remove/tasks/common_vxlan/vrfs.yml +++ b/roles/dtc/remove/tasks/common_vxlan/vrfs.yml @@ -64,15 +64,6 @@ - (vrf_delete_mode is defined) and (vrf_delete_mode is true|bool) - not is_active_child_fabric -- ansible.builtin.debug: - var: vars_common_local.vrf_diff_result - -- ansible.builtin.debug: - var: vars_common_local.vrf_config - -- ansible.builtin.pause: - seconds: 300 - # ----------------------------------------------------------------------------- # Remove VRFs Using Diff Run Framework # ----------------------------------------------------------------------------- From a7b6f49efc7cd6bfd7b22686f1b8b03aa36200ce Mon Sep 17 00:00:00 2001 From: mwiebe Date: Fri, 10 Oct 2025 11:09:21 -0400 Subject: [PATCH 33/65] Fix typo --- roles/dtc/create/tasks/common/devices_discovery.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/dtc/create/tasks/common/devices_discovery.yml b/roles/dtc/create/tasks/common/devices_discovery.yml index 3b39cd9c6..eb03f4b08 100644 --- a/roles/dtc/create/tasks/common/devices_discovery.yml +++ b/roles/dtc/create/tasks/common/devices_discovery.yml @@ -70,7 +70,7 @@ # the previous run and the current run, otherwise we manage all underlay IP address's # defined in the data model. -- name: Initialize Underlay IP Config List to All Interfaces +- name: Initialize Underlay IP Config List to All Underlay IP Addresses set_fact: underlay_ip_config_list: "{{ vars_common_local.underlay_ip_address }}" when: From 4442151c84a41504ea100c00f5eeda60facb9569 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Fri, 10 Oct 2025 18:58:36 -0400 Subject: [PATCH 34/65] MSD updates --- plugins/action/common/change_flag_manager.py | 9 ++- .../tasks/common/ndfc_edge_connections.yml | 4 +- roles/dtc/common/tasks/common/ndfc_fabric.yml | 4 +- .../common/tasks/common/ndfc_fabric_links.yml | 4 +- .../tasks/common/ndfc_interface_access.yml | 4 +- .../tasks/common/ndfc_interface_access_po.yml | 4 +- .../tasks/common/ndfc_interface_all.yml | 4 +- .../tasks/common/ndfc_interface_breakout.yml | 4 +- .../ndfc_interface_breakout_preprov.yml | 4 +- .../tasks/common/ndfc_interface_dot1q.yml | 4 +- .../tasks/common/ndfc_interface_loopback.yml | 4 +- .../tasks/common/ndfc_interface_po_routed.yml | 4 +- .../tasks/common/ndfc_interface_routed.yml | 4 +- .../tasks/common/ndfc_interface_trunk.yml | 4 +- .../tasks/common/ndfc_interface_trunk_po.yml | 4 +- .../tasks/common/ndfc_interface_vpc.yml | 4 +- .../common/tasks/common/ndfc_inventory.yml | 4 +- roles/dtc/common/tasks/common/ndfc_policy.yml | 4 +- .../common/ndfc_sub_interface_routed.yml | 4 +- .../tasks/common/ndfc_underlay_ip_address.yml | 4 +- .../common/ndfc_vpc_domain_id_resource.yml | 4 +- .../common/ndfc_vpc_fabric_peering_links.yml | 4 +- .../tasks/common/ndfc_vpc_peering_pairs.yml | 4 +- .../tasks/external/ndfc_vpc_peering_pairs.yml | 2 +- roles/dtc/common/tasks/main.yml | 29 ++++++--- .../common/tasks/msd/ndfc_bgw_anycast_vip.yml | 4 +- .../dtc/common/tasks/msd/ndfc_child_vrfs.yml | 4 +- roles/dtc/common/tasks/msd/ndfc_fabric.yml | 5 +- roles/dtc/common/tasks/msd/ndfc_networks.yml | 4 +- roles/dtc/common/tasks/msd/ndfc_vrfs.yml | 4 +- roles/dtc/common/tasks/sub_main_msd.yml | 24 ------- .../dtc/common/tasks/vxlan/ndfc_networks.yml | 2 +- roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml | 2 +- roles/dtc/create/tasks/msd/vrfs_networks.yml | 62 +++++++++++-------- roles/dtc/remove/tasks/main.yml | 1 + roles/dtc/remove/tasks/msd/networks.yml | 33 +++------- .../remove/tasks/msd/vrf_network_common.yml | 59 ++++++++++++++++++ roles/dtc/remove/tasks/msd/vrfs.yml | 33 +++------- roles/dtc/remove/tasks/sub_main_msd.yml | 10 +++ 39 files changed, 210 insertions(+), 165 deletions(-) create mode 100644 roles/dtc/remove/tasks/msd/vrf_network_common.yml diff --git a/plugins/action/common/change_flag_manager.py b/plugins/action/common/change_flag_manager.py index 90a85abb9..32ff5df24 100644 --- a/plugins/action/common/change_flag_manager.py +++ b/plugins/action/common/change_flag_manager.py @@ -265,6 +265,7 @@ class ActionModule(ActionBase): def run(self, tmp=None, task_vars=None): results = super(ActionModule, self).run(tmp, task_vars) results['failed'] = False + results['flags'] = {} # Get data from Ansible task parameters params = {} @@ -281,9 +282,9 @@ def run(self, tmp=None, task_vars=None): results['msg'] = f"Missing required parameter '{key}'" return results - if params['operation'] not in ['initialize', 'update', 'display']: + if params['operation'] not in ['initialize', 'update', 'get', 'display']: results['failed'] = True - results['msg'] = "Parameter 'operation' must be one of: initialize, update, display" + results['msg'] = "Parameter 'operation' must be one of: [initialize, update, get, display]" return results # Supported Operations (intialize, update) @@ -320,6 +321,10 @@ def run(self, tmp=None, task_vars=None): self.process_write_result(success, params['change_flag'], params['flag_value'], params, results) + if params['operation'] == 'get': + change_detection_manager.changes_detected_flags = change_detection_manager.read_changes_detected_flags_from_file() + results['flags'] = change_detection_manager.changes_detected_flags[params['fabric_name']][params['fabric_type']] + if params['operation'] == "display": change_detection_manager.changes_detected_flags = change_detection_manager.read_changes_detected_flags_from_file() change_detection_manager.display_flag_values(task_vars) diff --git a/roles/dtc/common/tasks/common/ndfc_edge_connections.yml b/roles/dtc/common/tasks/common/ndfc_edge_connections.yml index ae3f96197..b307d3b0a 100644 --- a/roles/dtc/common/tasks/common/ndfc_edge_connections.yml +++ b/roles/dtc/common/tasks/common/ndfc_edge_connections.yml @@ -75,8 +75,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_edge_connections flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/common/ndfc_fabric.yml b/roles/dtc/common/tasks/common/ndfc_fabric.yml index 550b67cb5..e50d16533 100644 --- a/roles/dtc/common/tasks/common/ndfc_fabric.yml +++ b/roles/dtc/common/tasks/common/ndfc_fabric.yml @@ -74,8 +74,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_fabric flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/common/ndfc_fabric_links.yml b/roles/dtc/common/tasks/common/ndfc_fabric_links.yml index 8959ea374..d713c2aee 100644 --- a/roles/dtc/common/tasks/common/ndfc_fabric_links.yml +++ b/roles/dtc/common/tasks/common/ndfc_fabric_links.yml @@ -84,8 +84,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_fabric_links flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/common/ndfc_interface_access.yml b/roles/dtc/common/tasks/common/ndfc_interface_access.yml index 3415853b5..8e6eb0a5d 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_access.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_access.yml @@ -75,8 +75,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_interface_access flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/common/ndfc_interface_access_po.yml b/roles/dtc/common/tasks/common/ndfc_interface_access_po.yml index 4010cfa83..d633fcf7f 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_access_po.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_access_po.yml @@ -75,8 +75,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_interface_access_po flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/common/ndfc_interface_all.yml b/roles/dtc/common/tasks/common/ndfc_interface_all.yml index 4a1488e9a..82059fd11 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_all.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_all.yml @@ -123,8 +123,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_interfaces flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/common/ndfc_interface_breakout.yml b/roles/dtc/common/tasks/common/ndfc_interface_breakout.yml index 4716b1bc8..6809b34d2 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_breakout.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_breakout.yml @@ -75,8 +75,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_interface_breakout flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/common/ndfc_interface_breakout_preprov.yml b/roles/dtc/common/tasks/common/ndfc_interface_breakout_preprov.yml index c115e940f..d6a846e98 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_breakout_preprov.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_breakout_preprov.yml @@ -75,8 +75,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_interface_breakout_preprov flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/common/ndfc_interface_dot1q.yml b/roles/dtc/common/tasks/common/ndfc_interface_dot1q.yml index 5087f2946..af99ede21 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_dot1q.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_dot1q.yml @@ -75,8 +75,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_interface_dot1q flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/common/ndfc_interface_loopback.yml b/roles/dtc/common/tasks/common/ndfc_interface_loopback.yml index 0b1625253..bc956e3c1 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_loopback.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_loopback.yml @@ -78,8 +78,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_interface_loopback flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/common/ndfc_interface_po_routed.yml b/roles/dtc/common/tasks/common/ndfc_interface_po_routed.yml index 2a897b651..309020f08 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_po_routed.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_po_routed.yml @@ -75,8 +75,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_interface_po_routed flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/common/ndfc_interface_routed.yml b/roles/dtc/common/tasks/common/ndfc_interface_routed.yml index 2f456185a..381b58a49 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_routed.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_routed.yml @@ -75,8 +75,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_interface_routed flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/common/ndfc_interface_trunk.yml b/roles/dtc/common/tasks/common/ndfc_interface_trunk.yml index 850de988f..46f41e1b6 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_trunk.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_trunk.yml @@ -75,8 +75,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_interface_trunk flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/common/ndfc_interface_trunk_po.yml b/roles/dtc/common/tasks/common/ndfc_interface_trunk_po.yml index df4a65d07..f7e3e68b7 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_trunk_po.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_trunk_po.yml @@ -75,8 +75,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_interface_trunk_po flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/common/ndfc_interface_vpc.yml b/roles/dtc/common/tasks/common/ndfc_interface_vpc.yml index 1eab80264..e62520498 100644 --- a/roles/dtc/common/tasks/common/ndfc_interface_vpc.yml +++ b/roles/dtc/common/tasks/common/ndfc_interface_vpc.yml @@ -75,8 +75,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_interface_vpc flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/common/ndfc_inventory.yml b/roles/dtc/common/tasks/common/ndfc_inventory.yml index 334a050db..f13eb82d8 100644 --- a/roles/dtc/common/tasks/common/ndfc_inventory.yml +++ b/roles/dtc/common/tasks/common/ndfc_inventory.yml @@ -98,8 +98,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_inventory flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/common/ndfc_policy.yml b/roles/dtc/common/tasks/common/ndfc_policy.yml index b24caa79d..22e411c57 100644 --- a/roles/dtc/common/tasks/common/ndfc_policy.yml +++ b/roles/dtc/common/tasks/common/ndfc_policy.yml @@ -75,8 +75,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_policy flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/common/ndfc_sub_interface_routed.yml b/roles/dtc/common/tasks/common/ndfc_sub_interface_routed.yml index 5f9cddf81..2cd3cb017 100644 --- a/roles/dtc/common/tasks/common/ndfc_sub_interface_routed.yml +++ b/roles/dtc/common/tasks/common/ndfc_sub_interface_routed.yml @@ -75,8 +75,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_sub_interface_routed flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml b/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml index 5646335be..2425d7791 100644 --- a/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml +++ b/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml @@ -87,8 +87,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_underlay_ip_address flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml b/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml index a1509ac67..3934d6fa4 100644 --- a/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml +++ b/roles/dtc/common/tasks/common/ndfc_vpc_domain_id_resource.yml @@ -84,8 +84,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_vpc_domain_id_resource flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/common/ndfc_vpc_fabric_peering_links.yml b/roles/dtc/common/tasks/common/ndfc_vpc_fabric_peering_links.yml index 72e6dca89..f3a029584 100644 --- a/roles/dtc/common/tasks/common/ndfc_vpc_fabric_peering_links.yml +++ b/roles/dtc/common/tasks/common/ndfc_vpc_fabric_peering_links.yml @@ -78,8 +78,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_link_vpc_peering flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml b/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml index b80f707e5..58bf88c56 100644 --- a/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml +++ b/roles/dtc/common/tasks/common/ndfc_vpc_peering_pairs.yml @@ -84,8 +84,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_vpc_peering flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/external/ndfc_vpc_peering_pairs.yml b/roles/dtc/common/tasks/external/ndfc_vpc_peering_pairs.yml index 5ecc936dd..0cd18aad0 100644 --- a/roles/dtc/common/tasks/external/ndfc_vpc_peering_pairs.yml +++ b/roles/dtc/common/tasks/external/ndfc_vpc_peering_pairs.yml @@ -89,7 +89,7 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" + role_path: "{{ common_role_path }}" operation: "update" change_flag: changes_detected_vpc_peering flag_value: true diff --git a/roles/dtc/common/tasks/main.yml b/roles/dtc/common/tasks/main.yml index c9f2d1f00..1a2dff901 100644 --- a/roles/dtc/common/tasks/main.yml +++ b/roles/dtc/common/tasks/main.yml @@ -21,13 +21,18 @@ --- +- name: Create Fact To Store Common Role Path + ansible.builtin.set_fact: + common_role_path: "{{ role_path }}" + tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml + - name: Initialize Change Flags cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "initialize" - tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml + role_path: "{{ common_role_path }}" + operation: initialize + tags: "{{ nac_tags.common_role }}" delegate_to: localhost - name: Import Role Tasks for iBGP VXLAN Fabric @@ -55,15 +60,19 @@ tags: "{{ nac_tags.common_role }}" when: MD_Extended.vxlan.fabric.type == 'External' -- name: Read Change Flags JSON Data From File - ansible.builtin.set_fact: - change_flag_data: "{{ lookup('ansible.builtin.file', role_path + '/files/' + MD_Extended.vxlan.fabric.name + '_changes_detected_flags.json') | from_json }}" +- name: Retrieve Flag Values + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ common_role_path }}" + operation: get tags: "{{ nac_tags.common_role }}" + register: change_flag_result delegate_to: localhost -- name: Set Change Flags Fact +- name: Store Change Flags For Use In Subsequent Roles ansible.builtin.set_fact: - change_flags: "{{ change_flag_data[MD_Extended.vxlan.fabric.name][MD_Extended.vxlan.fabric.type] }}" + change_flags: "{{ change_flag_result['flags'] }}" tags: "{{ nac_tags.common_role }}" delegate_to: localhost @@ -71,7 +80,7 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "display" + role_path: "{{ common_role_path }}" + operation: display tags: "{{ nac_tags.common_role }}" delegate_to: localhost diff --git a/roles/dtc/common/tasks/msd/ndfc_bgw_anycast_vip.yml b/roles/dtc/common/tasks/msd/ndfc_bgw_anycast_vip.yml index cfc8e6e36..2d4d25420 100644 --- a/roles/dtc/common/tasks/msd/ndfc_bgw_anycast_vip.yml +++ b/roles/dtc/common/tasks/msd/ndfc_bgw_anycast_vip.yml @@ -74,8 +74,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_bgw_anycast_vip flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/msd/ndfc_child_vrfs.yml b/roles/dtc/common/tasks/msd/ndfc_child_vrfs.yml index 96d7af005..ddb56b51e 100644 --- a/roles/dtc/common/tasks/msd/ndfc_child_vrfs.yml +++ b/roles/dtc/common/tasks/msd/ndfc_child_vrfs.yml @@ -75,8 +75,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_vrfs flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/msd/ndfc_fabric.yml b/roles/dtc/common/tasks/msd/ndfc_fabric.yml index 4b9f724e1..5b72784f9 100644 --- a/roles/dtc/common/tasks/msd/ndfc_fabric.yml +++ b/roles/dtc/common/tasks/msd/ndfc_fabric.yml @@ -31,7 +31,6 @@ path: "{{ path_name }}{{ file_name }}" register: data_file_previous delegate_to: localhost - # TODO: Add capability to overridde path variable above for CI/CD pipeline - name: Backup Previous Data File If It Exists ansible.builtin.copy: @@ -75,8 +74,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_fabric flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/msd/ndfc_networks.yml b/roles/dtc/common/tasks/msd/ndfc_networks.yml index e4358686d..d482dbac5 100644 --- a/roles/dtc/common/tasks/msd/ndfc_networks.yml +++ b/roles/dtc/common/tasks/msd/ndfc_networks.yml @@ -75,8 +75,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_networks flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/msd/ndfc_vrfs.yml b/roles/dtc/common/tasks/msd/ndfc_vrfs.yml index 7031516fb..2989894d9 100644 --- a/roles/dtc/common/tasks/msd/ndfc_vrfs.yml +++ b/roles/dtc/common/tasks/msd/ndfc_vrfs.yml @@ -75,8 +75,8 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" - operation: "update" + role_path: "{{ common_role_path }}" + operation: update change_flag: changes_detected_vrfs flag_value: true delegate_to: localhost diff --git a/roles/dtc/common/tasks/sub_main_msd.yml b/roles/dtc/common/tasks/sub_main_msd.yml index c5c687a10..f769273a1 100644 --- a/roles/dtc/common/tasks/sub_main_msd.yml +++ b/roles/dtc/common/tasks/sub_main_msd.yml @@ -61,35 +61,11 @@ - name: Build MSD Child Fabric BGW Anycast VIP List From Template ansible.builtin.import_tasks: msd/ndfc_bgw_anycast_vip.yml -# ------------------------------------------------------------------------ -# Build MSD Fabric VRFs Attach List From Template -# ------------------------------------------------------------------------ - -# - name: Build MSD Fabric VRFs Attach List From Template -# ansible.builtin.import_tasks: msd/ndfc_vrfs.yml - -# ------------------------------------------------------------------------ -# Build MSD Fabric Networks Attach List From Template -# ------------------------------------------------------------------------ - -# - name: Build MSD Fabric Networks Attach List From Template -# ansible.builtin.import_tasks: msd/ndfc_networks.yml - # ------------------------------------------------------------------------ # Save Local Variables To NameSpace Dict For Use Elsewhere # ------------------------------------------------------------------------ - name: Save Local Variables With Namespace Context ansible.builtin.set_fact: vars_common_msd: - # because ansible.builtin.set_fact copmletely rewrites vars_common_msd and we need - # to keep alignment with the initialzed false state in common/main.yml. - # The proper state will update in create/sub_main_msd.yml as that is where vrfs and networks - # data is processed as we must process the vrfs and networks data only after multsite data is prepared. - changes_detected_vrfs: false - changes_detected_networks: false fabric_config: "{{ fabric_config }}" bgw_anycast_vip: "{{ bgw_anycast_vip }}" - # vrf_config: "{{ vrf_config }}" - # net_config: "{{ net_config }}" - # Check with Matt and Pete on how to handle this for MSD - # vrf_attach_config: "{{ vrf_attach_config }}" diff --git a/roles/dtc/common/tasks/vxlan/ndfc_networks.yml b/roles/dtc/common/tasks/vxlan/ndfc_networks.yml index 7b674a98d..5cde7f64f 100644 --- a/roles/dtc/common/tasks/vxlan/ndfc_networks.yml +++ b/roles/dtc/common/tasks/vxlan/ndfc_networks.yml @@ -85,7 +85,7 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" + role_path: "{{ common_role_path }}" operation: "update" change_flag: changes_detected_networks flag_value: true diff --git a/roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml b/roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml index 46cf1206e..61d7cca24 100644 --- a/roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml +++ b/roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml @@ -85,7 +85,7 @@ cisco.nac_dc_vxlan.common.change_flag_manager: fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ role_path }}" + role_path: "{{ common_role_path }}" operation: "update" change_flag: changes_detected_vrfs flag_value: true diff --git a/roles/dtc/create/tasks/msd/vrfs_networks.yml b/roles/dtc/create/tasks/msd/vrfs_networks.yml index e71faa4e8..92c2cc02b 100644 --- a/roles/dtc/create/tasks/msd/vrfs_networks.yml +++ b/roles/dtc/create/tasks/msd/vrfs_networks.yml @@ -41,6 +41,7 @@ # pre-processing is done for the MSD fabric itself (and child fabrics when functionality is added). # The import_role tasks were removed due to a bug in ansible-core 2.16.5 not finding the role and tasks_from file whereas ansible-core 2.17.8+ works. +# Do Not Remove (Historical Context) # - name: Run dtc.common.tasks.msd.ndfc_vrfs.yml # ansible.builtin.import_role: # name: dtc.common @@ -62,36 +63,47 @@ - name: Run dtc.common.tasks.msd.ndfc_networks.yml ansible.builtin.import_tasks: "{{ role_path }}/../common/tasks/msd/ndfc_networks.yml" -# -------------------------------------------------------------------- -# Update Local Variables To NameSpace Dict For Use Elsewhere -# -------------------------------------------------------------------- +# ---------------------------------------------------------------------------------- +# Changes detected flags for Multisite VRF and Networks is set when the tasks above +# are imported. We need to retrieve and store the values. +# ---------------------------------------------------------------------------------- +- name: Retrieve Multisite Flag Values + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ common_role_path }}" + operation: get + tags: "{{ nac_tags.common_role }}" + register: change_flag_multisite_result + delegate_to: localhost + +- name: Store Change Flags For Use In Subsequent Roles + ansible.builtin.set_fact: + change_flags_multisite: "{{ change_flag_multisite_result['flags'] }}" + tags: "{{ nac_tags.common_role }}" + delegate_to: localhost + +- name: Display Flag Values + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ common_role_path }}" + operation: display + delegate_to: localhost + +# ---------------------------------------------------------------------------------- +# Likewise, the vrf_config and net_config data is created when the tasks above +# are imported so we need to update and store them in vars_common_msd +# ---------------------------------------------------------------------------------- - name: Update Local Variables With Namespace Context ansible.builtin.set_fact: vars_common_msd: "{{ vars_common_msd | ansible.builtin.combine(update_data) }}" vars: update_data: - # changes_detected_vrfs and changes_detected_networks are set in the - # dtc.common.tasks.msd.ndfc_vrfs.yml and dtc.common.tasks.msd.ndfc_networks.yml tasks - changes_detected_vrfs: "{{ changes_detected_vrfs }}" - changes_detected_networks: "{{ changes_detected_networks }}" vrf_config: "{{ vrf_config }}" net_config: "{{ net_config }}" - # Check with Matt and Pete on how to handle this for MSD - # vrf_attach_config: "{{ vrf_attach_config }}" - -- name: Run Diff Flags - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ Fabric Changes Detected - [ {{ vars_common_msd.changes_detected_fabric }} ]" - - "+ VRFs Changes Detected - [ {{ vars_common_msd.changes_detected_vrfs }} ]" - - "+ Networks Changes Detected - [ {{ vars_common_msd.changes_detected_networks }} ]" - - "+ ----- Run Map -----" - - "+ Run Map Diff Run - [ {{ run_map_read_result.diff_run }} ]" - - "+ Force Run Flag - [ {{ force_run_all }} ]" - - "----------------------------------------------------------------" -# With the VRFs and Networking pre-processed, we can now send the configuration for the MSD fabric to NDFC +# With the VRFs and Networking pre-processed, we can now send the configuration for the MSD fabric to ND # based on the detected changes. This is done in the following tasks. # -------------------------------------------------------------------- @@ -107,7 +119,7 @@ when: - MD_Extended.vxlan.multisite.overlay.vrfs is defined - MD_Extended.vxlan.multisite.overlay.vrfs - - vars_common_msd.changes_detected_vrfs + - change_flags_multisite.changes_detected_vrfs - name: Manage Child Fabric VRFs in Nexus Dashboard cisco.nac_dc_vxlan.dtc.manage_child_fabric_vrfs: @@ -128,7 +140,7 @@ # when: # - MD_Extended.vxlan.overlay.vrfs is defined # - MD_Extended.vxlan.overlay.vrfs -# - vars_common_msd.changes_detected_vrfs +# - change_flags_multisite.changes_detected_vrfs # -------------------------------------------------------------------- # Manage Network Configuration on NDFC @@ -142,7 +154,7 @@ when: - MD_Extended.vxlan.multisite.overlay.networks is defined - MD_Extended.vxlan.multisite.overlay.networks - - vars_common_msd.changes_detected_networks + - change_flags_multisite.changes_detected_networks - name: Manage Child Fabric Networks in Nexus Dashboard cisco.nac_dc_vxlan.dtc.manage_child_fabric_networks: diff --git a/roles/dtc/remove/tasks/main.yml b/roles/dtc/remove/tasks/main.yml index 21487455e..6148d63e3 100644 --- a/roles/dtc/remove/tasks/main.yml +++ b/roles/dtc/remove/tasks/main.yml @@ -66,6 +66,7 @@ name: cisco.nac_dc_vxlan.dtc.deploy when: - stage_remove is false|bool + - not MD_Extended.vxlan.fabric.type == 'MSD' - name: Mark Stage Role Remove Completed cisco.nac_dc_vxlan.common.run_map: diff --git a/roles/dtc/remove/tasks/msd/networks.yml b/roles/dtc/remove/tasks/msd/networks.yml index c6f8153d6..3e34a339c 100644 --- a/roles/dtc/remove/tasks/msd/networks.yml +++ b/roles/dtc/remove/tasks/msd/networks.yml @@ -27,28 +27,15 @@ when: - (multisite_network_delete_mode is defined) and (multisite_network_delete_mode is true|bool) -# If run_map_read_result.diff_run is true then we know that the changes_detected_networks flag -# was set in the dtc.common.tasks.msd.ndfc_networks.yml tasks. -# -# Otherwise, we set the flag to True to ensure the VRFs will be removed when the diff_run -# feature is not enabled. -- name: If run_map_read_result.diff_run is false then set changes_detected_networks to true - ansible.builtin.set_fact: - vars_common_msd: "{{ vars_common_msd | ansible.builtin.combine(update_data) }}" - vars: - update_data: - changes_detected_networks: true - when: not run_map_read_result.diff_run - -- name: Run Diff Flags - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ Networks Changes Detected - [ {{ vars_common_msd.changes_detected_networks }} ]" - - "+ ----- Run Map -----" - - "+ Run Map Diff Run - [ {{ run_map_read_result.diff_run }} ]" - - "+ Force Run Flag - [ {{ force_run_all }} ]" - - "----------------------------------------------------------------" +- name: Display Flag Values - Changes Detected Networks + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ common_role_path }}" + operation: display + delegate_to: localhost + when: + - (multisite_network_delete_mode is defined) and (multisite_network_delete_mode is true|bool) - name: Remove Unmanaged Fabric Networks in Nexus Dashboard cisco.nac_dc_vxlan.dtc.unmanaged_child_fabric_networks: @@ -58,7 +45,7 @@ when: - multisite_network_delete_mode is defined - multisite_network_delete_mode is true | bool - - vars_common_msd.changes_detected_networks + - change_flags_multisite.changes_detected_networks - MD_Extended.vxlan.multisite.child_fabrics is defined and MD_Extended.vxlan.multisite.child_fabrics | length > 0 - name: Skip Remove Unmanaged Fabric Networks Task If multisite_network_delete_mode is False diff --git a/roles/dtc/remove/tasks/msd/vrf_network_common.yml b/roles/dtc/remove/tasks/msd/vrf_network_common.yml new file mode 100644 index 000000000..f1baaf638 --- /dev/null +++ b/roles/dtc/remove/tasks/msd/vrf_network_common.yml @@ -0,0 +1,59 @@ +# Copyright (c) 2025 Cisco Systems, Inc. and its affiliates +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +# the Software, and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# SPDX-License-Identifier: MIT + +--- + +# ------------------------------------------------------------------------------------ +# This file is only imported in the remove role when the diff_run feature is disabled. +# If the diff_run feature is enabled, then the vrfs and networks tasks were imported +# when the create role was run. +# ------------------------------------------------------------------------------------ + +- name: Set path_name Var + ansible.builtin.set_fact: + path_name: "{{ role_path }}/../common/files/msd/{{ MD_Extended.vxlan.fabric.name }}/" + delegate_to: localhost + +- name: Run dtc.common.tasks.msd.ndfc_vrfs.yml + ansible.builtin.import_tasks: "{{ role_path }}/../common/tasks/msd/ndfc_vrfs.yml" + +- name: Run dtc.common.tasks.msd.ndfc_networks.yml + ansible.builtin.import_tasks: "{{ role_path }}/../common/tasks/msd/ndfc_networks.yml" + +# ---------------------------------------------------------------------------------- +# Changes detected flags for Multisite VRF and Networks is set when the tasks above +# are imported. We need to retrieve and store the values. +# ---------------------------------------------------------------------------------- +- name: Retrieve Multisite Flag Values + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ common_role_path }}" + operation: get + tags: "{{ nac_tags.common_role }}" + register: change_flag_multisite_result + delegate_to: localhost + +- name: Store Change Flags For Use In Subsequent Roles + ansible.builtin.set_fact: + change_flags_multisite: "{{ change_flag_multisite_result['flags'] }}" + tags: "{{ nac_tags.common_role }}" + delegate_to: localhost diff --git a/roles/dtc/remove/tasks/msd/vrfs.yml b/roles/dtc/remove/tasks/msd/vrfs.yml index 2fbfb51d2..c5e3b4d60 100644 --- a/roles/dtc/remove/tasks/msd/vrfs.yml +++ b/roles/dtc/remove/tasks/msd/vrfs.yml @@ -27,28 +27,15 @@ when: - (multisite_vrf_delete_mode is defined) and (multisite_vrf_delete_mode is true|bool) -# If run_map_read_result.diff_run is true then we know that the changes_detected_vrfs flag -# was set in the dtc.common.tasks.msd.ndfc_vrfs.yml tasks. -# -# Otherwise, we set the flag to True to ensure the VRFs will be removed when the diff_run -# feature is not enabled. -- name: If run_map_read_result.diff_run is false then set changes_detected_networks to true - ansible.builtin.set_fact: - vars_common_msd: "{{ vars_common_msd | ansible.builtin.combine(update_data) }}" - vars: - update_data: - changes_detected_vrfs: true - when: not run_map_read_result.diff_run - -- name: Run Diff Flags - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ VRFs Changes Detected - [ {{ vars_common_msd.changes_detected_vrfs }} ]" - - "+ ----- Run Map -----" - - "+ Run Map Diff Run - [ {{ run_map_read_result.diff_run }} ]" - - "+ Force Run Flag - [ {{ force_run_all }} ]" - - "----------------------------------------------------------------" +- name: Display Flag Values - Changes Detected VRFs + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ common_role_path }}" + operation: display + delegate_to: localhost + when: + - (multisite_vrf_delete_mode is defined) and (multisite_vrf_delete_mode is true|bool) - name: Remove Unmanaged Fabric VRFs in Nexus Dashboard cisco.nac_dc_vxlan.dtc.unmanaged_child_fabric_vrfs: @@ -58,7 +45,7 @@ when: - multisite_vrf_delete_mode is defined - multisite_vrf_delete_mode is true | bool - - vars_common_msd.changes_detected_vrfs + - change_flags_multisite.changes_detected_vrfs - MD_Extended.vxlan.multisite.child_fabrics is defined and MD_Extended.vxlan.multisite.child_fabrics | length > 0 - name: Skip Remove Unmanaged Fabric VRFs Task If multisite_vrf_delete_mode is False diff --git a/roles/dtc/remove/tasks/sub_main_msd.yml b/roles/dtc/remove/tasks/sub_main_msd.yml index 6a9b0d525..141edc74e 100644 --- a/roles/dtc/remove/tasks/sub_main_msd.yml +++ b/roles/dtc/remove/tasks/sub_main_msd.yml @@ -50,6 +50,16 @@ - "{{ nac_tags.remove_networks }}" - "{{ nac_tags.remove_vrfs }}" +# ------------------------------------------------------------------------------------ +# This file is only imported in the remove role when the diff_run feature is disabled. +# If the diff_run feature is enabled, then the vrfs and networks tasks were imported +# when the create role was run. +# ------------------------------------------------------------------------------------ +- name: Import VRF and Network Roles From Common If Needed + ansible.builtin.import_tasks: msd/vrf_network_common.yml + tags: "{{ nac_tags.remove_networks }}" + when: not run_map_read_result.diff_run + - name: Remove MSD Fabric Networks from Nexus Dashboard ansible.builtin.import_tasks: msd/networks.yml tags: "{{ nac_tags.remove_networks }}" From 94c118b7524f1d9aa1e599204aa483584795890a Mon Sep 17 00:00:00 2001 From: mwiebe Date: Sat, 11 Oct 2025 12:57:46 -0400 Subject: [PATCH 35/65] Minor cleanup --- plugins/action/common/change_flag_manager.py | 4 ++-- .../common/tasks/external/ndfc_vpc_peering_pairs.yml | 2 +- roles/dtc/deploy/tasks/main.yml | 11 ----------- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/plugins/action/common/change_flag_manager.py b/plugins/action/common/change_flag_manager.py index 32ff5df24..2fa21fdf0 100644 --- a/plugins/action/common/change_flag_manager.py +++ b/plugins/action/common/change_flag_manager.py @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates +# Copyright (c) 2025 Cisco Systems, Inc. and its affiliates # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -321,7 +321,7 @@ def run(self, tmp=None, task_vars=None): self.process_write_result(success, params['change_flag'], params['flag_value'], params, results) - if params['operation'] == 'get': + if params['operation'] == "get": change_detection_manager.changes_detected_flags = change_detection_manager.read_changes_detected_flags_from_file() results['flags'] = change_detection_manager.changes_detected_flags[params['fabric_name']][params['fabric_type']] diff --git a/roles/dtc/common/tasks/external/ndfc_vpc_peering_pairs.yml b/roles/dtc/common/tasks/external/ndfc_vpc_peering_pairs.yml index 0cd18aad0..c6efcd834 100644 --- a/roles/dtc/common/tasks/external/ndfc_vpc_peering_pairs.yml +++ b/roles/dtc/common/tasks/external/ndfc_vpc_peering_pairs.yml @@ -90,7 +90,7 @@ fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" role_path: "{{ common_role_path }}" - operation: "update" + operation: update change_flag: changes_detected_vpc_peering flag_value: true delegate_to: localhost diff --git a/roles/dtc/deploy/tasks/main.yml b/roles/dtc/deploy/tasks/main.yml index 4a9f0c008..14ee51d69 100644 --- a/roles/dtc/deploy/tasks/main.yml +++ b/roles/dtc/deploy/tasks/main.yml @@ -21,17 +21,6 @@ --- -# - name: Import MSD Fabric Role Tasks -# ansible.builtin.import_tasks: sub_main_msd.yml -# tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml -# when: > -# (MD_Extended.vxlan.fabric.type == 'MSD') and -# (vars_common_msd.changes_detected_fabric or -# vars_common_msd.changes_detected_vrfs or -# vars_common_msd.changes_detected_networks or -# (child_fabrics_vrfs_networks_changed is defined and child_fabrics_vrfs_networks_changed | length > 0) or -# vars_common_msd.changes_detected_bgw_anycast_vip) - - name: Import iBGP VXLAN EVPN Role Tasks ansible.builtin.import_tasks: sub_main_vxlan.yml tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml From 5658ceefe478479eae771ce5af6aa2af6c79b7bf Mon Sep 17 00:00:00 2001 From: mwiebe Date: Sat, 11 Oct 2025 16:33:00 -0400 Subject: [PATCH 36/65] New fabric_deploy_manager --- plugins/action/common/change_flag_manager.py | 2 +- plugins/action/dtc/fabric_deploy_manager.py | 205 ++++++++++++++++++ .../dtc/deploy/tasks/sub_main_ebgp_vxlan.yml | 65 +----- roles/dtc/deploy/tasks/sub_main_external.yml | 36 +-- roles/dtc/deploy/tasks/sub_main_isn.yml | 36 +-- roles/dtc/deploy/tasks/sub_main_msd.yml | 37 +--- roles/dtc/deploy/tasks/sub_main_vxlan.yml | 98 +-------- 7 files changed, 238 insertions(+), 241 deletions(-) create mode 100644 plugins/action/dtc/fabric_deploy_manager.py diff --git a/plugins/action/common/change_flag_manager.py b/plugins/action/common/change_flag_manager.py index 2fa21fdf0..50cb8d01b 100644 --- a/plugins/action/common/change_flag_manager.py +++ b/plugins/action/common/change_flag_manager.py @@ -329,7 +329,7 @@ def run(self, tmp=None, task_vars=None): change_detection_manager.changes_detected_flags = change_detection_manager.read_changes_detected_flags_from_file() change_detection_manager.display_flag_values(task_vars) from time import sleep - sleep(10) + sleep(2) return results diff --git a/plugins/action/dtc/fabric_deploy_manager.py b/plugins/action/dtc/fabric_deploy_manager.py new file mode 100644 index 000000000..62cc58f00 --- /dev/null +++ b/plugins/action/dtc/fabric_deploy_manager.py @@ -0,0 +1,205 @@ +# Copyright (c) 2025 Cisco Systems, Inc. and its affiliates +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +# the Software, and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# SPDX-License-Identifier: MIT + +from __future__ import absolute_import, division, print_function + + +__metaclass__ = type + +from ansible.utils.display import Display +from ansible.plugins.action import ActionBase +import inspect + + +display = Display() + +class FabricDeployManager: + """Manages fabric deployment tasks.""" + + def __init__(self, params): + self.class_name = self.__class__.__name__ + method_name = inspect.stack()[0][3] + + # Fabric Parameters + self.fabric_name = params['fabric_name'] + self.fabric_type = params['fabric_type'] + + # Module Execution Parameters + self.task_vars = params['task_vars'] + self.tmp = params['tmp'] + self.action_module = params['action_module'] + self.module_name = "cisco.dcnm.dcnm_rest" + + # Module API Paths + self.api_paths = { + "get_switches_by_fabric": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{self.fabric_name}/inventory/switchesByFabric", + "config_save": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{self.fabric_name}/config-save", + "config_deploy": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{self.fabric_name}/config-deploy?forceShowRun=false", + "fabric_history": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/config/delivery/deployerHistoryByFabric/{self.fabric_name}?sort=completedTime%3ADES&limit=5", + } + + # Fabric State Booleans + self.fabric_in_sync = True + self.fabric_save_succeeded = True + self.fabric_deploy_succeeded = True + + # Fabric History + self.fabric_history = [] + + def fabric_check_sync(self): + """Check if the fabric is in sync.""" + method_name = inspect.stack()[0][3] + display.banner(f"{self.class_name}.{method_name}() Fabric: ({self.fabric_name}) Type: ({self.fabric_type})") + + response = self._send_request("GET", self.api_paths["get_switches_by_fabric"]) + + if response['response'].get('DATA'): + for switch in response['response']['DATA']: + if switch['ccStatus'] == 'Out-of-Sync': + self.fabric_in_sync = False + break + + display.banner(f">>>> Fabric: ({self.fabric_name}) Type: ({self.fabric_type}) in sync: {self.fabric_in_sync}") + + def fabric_config_save(self): + """Trigger a config-save on the fabric.""" + method_name = inspect.stack()[0][3] + display.banner(f"{self.class_name}.{method_name}() Fabric: ({self.fabric_name}) Type: ({self.fabric_type})") + + response = self._send_request("POST", self.api_paths["config_save"]) + + if response['response'].get('RETURN_CODE') == 200: + display.banner(f">>>> Succeeded for Fabric {self.fabric_name}") + else: + self.fabric_save_succeeded = False + display.warning(f">>>> Failed for Fabric {self.fabric_name}: {response}") + + def fabric_deploy(self): + """Deploy the fabric configuration.""" + method_name = inspect.stack()[0][3] + display.banner(f"{self.class_name}.{method_name}() Fabric: ({self.fabric_name}) Type: ({self.fabric_type})") + + response = self._send_request("POST", self.api_paths["config_deploy"]) + if response['response'].get('RETURN_CODE') == 200: + display.banner(f">>>> Succeeded for Fabric {self.fabric_name}") + else: + self.fabric_deploy_succeeded = False + display.warning(f">>>> Failed for Fabric {self.fabric_name}: {response}") + + def fabric_history_get(self): + """Retrieve fabric deployment history.""" + method_name = inspect.stack()[0][3] + display.banner(f"{self.class_name}.{method_name}() Fabric: ({self.fabric_name}) Type: ({self.fabric_type})") + + response = self._send_request("GET", self.api_paths["fabric_history"]) + if response['response'].get('RETURN_CODE') == 200: + display.banner(f">>>> Succeeded for Fabric {self.fabric_name}") + else: + display.warning(f">>>> Failed for Fabric {self.fabric_name}: {response}") + + # Get last 2 history entries + self.fabric_history = response['response'].get('DATA', [])[0:2] + + + def _send_request(self, method, path, data=None): + """Helper method to send REST API requests.""" + + module_args = { + "method": method, + "path": path, + } + if data: + module_args["data"] = data + + response = self.action_module._execute_module( + module_name=self.module_name, + module_args=module_args, + task_vars=self.task_vars, + tmp=self.tmp + ) + return response + +class ActionModule(ActionBase): + + def run(self, tmp=None, task_vars=None): + results = super(ActionModule, self).run(tmp, task_vars) + results['failed'] = False + + params = {} + params['fabric_name'] = self._task.args["fabric_name"] + params['fabric_type'] = self._task.args["fabric_type"] + params['operation'] = self._task.args.get("operation") + + for key in ['fabric_type', 'fabric_name', 'operation']: + if params[key] is None: + results['failed'] = True + results['msg'] = f"Missing required parameter '{key}'" + return results + + if params['operation'] not in ['all', 'config_save', 'config_deploy', 'check_sync']: + results['failed'] = True + results['msg'] = "Parameter 'operation' must be one of: [all, config_save, config_deploy, check_sync]" + return results + + # Module Execution Context Parameters + params['task_vars'] = task_vars + params['tmp'] = tmp + params['action_module'] = self + + fabric_manager = FabricDeployManager(params) + + # Workflows + if params['operation'] in ['all']: + fabric_manager.fabric_config_save() + fabric_manager.fabric_deploy() + fabric_manager.fabric_check_sync() + + if not fabric_manager.fabric_in_sync: + # If the fabric is out of sync after deployment try one more time before giving up + display.warning("Fabric is out of sync after initial deployment. Attempting one more deployment.") + fabric_manager.fabric_config_save() + fabric_manager.fabric_deploy() + + if not fabric_manager.fabric_in_sync: + fabric_manager.fabric_history_get() + display.error(f"Fabric {fabric_manager.fabric_name} is out of sync after deployment.") + display.error(fabric_manager.fabric_history) + results['failed'] = True + + if params['operation'] in ['config_save']: + fabric_manager.fabric_config_save() + if not fabric_manager.fabric_save_succeeded: + results['failed'] = True + + if params['operation'] in ['config_deploy']: + fabric_manager.fabric_deploy() + if not fabric_manager.fabric_deploy_succeeded: + results['failed'] = True + + if params['operation'] in ['check_sync']: + fabric_manager.fabric_check_sync() + if not fabric_manager.fabric_in_sync: + fabric_manager.fabric_history_get() + display.error(f"Fabric {fabric_manager.fabric_name} is out of sync.") + display.error(fabric_manager.fabric_history) + results['failed'] = True + + return results diff --git a/roles/dtc/deploy/tasks/sub_main_ebgp_vxlan.yml b/roles/dtc/deploy/tasks/sub_main_ebgp_vxlan.yml index d43d102a9..9833d2717 100644 --- a/roles/dtc/deploy/tasks/sub_main_ebgp_vxlan.yml +++ b/roles/dtc/deploy/tasks/sub_main_ebgp_vxlan.yml @@ -35,69 +35,14 @@ - "+ VXLAN EBGP FABRIC +" - "----------------------------------------------------------------" -- name: Display Device Configuration Method - ansible.builtin.debug: - msg: "Configuring NXOS Devices using NDFC (Direct to Controller)" - -- name: Config-Save Block for eBGP VXLAN Fabric in Nexus Dashboard - block: - - name: Config-Save for eBGP VXLAN Fabric in Nexus Dashboard - cisco.dcnm.dcnm_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" - register: config_save - when: > - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) - # TODO: Need to add logic to only save if changes are made - - rescue: - - name: Config-Save for eBGP VXLAN Fabric in Nexus Dashboard - Failed - ansible.builtin.debug: - msg: "{{ config_save.msg.DATA }}" - -- name: Deploy for eBGP VXLAN Fabric in Nexus Dashboard - cisco.dcnm.dcnm_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" - vars: - ansible_command_timeout: 3000 - ansible_connect_timeout: 3000 - when: > - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) - # TODO: Need to add logic to only deploy if changes are made - -- name: Check Switch Sync in eBGP VXLAN Fabric in Nexus Dashboard - cisco.nac_dc_vxlan.dtc.fabric_check_sync: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - register: results - when: > - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) - -- name: Retrying Config-Save Block for eBGP VXLAN Fabric in Nexus Dashboard - block: - - name: Retrying Config-Save for eBGP VXLAN Fabric in Nexus Dashboard - cisco.dcnm.dcnm_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" - register: config_save - when: - - MD_Extended.vxlan.topology.switches is defined - - MD_Extended.vxlan.topology.switches | length > 0 - - results.changed - - rescue: - - name: Retrying Config-Save for eBGP VXLAN Fabric in Nexus Dashboard - Failed - ansible.builtin.debug: - msg: "{{ config_save.msg.DATA }}" - -- name: Retrying Deploy for eBGP VXLAN Fabric in Nexus Dashboard - cisco.dcnm.dcnm_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" +- name: Manage Fabric Deployment for eBGP VXLAN Fabric in Nexus Dashboard + cisco.nac_dc_vxlan.dtc.fabric_deploy_manager: + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + operation: all vars: ansible_command_timeout: 3000 ansible_connect_timeout: 3000 when: - MD_Extended.vxlan.topology.switches is defined - MD_Extended.vxlan.topology.switches | length > 0 - - results.changed diff --git a/roles/dtc/deploy/tasks/sub_main_external.yml b/roles/dtc/deploy/tasks/sub_main_external.yml index 6c5d31b11..8da778712 100644 --- a/roles/dtc/deploy/tasks/sub_main_external.yml +++ b/roles/dtc/deploy/tasks/sub_main_external.yml @@ -35,34 +35,14 @@ - "+ External FABRIC +" - "----------------------------------------------------------------" -- name: Display Device Configuration Method - ansible.builtin.debug: - msg: "Configuring NXOS Devices using NDFC (Direct to Controller)" - -- name: Config-Save Block for External Fabric in Nexus Dashboard - block: - - name: Config-Save for External Fabric in Nexus Dashboard - cisco.dcnm.dcnm_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" - register: config_save - when: > - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) - # TODO: Need to add logic to only save if changes are made - - rescue: - - name: Config-Save for External Fabric in Nexus Dashboard - Failed - ansible.builtin.debug: - msg: "{{ config_save.msg.DATA }}" - when: config_save.msg.RETURN_CODE is defined and config_save.msg.RETURN_CODE == 500 - -- name: Deploy for External Fabric in Nexus Dashboard - cisco.dcnm.dcnm_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" +- name: Manage Fabric Deployment for External Fabric in Nexus Dashboard + cisco.nac_dc_vxlan.dtc.fabric_deploy_manager: + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + operation: all vars: ansible_command_timeout: 3000 ansible_connect_timeout: 3000 - when: > - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) - # TODO: Need to add logic to only deploy if changes are made + when: + - MD_Extended.vxlan.topology.switches is defined + - MD_Extended.vxlan.topology.switches | length > 0 diff --git a/roles/dtc/deploy/tasks/sub_main_isn.yml b/roles/dtc/deploy/tasks/sub_main_isn.yml index 0ed54c76c..808155f14 100644 --- a/roles/dtc/deploy/tasks/sub_main_isn.yml +++ b/roles/dtc/deploy/tasks/sub_main_isn.yml @@ -35,34 +35,14 @@ - "+ ISN FABRIC +" - "----------------------------------------------------------------" -- name: Display Device Configuration Method - ansible.builtin.debug: - msg: "Configuring NXOS Devices using NDFC (Direct to Controller)" - -- name: Config-Save Block for ISN Fabric in Nexus Dashboard - block: - - name: Config-Save for ISN Fabric in Nexus Dashboard - cisco.dcnm.dcnm_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" - register: config_save - when: > - (MD_Extended.vxlan.fabric.type == 'ISN' and - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0)) - - rescue: - - name: Config-Save for ISN Fabric in Nexus Dashboard - Failed - ansible.builtin.debug: - msg: "{{ config_save.msg.DATA }}" - when: config_save.msg.RETURN_CODE is defined and config_save.msg.RETURN_CODE == 500 - -- name: Deploy for ISN Fabric in Nexus Dashboard - cisco.dcnm.dcnm_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" +- name: Manage Fabric Deployment for ISN Fabric in Nexus Dashboard + cisco.nac_dc_vxlan.dtc.fabric_deploy_manager: + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + operation: all vars: ansible_command_timeout: 3000 ansible_connect_timeout: 3000 - when: > - (MD_Extended.vxlan.fabric.type == 'ISN' and - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0)) + when: + - MD_Extended.vxlan.topology.switches is defined + - MD_Extended.vxlan.topology.switches | length > 0 diff --git a/roles/dtc/deploy/tasks/sub_main_msd.yml b/roles/dtc/deploy/tasks/sub_main_msd.yml index d104aac10..275cfe01e 100644 --- a/roles/dtc/deploy/tasks/sub_main_msd.yml +++ b/roles/dtc/deploy/tasks/sub_main_msd.yml @@ -35,44 +35,19 @@ - "+ MSD FABRIC +" - "----------------------------------------------------------------" -- name: Display Device Configuration Method - ansible.builtin.debug: - msg: "Configuring NXOS Devices using NDFC (Direct to Controller)" - -- name: Config-Save Block for MSD Fabric in Nexus Dashboard - block: - - name: Config-Save for MSD Fabric in Nexus Dashboard - cisco.dcnm.dcnm_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" - register: config_save - when: MD_Extended.vxlan.fabric.type == 'MSD' - - rescue: - - name: Config-Save for MSD Fabric in Nexus Dashboard - Failed - ansible.builtin.debug: - msg: "{{ config_save.msg.DATA }}" - when: config_save.msg.RETURN_CODE is defined and config_save.msg.RETURN_CODE == 500 - -- name: Deploy for MSD Fabric in Nexus Dashboard - cisco.dcnm.dcnm_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" +- name: Manage Fabric Deployment for MSD Fabric in Nexus Dashboard + cisco.nac_dc_vxlan.dtc.fabric_deploy_manager: + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + operation: all vars: ansible_command_timeout: 3000 ansible_connect_timeout: 3000 when: - - MD_Extended.vxlan.fabric.type == 'MSD' - MD_Extended.vxlan.multisite.child_fabrics is defined - MD_Extended.vxlan.multisite.child_fabrics | length > 0 -- name: Config-Save For MSD Child Fabrics in Nexus Dashboard - cisco.nac_dc_vxlan.dtc.fabrics_config_save: - fabrics: "{{ child_fabrics_vrfs_networks_changed }}" - when: > - MD_Extended.vxlan.fabric.type == 'MSD' and - (child_fabrics_vrfs_networks_changed is defined and child_fabrics_vrfs_networks_changed | length > 0) - +# TODO: Update cisco.nac_dc_vxlan.dtc.fabric_deploy_manager to handle a list of child fabrics - name: Deploy For MSD Child Fabrics in Nexus Dashboard cisco.nac_dc_vxlan.dtc.fabrics_deploy: fabrics: "{{ child_fabrics_vrfs_networks_changed }}" diff --git a/roles/dtc/deploy/tasks/sub_main_vxlan.yml b/roles/dtc/deploy/tasks/sub_main_vxlan.yml index 02a5177e1..32a3915e7 100644 --- a/roles/dtc/deploy/tasks/sub_main_vxlan.yml +++ b/roles/dtc/deploy/tasks/sub_main_vxlan.yml @@ -35,102 +35,14 @@ - "+ VXLAN IBGP FABRIC +" - "----------------------------------------------------------------" -- name: Display Device Configuration Method - ansible.builtin.debug: - msg: "Configuring NXOS Devices using NDFC (Direct to Controller)" - -- name: Config-Save Block for iBGP VXLAN Fabric in Nexus Dashboard - block: - - name: Config-Save for iBGP VXLAN Fabric in Nexus Dashboard - cisco.dcnm.dcnm_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" - register: config_save - when: > - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) - - rescue: - - name: Config-Save for iBGP VXLAN Fabric in Nexus Dashboard - Failed - ansible.builtin.debug: - msg: "{{ config_save.msg.DATA }}" - when: config_save.msg.RETURN_CODE is defined and config_save.msg.RETURN_CODE == 500 - -- name: Deploy for iBGP VXLAN Fabric in Nexus Dashboard - cisco.dcnm.dcnm_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" - vars: - ansible_command_timeout: 3000 - ansible_connect_timeout: 3000 - when: > - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) - -- name: Check Switch Sync in iBGP VXLAN Fabric in Nexus Dashboard - cisco.nac_dc_vxlan.dtc.fabric_check_sync: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - register: results - when: > - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) - -- name: Retrying Config-Save Block for iBGP VXLAN Fabric in Nexus Dashboard - block: - - name: Retrying Config-Save for iBGP VXLAN Fabric in Nexus Dashboard - cisco.dcnm.dcnm_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" - register: config_save - when: - - MD_Extended.vxlan.topology.switches is defined - - MD_Extended.vxlan.topology.switches | length > 0 - - results.changed - - rescue: - - name: Retrying Config-Save for iBGP VXLAN Fabric in Nexus Dashboard - Failed - ansible.builtin.debug: - msg: "{{ config_save.msg.DATA }}" - when: config_save.msg.RETURN_CODE is defined and config_save.msg.RETURN_CODE == 500 - -- name: Retrying Deploy for iBGP VXLAN Fabric in Nexus Dashboard - cisco.dcnm.dcnm_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" +- name: Manage Fabric Deployment for iBGP VXLAN Fabric in Nexus Dashboard + cisco.nac_dc_vxlan.dtc.fabric_deploy_manager: + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + operation: all vars: ansible_command_timeout: 3000 ansible_connect_timeout: 3000 when: - MD_Extended.vxlan.topology.switches is defined - MD_Extended.vxlan.topology.switches | length > 0 - - results.changed - -- name: Check Switch Sync in iBGP VXLAN Fabric - cisco.nac_dc_vxlan.dtc.fabric_check_sync: - fabric: "{{ MD_Extended.vxlan.fabric.name }}" - register: results - when: > - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) - -- name: Capture History Log On Failure for iBGP VXLAN Fabric - cisco.dcnm.dcnm_rest: - method: GET - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/config/delivery/deployerHistoryByFabric/{{ MD_Extended.vxlan.fabric.name }}?sort=completedTime%3ADES&limit=5" - vars: - ansible_command_timeout: 3000 - ansible_connect_timeout: 3000 - when: - - MD_Extended.vxlan.topology.switches is defined - - MD_Extended.vxlan.topology.switches | length > 0 - - results.changed - register: history_log - -- name: Display Last 5 History Log Entries On Failure for iBGP VXLAN Fabric - ansible.builtin.debug: - msg: "{{ history_log.response.DATA | json_query('[0:2]') }}" - when: - - MD_Extended.vxlan.topology.switches is defined - - MD_Extended.vxlan.topology.switches | length > 0 - - results.changed - -- name: Fail On Failure for iBGP VXLAN Fabric - fail: - msg: "Deploy Failure Detected - Please see History Log For Full Details" - when: results.changed From 3323015cfd7374e6953323d3a225075e932b3c7a Mon Sep 17 00:00:00 2001 From: mwiebe Date: Sat, 11 Oct 2025 16:35:49 -0400 Subject: [PATCH 37/65] github actions --- tests/sanity/ignore-2.14.txt | 1 + tests/sanity/ignore-2.15.txt | 1 + tests/sanity/ignore-2.16.txt | 1 + tests/sanity/ignore-2.17.txt | 1 + 4 files changed, 4 insertions(+) diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index 20aa0be4c..2ff904334 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -47,4 +47,5 @@ plugins/action/common/change_flag_manager.py import-3.10!skip plugins/action/dtc/diff_model_changes.py import-3.10!skip plugins/filter/version_compare.py import-3.10!skip plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation +plugins/action/dtc/fabric_deploy_manager.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/common/change_flag_manager.py action-plugin-docs # action plugin has no matching module to provide documentation \ No newline at end of file diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index 20aa0be4c..2ff904334 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -47,4 +47,5 @@ plugins/action/common/change_flag_manager.py import-3.10!skip plugins/action/dtc/diff_model_changes.py import-3.10!skip plugins/filter/version_compare.py import-3.10!skip plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation +plugins/action/dtc/fabric_deploy_manager.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/common/change_flag_manager.py action-plugin-docs # action plugin has no matching module to provide documentation \ No newline at end of file diff --git a/tests/sanity/ignore-2.16.txt b/tests/sanity/ignore-2.16.txt index 20aa0be4c..2ff904334 100644 --- a/tests/sanity/ignore-2.16.txt +++ b/tests/sanity/ignore-2.16.txt @@ -47,4 +47,5 @@ plugins/action/common/change_flag_manager.py import-3.10!skip plugins/action/dtc/diff_model_changes.py import-3.10!skip plugins/filter/version_compare.py import-3.10!skip plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation +plugins/action/dtc/fabric_deploy_manager.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/common/change_flag_manager.py action-plugin-docs # action plugin has no matching module to provide documentation \ No newline at end of file diff --git a/tests/sanity/ignore-2.17.txt b/tests/sanity/ignore-2.17.txt index 20aa0be4c..2ff904334 100644 --- a/tests/sanity/ignore-2.17.txt +++ b/tests/sanity/ignore-2.17.txt @@ -47,4 +47,5 @@ plugins/action/common/change_flag_manager.py import-3.10!skip plugins/action/dtc/diff_model_changes.py import-3.10!skip plugins/filter/version_compare.py import-3.10!skip plugins/action/dtc/diff_compare.py action-plugin-docs # action plugin has no matching module to provide documentation +plugins/action/dtc/fabric_deploy_manager.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/common/change_flag_manager.py action-plugin-docs # action plugin has no matching module to provide documentation \ No newline at end of file From 25d588ef6b9ea315d533b899a6fe6cd479a123cc Mon Sep 17 00:00:00 2001 From: mwiebe Date: Sat, 11 Oct 2025 16:44:47 -0400 Subject: [PATCH 38/65] github actions --- plugins/action/dtc/fabric_deploy_manager.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/action/dtc/fabric_deploy_manager.py b/plugins/action/dtc/fabric_deploy_manager.py index 62cc58f00..f9296e0d7 100644 --- a/plugins/action/dtc/fabric_deploy_manager.py +++ b/plugins/action/dtc/fabric_deploy_manager.py @@ -31,6 +31,7 @@ display = Display() + class FabricDeployManager: """Manages fabric deployment tasks.""" @@ -49,11 +50,12 @@ def __init__(self, params): self.module_name = "cisco.dcnm.dcnm_rest" # Module API Paths + base_path = "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest" self.api_paths = { - "get_switches_by_fabric": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{self.fabric_name}/inventory/switchesByFabric", - "config_save": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{self.fabric_name}/config-save", - "config_deploy": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{self.fabric_name}/config-deploy?forceShowRun=false", - "fabric_history": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/config/delivery/deployerHistoryByFabric/{self.fabric_name}?sort=completedTime%3ADES&limit=5", + "get_switches_by_fabric": f"{base_path}/control/fabrics/{self.fabric_name}/inventory/switchesByFabric", + "config_save": f"{base_path}/control/fabrics/{self.fabric_name}/config-save", + "config_deploy": f"{base_path}/control/fabrics/{self.fabric_name}/config-deploy?forceShowRun=false", + "fabric_history": f"{base_path}/config/delivery/deployerHistoryByFabric/{self.fabric_name}?sort=completedTime%3ADES&limit=5", } # Fabric State Booleans @@ -117,7 +119,6 @@ def fabric_history_get(self): # Get last 2 history entries self.fabric_history = response['response'].get('DATA', [])[0:2] - def _send_request(self, method, path, data=None): """Helper method to send REST API requests.""" @@ -137,6 +138,7 @@ def _send_request(self, method, path, data=None): ) return response + class ActionModule(ActionBase): def run(self, tmp=None, task_vars=None): @@ -171,7 +173,7 @@ def run(self, tmp=None, task_vars=None): fabric_manager.fabric_config_save() fabric_manager.fabric_deploy() fabric_manager.fabric_check_sync() - + if not fabric_manager.fabric_in_sync: # If the fabric is out of sync after deployment try one more time before giving up display.warning("Fabric is out of sync after initial deployment. Attempting one more deployment.") From 58eb931f9b6d6d7929e0d24c5301a486b1091962 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Sat, 11 Oct 2025 17:08:07 -0400 Subject: [PATCH 39/65] Add task back that was removed --- roles/dtc/deploy/tasks/sub_main_msd.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/roles/dtc/deploy/tasks/sub_main_msd.yml b/roles/dtc/deploy/tasks/sub_main_msd.yml index 275cfe01e..c266d6e24 100644 --- a/roles/dtc/deploy/tasks/sub_main_msd.yml +++ b/roles/dtc/deploy/tasks/sub_main_msd.yml @@ -48,6 +48,13 @@ - MD_Extended.vxlan.multisite.child_fabrics | length > 0 # TODO: Update cisco.nac_dc_vxlan.dtc.fabric_deploy_manager to handle a list of child fabrics +- name: Config-Save For MSD Child Fabrics in Nexus Dashboard + cisco.nac_dc_vxlan.dtc.fabrics_config_save: + fabrics: "{{ child_fabrics_vrfs_networks_changed }}" + when: > + MD_Extended.vxlan.fabric.type == 'MSD' and + (child_fabrics_vrfs_networks_changed is defined and child_fabrics_vrfs_networks_changed | length > 0) + - name: Deploy For MSD Child Fabrics in Nexus Dashboard cisco.nac_dc_vxlan.dtc.fabrics_deploy: fabrics: "{{ child_fabrics_vrfs_networks_changed }}" From 61a108ce5ebdb466b59369811ed23954ef9a61cc Mon Sep 17 00:00:00 2001 From: mwiebe Date: Sat, 11 Oct 2025 17:28:05 -0400 Subject: [PATCH 40/65] MSD deploy updates --- plugins/action/dtc/fabric_deploy_manager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/action/dtc/fabric_deploy_manager.py b/plugins/action/dtc/fabric_deploy_manager.py index f9296e0d7..ea0399da6 100644 --- a/plugins/action/dtc/fabric_deploy_manager.py +++ b/plugins/action/dtc/fabric_deploy_manager.py @@ -174,13 +174,13 @@ def run(self, tmp=None, task_vars=None): fabric_manager.fabric_deploy() fabric_manager.fabric_check_sync() - if not fabric_manager.fabric_in_sync: + if not fabric_manager.fabric_in_sync and params['fabric_type'] != 'MSD': # If the fabric is out of sync after deployment try one more time before giving up display.warning("Fabric is out of sync after initial deployment. Attempting one more deployment.") fabric_manager.fabric_config_save() fabric_manager.fabric_deploy() - if not fabric_manager.fabric_in_sync: + if not fabric_manager.fabric_in_sync and params['fabric_type'] != 'MSD': fabric_manager.fabric_history_get() display.error(f"Fabric {fabric_manager.fabric_name} is out of sync after deployment.") display.error(fabric_manager.fabric_history) From c570560abca3843a4eac4982bbe6cfb9d085ad0a Mon Sep 17 00:00:00 2001 From: mwiebe Date: Sat, 11 Oct 2025 18:13:31 -0400 Subject: [PATCH 41/65] Skip unmanagable devices for sync check --- plugins/action/dtc/fabric_deploy_manager.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/action/dtc/fabric_deploy_manager.py b/plugins/action/dtc/fabric_deploy_manager.py index ea0399da6..86e99b9d5 100644 --- a/plugins/action/dtc/fabric_deploy_manager.py +++ b/plugins/action/dtc/fabric_deploy_manager.py @@ -75,7 +75,9 @@ def fabric_check_sync(self): if response['response'].get('DATA'): for switch in response['response']['DATA']: - if switch['ccStatus'] == 'Out-of-Sync': + # Devices that are not managable (example: pre-provisioned devices) should be + # skipped in this check + if str(switch['managable']) == 'True' and switch['ccStatus'] == 'Out-of-Sync': self.fabric_in_sync = False break From 26c19d690b304b3977202d06406624f844e13d7a Mon Sep 17 00:00:00 2001 From: mwiebe Date: Sat, 11 Oct 2025 20:22:29 -0400 Subject: [PATCH 42/65] Loop for in-sync check --- plugins/action/dtc/diff_compare.py | 2 +- plugins/action/dtc/fabric_deploy_manager.py | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/plugins/action/dtc/diff_compare.py b/plugins/action/dtc/diff_compare.py index bf0919ef6..5f20d05f9 100644 --- a/plugins/action/dtc/diff_compare.py +++ b/plugins/action/dtc/diff_compare.py @@ -116,7 +116,7 @@ def write_comparison_results(self, compare_results): output_data = { 'comparison_summary': { 'timestamp': datetime.datetime.now().isoformat(), - 'source_file': self.new_file_path, + # 'source_file': self.new_file_path, 'total_updated': len(compare_results.get('updated', [])), 'total_removed': len(compare_results.get('removed', [])), 'total_equal': len(compare_results.get('equal', [])) diff --git a/plugins/action/dtc/fabric_deploy_manager.py b/plugins/action/dtc/fabric_deploy_manager.py index 86e99b9d5..62302aeb0 100644 --- a/plugins/action/dtc/fabric_deploy_manager.py +++ b/plugins/action/dtc/fabric_deploy_manager.py @@ -27,7 +27,7 @@ from ansible.utils.display import Display from ansible.plugins.action import ActionBase import inspect - +from time import sleep display = Display() @@ -71,8 +71,22 @@ def fabric_check_sync(self): method_name = inspect.stack()[0][3] display.banner(f"{self.class_name}.{method_name}() Fabric: ({self.fabric_name}) Type: ({self.fabric_type})") + self.fabric_in_sync = True response = self._send_request("GET", self.api_paths["get_switches_by_fabric"]) + for _ in range(20): + self._fabric_check_sync_helper(response) + if self.fabric_in_sync: + break + else: + display.warning(f"Fabric {self.fabric_name} is out of sync. Attempt {_ + 1}/20. Sleeping 2 seconds before retry.") + sleep(2) + self.fabric_in_sync = True + response = self._send_request("GET", self.api_paths["get_switches_by_fabric"]) + + + display.banner(f">>>> Fabric: ({self.fabric_name}) Type: ({self.fabric_type}) in sync: {self.fabric_in_sync}") + def _fabric_check_sync_helper(self, response): if response['response'].get('DATA'): for switch in response['response']['DATA']: # Devices that are not managable (example: pre-provisioned devices) should be @@ -81,8 +95,6 @@ def fabric_check_sync(self): self.fabric_in_sync = False break - display.banner(f">>>> Fabric: ({self.fabric_name}) Type: ({self.fabric_type}) in sync: {self.fabric_in_sync}") - def fabric_config_save(self): """Trigger a config-save on the fabric.""" method_name = inspect.stack()[0][3] @@ -178,9 +190,12 @@ def run(self, tmp=None, task_vars=None): if not fabric_manager.fabric_in_sync and params['fabric_type'] != 'MSD': # If the fabric is out of sync after deployment try one more time before giving up + fabric_manager.fabric_history_get() + display.warning(fabric_manager.fabric_history) display.warning("Fabric is out of sync after initial deployment. Attempting one more deployment.") fabric_manager.fabric_config_save() fabric_manager.fabric_deploy() + fabric_manager.fabric_check_sync() if not fabric_manager.fabric_in_sync and params['fabric_type'] != 'MSD': fabric_manager.fabric_history_get() From 1a690f41fa70c1647599ab08fb6f1f77bd4142a5 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Mon, 13 Oct 2025 18:15:57 -0400 Subject: [PATCH 43/65] VRF Fixes --- plugins/action/dtc/diff_compare.py | 39 ++++++++++++++++++- plugins/action/dtc/fabric_deploy_manager.py | 12 +++--- .../tasks/common_vxlan/vrfs_networks.yml | 3 ++ 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/plugins/action/dtc/diff_compare.py b/plugins/action/dtc/diff_compare.py index 5f20d05f9..4c3b94b83 100644 --- a/plugins/action/dtc/diff_compare.py +++ b/plugins/action/dtc/diff_compare.py @@ -81,6 +81,9 @@ def run(self, tmp=None, task_vars=None): except (FileNotFoundError, IOError): display.warning(f"New file not found: {self.new_file_path}, using empty list") + # Normalize omit placeholder strings between old and new items + old_items, new_items = self.normalize_omit_placeholders(old_items, new_items) + updated_items, removed_items, equal_items = self.compare_items(old_items, new_items) if self.new_file_path.endswith('ndfc_interface_all.yml'): @@ -116,7 +119,7 @@ def write_comparison_results(self, compare_results): output_data = { 'comparison_summary': { 'timestamp': datetime.datetime.now().isoformat(), - # 'source_file': self.new_file_path, + 'source_file': self.new_file_path, 'total_updated': len(compare_results.get('updated', [])), 'total_removed': len(compare_results.get('removed', [])), 'total_equal': len(compare_results.get('equal', [])) @@ -143,6 +146,40 @@ def load_yaml(self, filename): with open(filename, 'r', encoding='utf-8') as f: return yaml.safe_load(f) or [] + def normalize_omit_placeholders(self, old_items, new_items): + """ + Remove any lines that contain the string '__omit_place_holder__' from both old_items and new_items. + Goes through each list item and removes any dictionary key-value pairs where the value contains '__omit_place_holder__'. + Returns the cleaned (normalized) old_items and new_items. + """ + def remove_omit_placeholders(items): + """Recursively remove any entries containing '__omit_place_holder__' from data structures.""" + if isinstance(items, list): + cleaned_items = [] + for item in items: + cleaned_item = remove_omit_placeholders(item) + if cleaned_item is not None: # Only add non-None items + cleaned_items.append(cleaned_item) + return cleaned_items + elif isinstance(items, dict): + cleaned_dict = {} + for key, value in items.items(): + # Skip any key-value pair where the value contains '__omit_place_holder__' + if isinstance(value, str) and '__omit_place_holder__' in value: + continue + # Recursively clean nested structures + cleaned_value = remove_omit_placeholders(value) + cleaned_dict[key] = cleaned_value + return cleaned_dict + else: + # For primitive types, return as-is + return items + + cleaned_old = remove_omit_placeholders(old_items) + cleaned_new = remove_omit_placeholders(new_items) + display.v("Normalized old_items and new_items by removing __omit_place_holder__ entries") + return cleaned_old, cleaned_new + KEY_MAPPING = { 'ndfc_underlay_ip_address.yml': 'entity_name', 'ndfc_attach_vrfs.yml': 'vrf_name', diff --git a/plugins/action/dtc/fabric_deploy_manager.py b/plugins/action/dtc/fabric_deploy_manager.py index 62302aeb0..cd58df0b1 100644 --- a/plugins/action/dtc/fabric_deploy_manager.py +++ b/plugins/action/dtc/fabric_deploy_manager.py @@ -73,12 +73,12 @@ def fabric_check_sync(self): self.fabric_in_sync = True response = self._send_request("GET", self.api_paths["get_switches_by_fabric"]) - for _ in range(20): + for attempt in range(20): self._fabric_check_sync_helper(response) if self.fabric_in_sync: break else: - display.warning(f"Fabric {self.fabric_name} is out of sync. Attempt {_ + 1}/20. Sleeping 2 seconds before retry.") + display.warning(f"Fabric {self.fabric_name} is out of sync. Attempt {attempt + 1}/20. Sleeping 2 seconds before retry.") sleep(2) self.fabric_in_sync = True response = self._send_request("GET", self.api_paths["get_switches_by_fabric"]) @@ -199,8 +199,8 @@ def run(self, tmp=None, task_vars=None): if not fabric_manager.fabric_in_sync and params['fabric_type'] != 'MSD': fabric_manager.fabric_history_get() - display.error(f"Fabric {fabric_manager.fabric_name} is out of sync after deployment.") - display.error(fabric_manager.fabric_history) + results['msg'] = f"Fabric {fabric_manager.fabric_name} is out of sync after deployment." + results['fabric_history'] = fabric_manager.fabric_history results['failed'] = True if params['operation'] in ['config_save']: @@ -217,8 +217,8 @@ def run(self, tmp=None, task_vars=None): fabric_manager.fabric_check_sync() if not fabric_manager.fabric_in_sync: fabric_manager.fabric_history_get() - display.error(f"Fabric {fabric_manager.fabric_name} is out of sync.") - display.error(fabric_manager.fabric_history) + results['msg'] = f"Fabric {fabric_manager.fabric_name} is out of sync." + results['fabric_history'] = fabric_manager.fabric_history results['failed'] = True return results diff --git a/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml b/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml index cc8614618..9b4e335f2 100644 --- a/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml +++ b/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml @@ -86,6 +86,7 @@ - MD_Extended.vxlan.overlay.vrfs is defined - MD_Extended.vxlan.overlay.vrfs - change_flags.changes_detected_vrfs + - vrf_config_list | length > 0 - not is_active_child_fabric # -------------------------------------------------------------------- @@ -102,6 +103,7 @@ - change_flags.changes_detected_vrfs - not is_active_child_fabric + # -------------------------------------------------------------------- # Manage Network Configuration in Nexus Dashboard # -------------------------------------------------------------------- @@ -132,4 +134,5 @@ - MD_Extended.vxlan.overlay.networks is defined - MD_Extended.vxlan.overlay.networks - change_flags.changes_detected_networks + - network_config_list | length > 0 - not is_active_child_fabric From cee39a1266cc8c0b605a909dde0e01ce99617a8f Mon Sep 17 00:00:00 2001 From: mwiebe Date: Mon, 13 Oct 2025 18:20:21 -0400 Subject: [PATCH 44/65] Actions fixes --- plugins/action/dtc/fabric_deploy_manager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/action/dtc/fabric_deploy_manager.py b/plugins/action/dtc/fabric_deploy_manager.py index cd58df0b1..b510d6e9a 100644 --- a/plugins/action/dtc/fabric_deploy_manager.py +++ b/plugins/action/dtc/fabric_deploy_manager.py @@ -83,7 +83,6 @@ def fabric_check_sync(self): self.fabric_in_sync = True response = self._send_request("GET", self.api_paths["get_switches_by_fabric"]) - display.banner(f">>>> Fabric: ({self.fabric_name}) Type: ({self.fabric_type}) in sync: {self.fabric_in_sync}") def _fabric_check_sync_helper(self, response): From d9215591c24a6cc6f2438c6d4a7b9f264a8d0126 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Mon, 13 Oct 2025 21:05:26 -0400 Subject: [PATCH 45/65] Fix fabric check sync --- plugins/action/dtc/fabric_deploy_manager.py | 23 +++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/plugins/action/dtc/fabric_deploy_manager.py b/plugins/action/dtc/fabric_deploy_manager.py index b510d6e9a..a01a4048b 100644 --- a/plugins/action/dtc/fabric_deploy_manager.py +++ b/plugins/action/dtc/fabric_deploy_manager.py @@ -73,12 +73,14 @@ def fabric_check_sync(self): self.fabric_in_sync = True response = self._send_request("GET", self.api_paths["get_switches_by_fabric"]) - for attempt in range(20): + for attempt in range(5): self._fabric_check_sync_helper(response) if self.fabric_in_sync: break + if (attempt + 1) == 5 and not self.fabric_in_sync: + break else: - display.warning(f"Fabric {self.fabric_name} is out of sync. Attempt {attempt + 1}/20. Sleeping 2 seconds before retry.") + display.warning(f"Fabric {self.fabric_name} is out of sync. Attempt {attempt + 1}/5. Sleeping 2 seconds before retry.") sleep(2) self.fabric_in_sync = True response = self._send_request("GET", self.api_paths["get_switches_by_fabric"]) @@ -86,8 +88,8 @@ def fabric_check_sync(self): display.banner(f">>>> Fabric: ({self.fabric_name}) Type: ({self.fabric_type}) in sync: {self.fabric_in_sync}") def _fabric_check_sync_helper(self, response): - if response['response'].get('DATA'): - for switch in response['response']['DATA']: + if response.get('DATA'): + for switch in response['DATA']: # Devices that are not managable (example: pre-provisioned devices) should be # skipped in this check if str(switch['managable']) == 'True' and switch['ccStatus'] == 'Out-of-Sync': @@ -100,8 +102,7 @@ def fabric_config_save(self): display.banner(f"{self.class_name}.{method_name}() Fabric: ({self.fabric_name}) Type: ({self.fabric_type})") response = self._send_request("POST", self.api_paths["config_save"]) - - if response['response'].get('RETURN_CODE') == 200: + if response.get('RETURN_CODE') == 200: display.banner(f">>>> Succeeded for Fabric {self.fabric_name}") else: self.fabric_save_succeeded = False @@ -113,7 +114,7 @@ def fabric_deploy(self): display.banner(f"{self.class_name}.{method_name}() Fabric: ({self.fabric_name}) Type: ({self.fabric_type})") response = self._send_request("POST", self.api_paths["config_deploy"]) - if response['response'].get('RETURN_CODE') == 200: + if response.get('RETURN_CODE') == 200: display.banner(f">>>> Succeeded for Fabric {self.fabric_name}") else: self.fabric_deploy_succeeded = False @@ -125,13 +126,13 @@ def fabric_history_get(self): display.banner(f"{self.class_name}.{method_name}() Fabric: ({self.fabric_name}) Type: ({self.fabric_type})") response = self._send_request("GET", self.api_paths["fabric_history"]) - if response['response'].get('RETURN_CODE') == 200: + if response.get('RETURN_CODE') == 200: display.banner(f">>>> Succeeded for Fabric {self.fabric_name}") else: display.warning(f">>>> Failed for Fabric {self.fabric_name}: {response}") # Get last 2 history entries - self.fabric_history = response['response'].get('DATA', [])[0:2] + self.fabric_history = response.get('DATA', [])[0:2] def _send_request(self, method, path, data=None): """Helper method to send REST API requests.""" @@ -149,6 +150,10 @@ def _send_request(self, method, path, data=None): task_vars=self.task_vars, tmp=self.tmp ) + if 'response' in response.keys(): + response = response['response'] + if 'msg' in response.keys(): + response = response['msg'] return response From 396ea7bf3f877b68caa202a5aec25a328ad40e97 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Tue, 14 Oct 2025 11:01:02 -0400 Subject: [PATCH 46/65] add missing change flag for ebgp --- plugins/action/common/change_flag_manager.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/action/common/change_flag_manager.py b/plugins/action/common/change_flag_manager.py index 50cb8d01b..f01c6be2d 100644 --- a/plugins/action/common/change_flag_manager.py +++ b/plugins/action/common/change_flag_manager.py @@ -151,6 +151,7 @@ def initialize_flags(self): 'changes_detected_policy': False, 'changes_detected_sub_interface_routed': False, 'changes_detected_vpc_peering': False, + 'changes_detected_vpc_domain_id_resource': False, 'changes_detected_vrfs': False, 'changes_detected_any': False } From f939b30bad4401609ae3c9485b010a73601ccf87 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Tue, 14 Oct 2025 13:43:18 -0400 Subject: [PATCH 47/65] Diff run create for MSD VRFs and Networks --- roles/dtc/common/tasks/msd/ndfc_networks.yml | 9 +++++++++ roles/dtc/common/tasks/msd/ndfc_vrfs.yml | 9 +++++++++ roles/dtc/create/tasks/msd/vrfs_networks.yml | 16 ++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/roles/dtc/common/tasks/msd/ndfc_networks.yml b/roles/dtc/common/tasks/msd/ndfc_networks.yml index d482dbac5..ea9011489 100644 --- a/roles/dtc/common/tasks/msd/ndfc_networks.yml +++ b/roles/dtc/common/tasks/msd/ndfc_networks.yml @@ -64,6 +64,15 @@ when: (MD_Extended.vxlan.multisite.overlay.networks | default([])) | length > 0 delegate_to: localhost +- name: Build Network Diff Between Previous and Current Run + # This task must be run before the next task because + # dtc.diff_model_changes deletes the .old file if it exists + cisco.nac_dc_vxlan.dtc.diff_compare: + old_file: "{{ path_name }}{{ file_name }}.old" + new_file: "{{ path_name }}{{ file_name }}" + register: network_diff_result + delegate_to: localhost + - name: Diff Previous and Current Data Files cisco.nac_dc_vxlan.dtc.diff_model_changes: file_name_previous: "{{ path_name }}{{ file_name }}.old" diff --git a/roles/dtc/common/tasks/msd/ndfc_vrfs.yml b/roles/dtc/common/tasks/msd/ndfc_vrfs.yml index 2989894d9..22ea02f3e 100644 --- a/roles/dtc/common/tasks/msd/ndfc_vrfs.yml +++ b/roles/dtc/common/tasks/msd/ndfc_vrfs.yml @@ -64,6 +64,15 @@ when: (MD_Extended.vxlan.multisite.overlay.vrfs | default([])) | length > 0 delegate_to: localhost +- name: Build VRFs Diff Between Previous and Current Run + # This task must be run before the next task because + # dtc.diff_model_changes deletes the .old file if it exists + cisco.nac_dc_vxlan.dtc.diff_compare: + old_file: "{{ path_name }}{{ file_name }}.old" + new_file: "{{ path_name }}{{ file_name }}" + register: vrf_diff_result + delegate_to: localhost + - name: Diff Previous and Current Data Files cisco.nac_dc_vxlan.dtc.diff_model_changes: file_name_previous: "{{ path_name }}{{ file_name }}.old" diff --git a/roles/dtc/create/tasks/msd/vrfs_networks.yml b/roles/dtc/create/tasks/msd/vrfs_networks.yml index 92c2cc02b..90067a385 100644 --- a/roles/dtc/create/tasks/msd/vrfs_networks.yml +++ b/roles/dtc/create/tasks/msd/vrfs_networks.yml @@ -91,6 +91,22 @@ operation: display delegate_to: localhost +- name: Override Networks List Based On Diff Run Settings + set_fact: + net_config: "{{ network_diff_result.updated }}" + when: + - run_map_read_result.diff_run is true|bool + - (change_flags_multisite.changes_detected_networks is defined and change_flags_multisite.changes_detected_networks) + - (network_diff_result is defined and network_diff_result.updated | length > 0) + +- name: Override Networks List Based On Diff Run Settings + set_fact: + vrf_config: "{{ vrf_diff_result.updated }}" + when: + - run_map_read_result.diff_run is true|bool + - (change_flags_multisite.changes_detected_vrfs is defined and change_flags_multisite.changes_detected_vrfs) + - (vrf_diff_result is defined and vrf_diff_result.updated | length > 0) + # ---------------------------------------------------------------------------------- # Likewise, the vrf_config and net_config data is created when the tasks above # are imported so we need to update and store them in vars_common_msd From e800f7ab6ba7a2389c48a6146a5e5a66dbe7d572 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Tue, 14 Oct 2025 13:53:33 -0400 Subject: [PATCH 48/65] Add missing ebgp vrf_diff_result --- roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml b/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml index 6aa799918..3261393a9 100644 --- a/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml +++ b/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml @@ -246,3 +246,4 @@ network_diff_result: "{{ network_diff_result }}" vpc_peering_diff_result: "{{ vpc_peering_diff_result }}" vpc_domain_id_resource_diff_result: "{{ vpc_domain_id_resource_diff_result }}" + vrf_diff_result: "{{ vrf_diff_result }}" From a2428e8a92f6af5fffdf7068382e89472c9a5152 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Tue, 14 Oct 2025 13:56:11 -0400 Subject: [PATCH 49/65] Normalize diff_result data for all fabrics --- roles/dtc/common/tasks/sub_main_external.yml | 3 ++- roles/dtc/common/tasks/sub_main_isn.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/roles/dtc/common/tasks/sub_main_external.yml b/roles/dtc/common/tasks/sub_main_external.yml index b3bc10dcf..24fa53654 100644 --- a/roles/dtc/common/tasks/sub_main_external.yml +++ b/roles/dtc/common/tasks/sub_main_external.yml @@ -185,7 +185,6 @@ interface_access: "{{ interface_access }}" interface_all_create: "{{ interface_all_create }}" interface_all_remove_overridden: "{{ interface_all_remove_overridden }}" - interface_diff_result: "{{ interface_diff_result }}" int_loopback_config: "{{ int_loopback_config }}" interface_po_routed: "{{ interface_po_routed }}" interface_routed: "{{ interface_routed }}" @@ -199,4 +198,6 @@ updated_inv_config: "{{ updated_inv_config }}" updated_inv_config_no_bootstrap: "{{ updated_inv_config_no_bootstrap }}" vpc_peering: "{{ vpc_peering }}" + # Diff Result Data + interface_diff_result: "{{ interface_diff_result }}" vpc_peering_diff_result: "{{ vpc_peering_diff_result }}" diff --git a/roles/dtc/common/tasks/sub_main_isn.yml b/roles/dtc/common/tasks/sub_main_isn.yml index 571f2dd5c..0e58389de 100644 --- a/roles/dtc/common/tasks/sub_main_isn.yml +++ b/roles/dtc/common/tasks/sub_main_isn.yml @@ -177,7 +177,6 @@ interface_access: "{{ interface_access }}" interface_all_create: "{{ interface_all_create }}" interface_all_remove_overridden: "{{ interface_all_remove_overridden }}" - interface_diff_result: "{{ interface_diff_result }}" int_loopback_config: "{{ int_loopback_config }}" interface_po_routed: "{{ interface_po_routed }}" interface_routed: "{{ interface_routed }}" @@ -191,3 +190,5 @@ sub_interface_routed: "{{ sub_interface_routed }}" updated_inv_config: "{{ updated_inv_config }}" updated_inv_config_no_bootstrap: "{{ updated_inv_config_no_bootstrap }}" + # Diff Result Data + interface_diff_result: "{{ interface_diff_result }}" From 7341485f2ff590396a719f53501e35677ca2a930 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Tue, 14 Oct 2025 14:51:06 -0400 Subject: [PATCH 50/65] Debug task removal --- roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml | 8 -------- roles/dtc/create/tasks/sub_main_external.yml | 8 -------- roles/dtc/create/tasks/sub_main_isn.yml | 8 -------- roles/dtc/create/tasks/sub_main_msd.yml | 8 -------- roles/dtc/create/tasks/sub_main_vxlan.yml | 8 -------- roles/dtc/deploy/tasks/sub_main_ebgp_vxlan.yml | 7 ------- roles/dtc/deploy/tasks/sub_main_external.yml | 7 ------- roles/dtc/deploy/tasks/sub_main_isn.yml | 7 ------- roles/dtc/deploy/tasks/sub_main_msd.yml | 7 ------- roles/dtc/deploy/tasks/sub_main_vxlan.yml | 7 ------- roles/dtc/remove/tasks/sub_main_ebgp_vxlan.yml | 8 -------- roles/dtc/remove/tasks/sub_main_external.yml | 8 -------- roles/dtc/remove/tasks/sub_main_isn.yml | 8 -------- roles/dtc/remove/tasks/sub_main_msd.yml | 8 -------- roles/dtc/remove/tasks/sub_main_vxlan.yml | 8 -------- 15 files changed, 115 deletions(-) diff --git a/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml b/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml index d6b88b425..a0f1fa613 100644 --- a/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml +++ b/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml @@ -29,14 +29,6 @@ - "----------------------------------------------------------------" tags: "{{ nac_tags.create }}" # Tags defined in roles/common_global/vars/main.yml -- name: VXLAN EBGP FABRIC - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ VXLAN EBGP FABRIC +" - - "----------------------------------------------------------------" - tags: "{{ nac_tags.create }}" # Tags defined in roles/common_global/vars/main.yml - - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using Nexus Dashboard (Direct to Controller)" diff --git a/roles/dtc/create/tasks/sub_main_external.yml b/roles/dtc/create/tasks/sub_main_external.yml index e19043059..d223e4678 100644 --- a/roles/dtc/create/tasks/sub_main_external.yml +++ b/roles/dtc/create/tasks/sub_main_external.yml @@ -29,14 +29,6 @@ - "----------------------------------------------------------------" tags: "{{ nac_tags.create }}" # Tags defined in roles/common_global/vars/main.yml -- name: EXTERNAL FABRIC - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ EXTERNAL FABRIC +" - - "----------------------------------------------------------------" - tags: "{{ nac_tags.create }}" # Tags defined in roles/common_global/vars/main.yml - - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using Nexus Dashboard (Direct to Controller)" diff --git a/roles/dtc/create/tasks/sub_main_isn.yml b/roles/dtc/create/tasks/sub_main_isn.yml index 532540093..24ae6af25 100644 --- a/roles/dtc/create/tasks/sub_main_isn.yml +++ b/roles/dtc/create/tasks/sub_main_isn.yml @@ -29,14 +29,6 @@ - "----------------------------------------------------------------" tags: "{{ nac_tags.create }}" # Tags defined in roles/common_global/vars/main.yml -- name: ISN FABRIC - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ ISN FABRIC +" - - "----------------------------------------------------------------" - tags: "{{ nac_tags.create }}" # Tags defined in roles/common_global/vars/main.yml - - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using Nexus Dashboard (Direct to Controller)" diff --git a/roles/dtc/create/tasks/sub_main_msd.yml b/roles/dtc/create/tasks/sub_main_msd.yml index 101670586..6515ceecf 100644 --- a/roles/dtc/create/tasks/sub_main_msd.yml +++ b/roles/dtc/create/tasks/sub_main_msd.yml @@ -29,14 +29,6 @@ - "----------------------------------------------------------------" tags: "{{ nac_tags.create }}" # Tags defined in roles/common_global/vars/main.yml -- name: VXLAN MSD FABRIC - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ VXLAN MSD FABRIC +" - - "----------------------------------------------------------------" - tags: "{{ nac_tags.create }}" # Tags defined in roles/common_global/vars/main.yml - - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using Nexus Dashboard (Direct to Controller)" diff --git a/roles/dtc/create/tasks/sub_main_vxlan.yml b/roles/dtc/create/tasks/sub_main_vxlan.yml index d13f1eae4..a604a0a16 100644 --- a/roles/dtc/create/tasks/sub_main_vxlan.yml +++ b/roles/dtc/create/tasks/sub_main_vxlan.yml @@ -29,14 +29,6 @@ - "----------------------------------------------------------------" tags: "{{ nac_tags.create }}" # Tags defined in roles/common_global/vars/main.yml -- name: VXLAN IBGP FABRIC - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ VXLAN IBGP FABRIC +" - - "----------------------------------------------------------------" - tags: "{{ nac_tags.create }}" # Tags defined in roles/common_global/vars/main.yml - - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using Nexus Dashboard (Direct to Controller)" diff --git a/roles/dtc/deploy/tasks/sub_main_ebgp_vxlan.yml b/roles/dtc/deploy/tasks/sub_main_ebgp_vxlan.yml index 9833d2717..fbd70dd2f 100644 --- a/roles/dtc/deploy/tasks/sub_main_ebgp_vxlan.yml +++ b/roles/dtc/deploy/tasks/sub_main_ebgp_vxlan.yml @@ -28,13 +28,6 @@ - "+ Calling Role - [cisco.nac_dc_vxlan.dtc.deploy] +" - "----------------------------------------------------------------" -- name: VXLAN EBGP FABRIC - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ VXLAN EBGP FABRIC +" - - "----------------------------------------------------------------" - - name: Manage Fabric Deployment for eBGP VXLAN Fabric in Nexus Dashboard cisco.nac_dc_vxlan.dtc.fabric_deploy_manager: fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" diff --git a/roles/dtc/deploy/tasks/sub_main_external.yml b/roles/dtc/deploy/tasks/sub_main_external.yml index 8da778712..102d900bc 100644 --- a/roles/dtc/deploy/tasks/sub_main_external.yml +++ b/roles/dtc/deploy/tasks/sub_main_external.yml @@ -28,13 +28,6 @@ - "+ Calling Role - [cisco.nac_dc_vxlan.dtc.deploy] +" - "----------------------------------------------------------------" -- name: External FABRIC - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ External FABRIC +" - - "----------------------------------------------------------------" - - name: Manage Fabric Deployment for External Fabric in Nexus Dashboard cisco.nac_dc_vxlan.dtc.fabric_deploy_manager: fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" diff --git a/roles/dtc/deploy/tasks/sub_main_isn.yml b/roles/dtc/deploy/tasks/sub_main_isn.yml index 808155f14..b8fac9f78 100644 --- a/roles/dtc/deploy/tasks/sub_main_isn.yml +++ b/roles/dtc/deploy/tasks/sub_main_isn.yml @@ -28,13 +28,6 @@ - "+ Calling Role - [cisco.nac_dc_vxlan.dtc.deploy] +" - "----------------------------------------------------------------" -- name: ISN FABRIC - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ ISN FABRIC +" - - "----------------------------------------------------------------" - - name: Manage Fabric Deployment for ISN Fabric in Nexus Dashboard cisco.nac_dc_vxlan.dtc.fabric_deploy_manager: fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" diff --git a/roles/dtc/deploy/tasks/sub_main_msd.yml b/roles/dtc/deploy/tasks/sub_main_msd.yml index c266d6e24..67aa37e42 100644 --- a/roles/dtc/deploy/tasks/sub_main_msd.yml +++ b/roles/dtc/deploy/tasks/sub_main_msd.yml @@ -28,13 +28,6 @@ - "+ Calling Role - [cisco.nac_dc_vxlan.dtc.deploy] +" - "----------------------------------------------------------------" -- name: MSD FABRIC - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ MSD FABRIC +" - - "----------------------------------------------------------------" - - name: Manage Fabric Deployment for MSD Fabric in Nexus Dashboard cisco.nac_dc_vxlan.dtc.fabric_deploy_manager: fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" diff --git a/roles/dtc/deploy/tasks/sub_main_vxlan.yml b/roles/dtc/deploy/tasks/sub_main_vxlan.yml index 32a3915e7..a84f303d4 100644 --- a/roles/dtc/deploy/tasks/sub_main_vxlan.yml +++ b/roles/dtc/deploy/tasks/sub_main_vxlan.yml @@ -28,13 +28,6 @@ - "+ Calling Role - [cisco.nac_dc_vxlan.dtc.deploy] +" - "----------------------------------------------------------------" -- name: VXLAN IBGP FABRIC - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ VXLAN IBGP FABRIC +" - - "----------------------------------------------------------------" - - name: Manage Fabric Deployment for iBGP VXLAN Fabric in Nexus Dashboard cisco.nac_dc_vxlan.dtc.fabric_deploy_manager: fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" diff --git a/roles/dtc/remove/tasks/sub_main_ebgp_vxlan.yml b/roles/dtc/remove/tasks/sub_main_ebgp_vxlan.yml index e35e015f5..ef0088fb4 100644 --- a/roles/dtc/remove/tasks/sub_main_ebgp_vxlan.yml +++ b/roles/dtc/remove/tasks/sub_main_ebgp_vxlan.yml @@ -28,14 +28,6 @@ - "----------------------------------------------------------------" tags: "{{ nac_tags.remove }}" # Tags defined in roles/common_global/vars/main.yml -- name: VXLAN EBGP FABRIC - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ VXLAN EBGP FABRIC +" - - "----------------------------------------------------------------" - tags: "{{ nac_tags.remove }}" # Tags defined in roles/common_global/vars/main.yml - - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using Nexus Dashboard (Direct to Controller)" diff --git a/roles/dtc/remove/tasks/sub_main_external.yml b/roles/dtc/remove/tasks/sub_main_external.yml index 282ef4577..a6c7f903a 100644 --- a/roles/dtc/remove/tasks/sub_main_external.yml +++ b/roles/dtc/remove/tasks/sub_main_external.yml @@ -28,14 +28,6 @@ - "----------------------------------------------------------------" tags: "{{ nac_tags.remove }}" # Tags defined in roles/common_global/vars/main.yml -- name: External FABRIC - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ External FABRIC +" - - "----------------------------------------------------------------" - tags: "{{ nac_tags.remove }}" # Tags defined in roles/common_global/vars/main.yml - - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using Nexus Dashboard (Direct to Controller)" diff --git a/roles/dtc/remove/tasks/sub_main_isn.yml b/roles/dtc/remove/tasks/sub_main_isn.yml index b88f3a22c..8f70c2a3b 100644 --- a/roles/dtc/remove/tasks/sub_main_isn.yml +++ b/roles/dtc/remove/tasks/sub_main_isn.yml @@ -28,14 +28,6 @@ - "----------------------------------------------------------------" tags: "{{ nac_tags.remove }}" # Tags defined in roles/common_global/vars/main.yml -- name: ISN FABRIC - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ ISN FABRIC +" - - "----------------------------------------------------------------" - tags: "{{ nac_tags.remove }}" # Tags defined in roles/common_global/vars/main.yml - - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using Nexus Dashboard (Direct to Controller)" diff --git a/roles/dtc/remove/tasks/sub_main_msd.yml b/roles/dtc/remove/tasks/sub_main_msd.yml index 141edc74e..1d23a3bc1 100644 --- a/roles/dtc/remove/tasks/sub_main_msd.yml +++ b/roles/dtc/remove/tasks/sub_main_msd.yml @@ -28,14 +28,6 @@ - "----------------------------------------------------------------" tags: "{{ nac_tags.remove }}" # Tags defined in roles/common_global/vars/main.yml -- name: MSD FABRIC - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ MSD FABRIC +" - - "----------------------------------------------------------------" - tags: "{{ nac_tags.remove }}" # Tags defined in roles/common_global/vars/main.yml - - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using Nexus Dashboard (Direct to Controller)" diff --git a/roles/dtc/remove/tasks/sub_main_vxlan.yml b/roles/dtc/remove/tasks/sub_main_vxlan.yml index 77afa535b..de6ab058f 100644 --- a/roles/dtc/remove/tasks/sub_main_vxlan.yml +++ b/roles/dtc/remove/tasks/sub_main_vxlan.yml @@ -28,14 +28,6 @@ - "----------------------------------------------------------------" tags: "{{ nac_tags.remove }}" # Tags defined in roles/common_global/vars/main.yml -- name: VXLAN IBGP FABRIC - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ VXLAN IBGP FABRIC +" - - "----------------------------------------------------------------" - tags: "{{ nac_tags.remove }}" # Tags defined in roles/common_global/vars/main.yml - - name: Display Device Configuration Method ansible.builtin.debug: msg: "Configuring NXOS Devices using Nexus Dashboard (Direct to Controller)" From 5017195a26c792379cb16c1bb697734c44fe4ce1 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Tue, 14 Oct 2025 15:06:39 -0400 Subject: [PATCH 51/65] Additional debug command cleanup --- roles/dtc/remove/tasks/common/interfaces.yml | 7 ------- roles/dtc/remove/tasks/common/vpc_peers.yml | 7 ------- roles/dtc/remove/tasks/main.yml | 5 ----- roles/validate/tasks/cleanup_model_files.yml | 2 -- roles/validate/tasks/manage_model_files_current.yml | 2 -- 5 files changed, 23 deletions(-) diff --git a/roles/dtc/remove/tasks/common/interfaces.yml b/roles/dtc/remove/tasks/common/interfaces.yml index b5d9795be..ddac8e54d 100644 --- a/roles/dtc/remove/tasks/common/interfaces.yml +++ b/roles/dtc/remove/tasks/common/interfaces.yml @@ -52,13 +52,6 @@ - switch_list.response.DATA | length > 0 - (interface_delete_mode is defined) and (interface_delete_mode is true|bool) -- name: Diff Run Feature Status - ansible.builtin.debug: - msg: - - "-------------------------------------------------------------------------" - - "+ Diff Run Feature Status: {{ run_map_read_result.diff_run }}" - - "-------------------------------------------------------------------------" - # ----------------------------------------------------------------------------- # Remove Interfaces Using Diff Run Framework # ----------------------------------------------------------------------------- diff --git a/roles/dtc/remove/tasks/common/vpc_peers.yml b/roles/dtc/remove/tasks/common/vpc_peers.yml index 89634e319..4f26d63cc 100644 --- a/roles/dtc/remove/tasks/common/vpc_peers.yml +++ b/roles/dtc/remove/tasks/common/vpc_peers.yml @@ -82,13 +82,6 @@ - (vpc_delete_mode is defined) and (vpc_delete_mode is true|bool) - run_map_read_result.diff_run is false|bool or force_run_all is true|bool -- debug: msg="Config {{ vars_common_local.vpc_peering }}" -- debug: msg="{{ vars_common_local.vpc_peering | length }}" - -- debug: msg="INT DEL MODE {{ interface_delete_mode }}" -- debug: msg="DIFF RUN {{ run_map_read_result.diff_run }}" -- debug: msg="FORCE RUN ALL {{ force_run_all }}" - - name: Skip Remove Unmanaged vPC Peering Task If vpc_delete_mode is False ansible.builtin.debug: msg: diff --git a/roles/dtc/remove/tasks/main.yml b/roles/dtc/remove/tasks/main.yml index 6148d63e3..db39ca2f0 100644 --- a/roles/dtc/remove/tasks/main.yml +++ b/roles/dtc/remove/tasks/main.yml @@ -56,11 +56,6 @@ - MD_Extended.vxlan.fabric.type == 'eBGP_VXLAN' - change_flags.changes_detected_any -- name: Log Stage Remove Without Deploy Setting - ansible.builtin.debug: - msg: - - "Stage Remove Without Deploy Is {{ stage_remove }}" - - name: Deploy Remove Changes ansible.builtin.include_role: name: cisco.nac_dc_vxlan.dtc.deploy diff --git a/roles/validate/tasks/cleanup_model_files.yml b/roles/validate/tasks/cleanup_model_files.yml index 609787fd9..cf4e80358 100644 --- a/roles/validate/tasks/cleanup_model_files.yml +++ b/roles/validate/tasks/cleanup_model_files.yml @@ -21,8 +21,6 @@ --- -- debug: msg="{{ MD_Extended.vxlan.fabric.name }}_service_model*.json" - - name: Remove Service Model JSON Files ansible.builtin.find: paths: "{{ role_path }}/files/" diff --git a/roles/validate/tasks/manage_model_files_current.yml b/roles/validate/tasks/manage_model_files_current.yml index 7d5aa847f..4c152fee9 100644 --- a/roles/validate/tasks/manage_model_files_current.yml +++ b/roles/validate/tasks/manage_model_files_current.yml @@ -73,8 +73,6 @@ when: run_map_read_result.validate_only_run is true|bool delegate_to: localhost -- debug: msg="{{ run_map_read_result}}" - - name: No Model Changes Detected ansible.builtin.meta: end_play when: From b4e45459432a0e71b1ee9977ed2e52894ac5d283 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Tue, 14 Oct 2025 18:18:54 -0400 Subject: [PATCH 52/65] Remove deploy based on changes_detected --- roles/dtc/remove/tasks/main.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/roles/dtc/remove/tasks/main.yml b/roles/dtc/remove/tasks/main.yml index db39ca2f0..0c80c9fcc 100644 --- a/roles/dtc/remove/tasks/main.yml +++ b/roles/dtc/remove/tasks/main.yml @@ -59,9 +59,12 @@ - name: Deploy Remove Changes ansible.builtin.include_role: name: cisco.nac_dc_vxlan.dtc.deploy - when: - - stage_remove is false|bool - - not MD_Extended.vxlan.fabric.type == 'MSD' + when: > + ((stage_remove is false|bool) and (not MD_Extended.vxlan.fabric.type == 'MSD')) and + (change_flags.changes_detected_interfaces) or + (change_flags.changes_detected_policy) or + (change_flags.changes_detected_vpc_peering) or + (change_flags.changes_detected_vpc_domain_id_resource) - name: Mark Stage Role Remove Completed cisco.nac_dc_vxlan.common.run_map: From de45c44ff6532d48458fd4c2a4c30785e5508d21 Mon Sep 17 00:00:00 2001 From: Matt Tarkington Date: Tue, 14 Oct 2025 20:28:06 -0400 Subject: [PATCH 53/65] initial work on msd diff --- .../dtc/unmanaged_child_fabric_networks.py | 2 +- .../action/dtc/unmanaged_child_fabric_vrfs.py | 119 +++++++++++------- roles/dtc/remove/tasks/msd/vrfs.yml | 19 ++- 3 files changed, 95 insertions(+), 45 deletions(-) diff --git a/plugins/action/dtc/unmanaged_child_fabric_networks.py b/plugins/action/dtc/unmanaged_child_fabric_networks.py index e1460b3af..175274870 100644 --- a/plugins/action/dtc/unmanaged_child_fabric_networks.py +++ b/plugins/action/dtc/unmanaged_child_fabric_networks.py @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates +# Copyright (c) 2025 Cisco Systems, Inc. and its affiliates # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in diff --git a/plugins/action/dtc/unmanaged_child_fabric_vrfs.py b/plugins/action/dtc/unmanaged_child_fabric_vrfs.py index 49f720bf1..0ccb125a1 100644 --- a/plugins/action/dtc/unmanaged_child_fabric_vrfs.py +++ b/plugins/action/dtc/unmanaged_child_fabric_vrfs.py @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates +# Copyright (c) 2025 Cisco Systems, Inc. and its affiliates # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in @@ -32,26 +32,27 @@ class ActionModule(ActionBase): - - def run(self, tmp=None, task_vars=None): - results = super(ActionModule, self).run(tmp, task_vars) - results['changed'] = False - results['failed'] = False - - fabric = self._task.args["fabric"] - msite_data = self._task.args["msite_data"] - - vrfs = msite_data['overlay_attach_groups']['vrfs'] - vrf_names = [vrf['name'] for vrf in vrfs] - - ndfc_vrfs = self._execute_module( + """ + Action plugin to determine what VRFs are to be removed from Nexus Dashboard (ND) + through comparison with the desired state in data model to ND state or through + the diff run framework option. + """ + def __init__(self, *args, **kwargs): + super(ActionModule, self).__init__(*args, **kwargs) + self.tmp = None + self.task_vars = None + self.nd_vrfs = {} + self.results = {} + + def get_nd_vrfs(self, fabric): + self.nd_vrfs = self._execute_module( module_name="cisco.dcnm.dcnm_vrf", module_args={ "fabric": fabric, "state": "query" }, - task_vars=task_vars, - tmp=tmp + task_vars=self.task_vars, + tmp=self.tmp ) # Failed query: @@ -67,11 +68,11 @@ def run(self, tmp=None, task_vars=None): # }, # "_ansible_parsed": true # } - if ndfc_vrfs.get('failed'): - if ndfc_vrfs['failed']: - results['failed'] = True - results['msg'] = f"{ndfc_vrfs['msg']}" - return results + if self.nd_vrfs.get('failed'): + if self.nd_vrfs['failed']: + self.results['failed'] = True + self.results['msg'] = f"{self.nd_vrfs['msg']}" + return self.results # Successful query: # { @@ -146,9 +147,16 @@ def run(self, tmp=None, task_vars=None): # }, # "_ansible_parsed": true # } + + def dm_nd_diff(self, fabric, data): + vrfs = data['overlay_attach_groups']['vrfs'] + vrf_names = [vrf['name'] for vrf in vrfs] + diff_ndfc_vrf_names = [] - if ndfc_vrfs.get('response'): - ndfc_vrf_names = [ndfc_vrf['parent']['vrfName'] for ndfc_vrf in ndfc_vrfs['response']] + config = [] + + if self.nd_vrfs.get('response'): + ndfc_vrf_names = [ndfc_vrf['parent']['vrfName'] for ndfc_vrf in self.nd_vrfs['response']] # Take the difference between the vrfs in the data model and the vrfs in NDFC # If the vrf is in NDFC but not in the data model, delete it @@ -156,7 +164,6 @@ def run(self, tmp=None, task_vars=None): display.warning(f"Removing vrf_names: {diff_ndfc_vrf_names} from fabric: {fabric}") if diff_ndfc_vrf_names: - config = [] for ndfc_vrf_name in diff_ndfc_vrf_names: config.append( { @@ -165,24 +172,50 @@ def run(self, tmp=None, task_vars=None): } ) - ndfc_deleted_vrfs = self._execute_module( - module_name="cisco.dcnm.dcnm_vrf", - module_args={ - "fabric": fabric, - "config": config, - "state": "deleted" - }, - task_vars=task_vars, - tmp=tmp - ) - - # See above for failed query example - if ndfc_deleted_vrfs.get('failed'): - if ndfc_deleted_vrfs['failed']: - results['failed'] = True - results['msg'] = f"{ndfc_deleted_vrfs['msg']}" - return results - else: - results['changed'] = True + return config + + def run(self, tmp=None, task_vars=None): + results = super(ActionModule, self).run(tmp, task_vars) + results['changed'] = False + results['failed'] = False + + self.tmp = tmp + self.task_vars = task_vars + + fabric = self._task.args["fabric"] + # data to use for deleting unmanaged VRFs based on either + # (a) diff run data or (b) data model state compared to ND state + data = self._task.args["data"] + diff_run = self._task.args.get("diff_run", False) + + if not diff_run: + self.get_nd_vrfs(fabric) + if self.results.get('failed'): + results['failed'] = self.results['failed'] + results['msg'] = self.results['msg'] + + config = self.dm_nd_diff(fabric, data) + else: + config = data + + ndfc_deleted_vrfs = self._execute_module( + module_name="cisco.dcnm.dcnm_vrf", + module_args={ + "fabric": fabric, + "config": config, + "state": "deleted" + }, + task_vars=self.task_vars, + tmp=self.tmp + ) + + # See above for failed query example + if ndfc_deleted_vrfs.get('failed'): + if ndfc_deleted_vrfs['failed']: + results['failed'] = True + results['msg'] = f"{ndfc_deleted_vrfs['msg']}" + return results + else: + results['changed'] = True return results diff --git a/roles/dtc/remove/tasks/msd/vrfs.yml b/roles/dtc/remove/tasks/msd/vrfs.yml index c5e3b4d60..cf1aaff6c 100644 --- a/roles/dtc/remove/tasks/msd/vrfs.yml +++ b/roles/dtc/remove/tasks/msd/vrfs.yml @@ -37,10 +37,27 @@ when: - (multisite_vrf_delete_mode is defined) and (multisite_vrf_delete_mode is true|bool) +- name: Set VRF Config to MultiSite VRF Data + set_fact: + vrf_config: "{{ MD_Multisite }}" + +- name: Override VRF Config Based On Diff Run Settings + set_fact: + vrf_config: "{{ vars_common_msd.vrf_diff_result.removed }}" + when: + - run_map_read_result.diff_run is true|bool + +- debug: + var: vrf_config + +- pause: + seconds: 300 + - name: Remove Unmanaged Fabric VRFs in Nexus Dashboard cisco.nac_dc_vxlan.dtc.unmanaged_child_fabric_vrfs: fabric: "{{ MD_Extended.vxlan.fabric.name }}" - msite_data: "{{ MD_Multisite }}" + data: "{{ vrf_config }}" + diff_run: "{{ run_map_read_result.diff_run }}" register: child_fabric_vrf_results when: - multisite_vrf_delete_mode is defined From fa495e517a60e36558c9f137c0fe33a4b9bccd8c Mon Sep 17 00:00:00 2001 From: mwiebe Date: Wed, 15 Oct 2025 07:38:50 -0400 Subject: [PATCH 54/65] Revert Remove deploy based on changes_detected --- roles/dtc/remove/tasks/main.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/roles/dtc/remove/tasks/main.yml b/roles/dtc/remove/tasks/main.yml index 0c80c9fcc..db39ca2f0 100644 --- a/roles/dtc/remove/tasks/main.yml +++ b/roles/dtc/remove/tasks/main.yml @@ -59,12 +59,9 @@ - name: Deploy Remove Changes ansible.builtin.include_role: name: cisco.nac_dc_vxlan.dtc.deploy - when: > - ((stage_remove is false|bool) and (not MD_Extended.vxlan.fabric.type == 'MSD')) and - (change_flags.changes_detected_interfaces) or - (change_flags.changes_detected_policy) or - (change_flags.changes_detected_vpc_peering) or - (change_flags.changes_detected_vpc_domain_id_resource) + when: + - stage_remove is false|bool + - not MD_Extended.vxlan.fabric.type == 'MSD' - name: Mark Stage Role Remove Completed cisco.nac_dc_vxlan.common.run_map: From 2714590cf6ddb70b890f58b7f4a23afc37aaa26b Mon Sep 17 00:00:00 2001 From: Matt Tarkington Date: Wed, 15 Oct 2025 08:45:41 -0400 Subject: [PATCH 55/65] diff for msd vrfs and networks --- .../dtc/unmanaged_child_fabric_networks.py | 119 +++++++++++------- roles/dtc/remove/tasks/main.yml | 4 +- roles/dtc/remove/tasks/msd/networks.yml | 12 +- roles/dtc/remove/tasks/msd/vrfs.yml | 8 +- roles/dtc/remove/tasks/sub_main_msd.yml | 2 +- 5 files changed, 92 insertions(+), 53 deletions(-) diff --git a/plugins/action/dtc/unmanaged_child_fabric_networks.py b/plugins/action/dtc/unmanaged_child_fabric_networks.py index 175274870..4277fb026 100644 --- a/plugins/action/dtc/unmanaged_child_fabric_networks.py +++ b/plugins/action/dtc/unmanaged_child_fabric_networks.py @@ -32,26 +32,27 @@ class ActionModule(ActionBase): - - def run(self, tmp=None, task_vars=None): - results = super(ActionModule, self).run(tmp, task_vars) - results['changed'] = False - results['failed'] = False - - fabric = self._task.args["fabric"] - msite_data = self._task.args["msite_data"] - - networks = msite_data['overlay_attach_groups']['networks'] - network_names = [network['name'] for network in networks] - - ndfc_networks = self._execute_module( + """ + Action plugin to determine what Networks are to be removed from Nexus Dashboard (ND) + through comparison with the desired state in data model to ND state or through + the diff run framework option. + """ + def __init__(self, *args, **kwargs): + super(ActionModule, self).__init__(*args, **kwargs) + self.tmp = None + self.task_vars = None + self.nd_networks = {} + self.results = {} + + def get_nd_networks(self, fabric): + self.nd_networks = self._execute_module( module_name="cisco.dcnm.dcnm_network", module_args={ "fabric": fabric, "state": "query" }, - task_vars=task_vars, - tmp=tmp + task_vars=self.task_vars, + tmp=self.tmp ) # Failed query: @@ -67,11 +68,11 @@ def run(self, tmp=None, task_vars=None): # }, # "_ansible_parsed": true # } - if ndfc_networks.get('failed'): - if ndfc_networks['failed']: - results['failed'] = True - results['msg'] = f"{ndfc_networks['msg']}" - return results + if self.nd_networks.get('failed'): + if self.nd_networks['failed']: + self.results['failed'] = True + self.results['msg'] = f"{self.nd_networks['msg']}" + return self.results # Successful query: # { @@ -150,16 +151,23 @@ def run(self, tmp=None, task_vars=None): # }, # "_ansible_parsed": true # } + + def dm_nd_diff(self, fabric, data): + networks = data['overlay_attach_groups']['networks'] + network_names = [network['name'] for network in networks] + diff_ndfc_network_names = [] - if ndfc_networks.get('response'): - ndfc_network_names = [ndfc_network['parent']['networkName'] for ndfc_network in ndfc_networks['response']] + config = [] + + if self.nd_networks.get('response'): + ndfc_network_names = [ndfc_network['parent']['networkName'] for ndfc_network in self.nd_networks['response']] + # Take the difference between the networks in the data model and the networks in NDFC # If the network is in NDFC but not in the data model, delete it diff_ndfc_network_names = [ndfc_network_name for ndfc_network_name in ndfc_network_names if ndfc_network_name not in network_names] display.warning(f"Removing network_names: {diff_ndfc_network_names} from fabric: {fabric}") if diff_ndfc_network_names: - config = [] for ndfc_network_name in diff_ndfc_network_names: config.append( { @@ -168,24 +176,51 @@ def run(self, tmp=None, task_vars=None): } ) - ndfc_deleted_networks = self._execute_module( - module_name="cisco.dcnm.dcnm_network", - module_args={ - "fabric": fabric, - "config": config, - "state": "deleted" - }, - task_vars=task_vars, - tmp=tmp - ) - - # See above for failed query example - if ndfc_deleted_networks.get('failed'): - if ndfc_deleted_networks['failed']: - results['failed'] = True - results['msg'] = f"{ndfc_deleted_networks['msg']}" - return results - else: - results['changed'] = True + return config + + def run(self, tmp=None, task_vars=None): + results = super(ActionModule, self).run(tmp, task_vars) + results['changed'] = False + results['failed'] = False + + self.tmp = tmp + self.task_vars = task_vars + + fabric = self._task.args["fabric"] + # data to use for deleting unmanaged VRFs based on either + # (a) diff run data or (b) data model state compared to ND state + data = self._task.args["data"] + diff_run = self._task.args.get("diff_run", False) + + if not diff_run: + self.get_nd_networks(fabric) + if self.results.get('failed'): + results['failed'] = self.results['failed'] + results['msg'] = self.results['msg'] + + config = self.dm_nd_diff(fabric, data) + else: + config = data + + + ndfc_deleted_networks = self._execute_module( + module_name="cisco.dcnm.dcnm_network", + module_args={ + "fabric": fabric, + "config": config, + "state": "deleted" + }, + task_vars=task_vars, + tmp=tmp + ) + + # See above for failed query example + if ndfc_deleted_networks.get('failed'): + if ndfc_deleted_networks['failed']: + results['failed'] = True + results['msg'] = f"{ndfc_deleted_networks['msg']}" + return results + else: + results['changed'] = True return results diff --git a/roles/dtc/remove/tasks/main.yml b/roles/dtc/remove/tasks/main.yml index 0c80c9fcc..9b8b0c5ee 100644 --- a/roles/dtc/remove/tasks/main.yml +++ b/roles/dtc/remove/tasks/main.yml @@ -61,10 +61,10 @@ name: cisco.nac_dc_vxlan.dtc.deploy when: > ((stage_remove is false|bool) and (not MD_Extended.vxlan.fabric.type == 'MSD')) and - (change_flags.changes_detected_interfaces) or + ((change_flags.changes_detected_interfaces) or (change_flags.changes_detected_policy) or (change_flags.changes_detected_vpc_peering) or - (change_flags.changes_detected_vpc_domain_id_resource) + (change_flags.changes_detected_vpc_domain_id_resource)) - name: Mark Stage Role Remove Completed cisco.nac_dc_vxlan.common.run_map: diff --git a/roles/dtc/remove/tasks/msd/networks.yml b/roles/dtc/remove/tasks/msd/networks.yml index 3e34a339c..22b6280e9 100644 --- a/roles/dtc/remove/tasks/msd/networks.yml +++ b/roles/dtc/remove/tasks/msd/networks.yml @@ -37,10 +37,20 @@ when: - (multisite_network_delete_mode is defined) and (multisite_network_delete_mode is true|bool) +- name: Set Network Config to MultiSite VRF Data + set_fact: + network_config: "{{ MD_Multisite }}" + +- name: Override Network Config Based On Diff Run Settings + set_fact: + network_config: "{{ network_diff_result.removed }}" + when: + - run_map_read_result.diff_run is true|bool + - name: Remove Unmanaged Fabric Networks in Nexus Dashboard cisco.nac_dc_vxlan.dtc.unmanaged_child_fabric_networks: fabric: "{{ MD_Extended.vxlan.fabric.name }}" - msite_data: "{{ MD_Multisite }}" + msite_data: "{{ network_config }}" register: child_fabric_network_results when: - multisite_network_delete_mode is defined diff --git a/roles/dtc/remove/tasks/msd/vrfs.yml b/roles/dtc/remove/tasks/msd/vrfs.yml index cf1aaff6c..d591c3637 100644 --- a/roles/dtc/remove/tasks/msd/vrfs.yml +++ b/roles/dtc/remove/tasks/msd/vrfs.yml @@ -43,16 +43,10 @@ - name: Override VRF Config Based On Diff Run Settings set_fact: - vrf_config: "{{ vars_common_msd.vrf_diff_result.removed }}" + vrf_config: "{{ vrf_diff_result.removed }}" when: - run_map_read_result.diff_run is true|bool -- debug: - var: vrf_config - -- pause: - seconds: 300 - - name: Remove Unmanaged Fabric VRFs in Nexus Dashboard cisco.nac_dc_vxlan.dtc.unmanaged_child_fabric_vrfs: fabric: "{{ MD_Extended.vxlan.fabric.name }}" diff --git a/roles/dtc/remove/tasks/sub_main_msd.yml b/roles/dtc/remove/tasks/sub_main_msd.yml index 1d23a3bc1..ac8425b26 100644 --- a/roles/dtc/remove/tasks/sub_main_msd.yml +++ b/roles/dtc/remove/tasks/sub_main_msd.yml @@ -48,7 +48,7 @@ # when the create role was run. # ------------------------------------------------------------------------------------ - name: Import VRF and Network Roles From Common If Needed - ansible.builtin.import_tasks: msd/vrf_network_common.yml + ansible.builtin.include_tasks: msd/vrf_network_common.yml tags: "{{ nac_tags.remove_networks }}" when: not run_map_read_result.diff_run From 723274a6a4c7d6dc42d836391b456b543d73008d Mon Sep 17 00:00:00 2001 From: Matt Tarkington Date: Wed, 15 Oct 2025 08:52:03 -0400 Subject: [PATCH 56/65] fix lint errors --- plugins/action/dtc/unmanaged_child_fabric_networks.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/action/dtc/unmanaged_child_fabric_networks.py b/plugins/action/dtc/unmanaged_child_fabric_networks.py index 4277fb026..e56aefba7 100644 --- a/plugins/action/dtc/unmanaged_child_fabric_networks.py +++ b/plugins/action/dtc/unmanaged_child_fabric_networks.py @@ -202,7 +202,6 @@ def run(self, tmp=None, task_vars=None): else: config = data - ndfc_deleted_networks = self._execute_module( module_name="cisco.dcnm.dcnm_network", module_args={ From 037ce32cbeb9035ded886c75e944a09dd15f3205 Mon Sep 17 00:00:00 2001 From: Matt Tarkington Date: Wed, 15 Oct 2025 09:59:57 -0400 Subject: [PATCH 57/65] ansible-lint cleanup --- .github/ISSUE_TEMPLATE/bug_report.yml | 4 ++-- .../dtc/common/tasks/common/ndfc_underlay_ip_address.yml | 2 +- roles/dtc/create/tasks/common/devices_discovery.yml | 4 ++-- roles/dtc/create/tasks/common/interfaces.yml | 8 ++++---- roles/dtc/create/tasks/common/links.yml | 4 ++-- roles/dtc/create/tasks/common/vpc_peering.yml | 8 ++++---- roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml | 8 ++++---- roles/dtc/create/tasks/msd/vrfs_networks.yml | 4 ++-- roles/dtc/remove/tasks/msd/networks.yml | 4 ++-- roles/dtc/remove/tasks/msd/vrfs.yml | 4 ++-- 10 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 4fb325a0e..561034ea3 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -7,7 +7,7 @@ body: - type: markdown attributes: value: | - Thanks for creating a bug issue to help us improve the VXLAN as Code collection. + Thanks for creating a bug issue to help us improve the VXLAN as Code collection. Please fill out the sections below to help us understand and reproduce the issue you are facing. - type: markdown @@ -37,7 +37,7 @@ body: render: shell validations: required: true - + - type: textarea id: ndfc-version attributes: diff --git a/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml b/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml index 2425d7791..b53caac29 100644 --- a/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml +++ b/roles/dtc/common/tasks/common/ndfc_underlay_ip_address.yml @@ -76,7 +76,7 @@ register: underlay_ip_address_diff_result delegate_to: localhost -- name: Get MD5 Diff For Previous and Current Data Files +- name: Get MD5 Diff For Previous and Current Data Files cisco.nac_dc_vxlan.dtc.diff_model_changes: file_name_previous: "{{ path_name }}{{ file_name }}.old" file_name_current: "{{ path_name }}{{ file_name }}" diff --git a/roles/dtc/create/tasks/common/devices_discovery.yml b/roles/dtc/create/tasks/common/devices_discovery.yml index eb03f4b08..b0e43892a 100644 --- a/roles/dtc/create/tasks/common/devices_discovery.yml +++ b/roles/dtc/create/tasks/common/devices_discovery.yml @@ -71,7 +71,7 @@ # defined in the data model. - name: Initialize Underlay IP Config List to All Underlay IP Addresses - set_fact: + ansible.builtin.set_fact: underlay_ip_config_list: "{{ vars_common_local.underlay_ip_address }}" when: - MD_Extended.vxlan.underlay.general.manual_underlay_allocation is defined @@ -80,7 +80,7 @@ - (vars_common_local.underlay_ip_address is defined and vars_common_local.underlay_ip_address | length > 0) - name: Override Underlay IP Config List Based On Diff Run Settings - set_fact: + ansible.builtin.set_fact: underlay_ip_config_list: "{{ vars_common_local.underlay_ip_address_diff_result.updated }}" when: - run_map_read_result.diff_run is true|bool diff --git a/roles/dtc/create/tasks/common/interfaces.yml b/roles/dtc/create/tasks/common/interfaces.yml index 6407d65ca..e64f81236 100644 --- a/roles/dtc/create/tasks/common/interfaces.yml +++ b/roles/dtc/create/tasks/common/interfaces.yml @@ -64,11 +64,11 @@ # defined in the data model. - name: Initialize Interface Config List to All Interfaces - set_fact: + ansible.builtin.set_fact: interface_config_list: "{{ vars_common_local.interface_all_create }}" - name: Override Interface Config List Based On Diff Run Settings - set_fact: + ansible.builtin.set_fact: interface_config_list: "{{ vars_common_local.interface_diff_result.updated }}" when: - run_map_read_result.diff_run is true|bool @@ -79,8 +79,8 @@ state: replaced config: "{{ interface_config_list }}" vars: - ansible_command_timeout: 5000 - ansible_connect_timeout: 5000 + ansible_command_timeout: 5000 + ansible_connect_timeout: 5000 when: - MD_Extended.vxlan.topology.interfaces.modes.all.count > 0 - interface_config_list | length > 0 diff --git a/roles/dtc/create/tasks/common/links.yml b/roles/dtc/create/tasks/common/links.yml index 0c01a5cff..7c9854f34 100644 --- a/roles/dtc/create/tasks/common/links.yml +++ b/roles/dtc/create/tasks/common/links.yml @@ -57,11 +57,11 @@ register: result_links - name: Initialize Fabric Links Config List to All Links - set_fact: + ansible.builtin.set_fact: fabric_links_config_list: "{{ fabric_links }}" - name: Override Fabric Links Config List Based On Diff Run Settings - set_fact: + ansible.builtin.set_fact: fabric_links_config_list: "{{ fabric_links_diff_result.updated }}" when: - run_map_read_result.diff_run is true|bool diff --git a/roles/dtc/create/tasks/common/vpc_peering.yml b/roles/dtc/create/tasks/common/vpc_peering.yml index 09baf5dd2..e7e5cd6cb 100644 --- a/roles/dtc/create/tasks/common/vpc_peering.yml +++ b/roles/dtc/create/tasks/common/vpc_peering.yml @@ -58,14 +58,14 @@ # -------------------------------------------------------------------- - name: Initialize vPC Domain ID Resource Config List to All Interfaces - set_fact: + ansible.builtin.set_fact: vpc_domain_id_resource_config_list: "{{ vars_common_vxlan.vpc_domain_id_resource }}" when: - vars_common_vxlan.vpc_domain_id_resource is defined - vars_common_vxlan.vpc_domain_id_resource | length > 0 - name: Override vPC Domain ID Resource Config List Based On Diff Run Settings - set_fact: + ansible.builtin.set_fact: vpc_domain_id_resource_config_list: "{{ vars_common_vxlan.vpc_domain_id_resource_diff_result.updated }}" when: - run_map_read_result.diff_run is true|bool @@ -100,14 +100,14 @@ # -------------------------------------------------------------------- - name: Initialize vPC Peering Config List to All Interfaces - set_fact: + ansible.builtin.set_fact: vpc_peering_config_list: "{{ vars_common_vxlan.vpc_peering }}" when: - vars_common_vxlan.vpc_peering_diff_result is defined - vars_common_vxlan.vpc_peering_diff_result.updated | length > 0 - name: Override vPC Peering Config List Based On Diff Run Settings - set_fact: + ansible.builtin.set_fact: vpc_peering_config_list: "{{ vars_common_vxlan.vpc_peering_diff_result.updated }}" when: - run_map_read_result.diff_run is true|bool diff --git a/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml b/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml index 9b4e335f2..f20698294 100644 --- a/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml +++ b/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml @@ -67,11 +67,11 @@ - vars_common_local.vrf_config | length > 0 - name: Initialize VRF Config List to All VRFs - set_fact: + ansible.builtin.set_fact: vrf_config_list: "{{ vars_common_local.vrf_config }}" - name: Override VRF Config List Based On Diff Run Settings - set_fact: + ansible.builtin.set_fact: vrf_config_list: "{{ vars_common_local.vrf_diff_result.updated }}" when: - run_map_read_result.diff_run is true|bool @@ -115,11 +115,11 @@ - vars_common_local.net_config | length > 0 - name: Initialize Network Config List to All Networks - set_fact: + ansible.builtin.set_fact: network_config_list: "{{ vars_common_local.net_config }}" - name: Override Network Config List Based On Diff Run Settings - set_fact: + ansible.builtin.set_fact: network_config_list: "{{ vars_common_local.network_diff_result.updated }}" when: - run_map_read_result.diff_run is true|bool diff --git a/roles/dtc/create/tasks/msd/vrfs_networks.yml b/roles/dtc/create/tasks/msd/vrfs_networks.yml index 90067a385..e08e018a2 100644 --- a/roles/dtc/create/tasks/msd/vrfs_networks.yml +++ b/roles/dtc/create/tasks/msd/vrfs_networks.yml @@ -92,7 +92,7 @@ delegate_to: localhost - name: Override Networks List Based On Diff Run Settings - set_fact: + ansible.builtin.set_fact: net_config: "{{ network_diff_result.updated }}" when: - run_map_read_result.diff_run is true|bool @@ -100,7 +100,7 @@ - (network_diff_result is defined and network_diff_result.updated | length > 0) - name: Override Networks List Based On Diff Run Settings - set_fact: + ansible.builtin.set_fact: vrf_config: "{{ vrf_diff_result.updated }}" when: - run_map_read_result.diff_run is true|bool diff --git a/roles/dtc/remove/tasks/msd/networks.yml b/roles/dtc/remove/tasks/msd/networks.yml index 22b6280e9..620c0af23 100644 --- a/roles/dtc/remove/tasks/msd/networks.yml +++ b/roles/dtc/remove/tasks/msd/networks.yml @@ -38,11 +38,11 @@ - (multisite_network_delete_mode is defined) and (multisite_network_delete_mode is true|bool) - name: Set Network Config to MultiSite VRF Data - set_fact: + ansible.builtin.set_fact: network_config: "{{ MD_Multisite }}" - name: Override Network Config Based On Diff Run Settings - set_fact: + ansible.builtin.set_fact: network_config: "{{ network_diff_result.removed }}" when: - run_map_read_result.diff_run is true|bool diff --git a/roles/dtc/remove/tasks/msd/vrfs.yml b/roles/dtc/remove/tasks/msd/vrfs.yml index d591c3637..b30a8ec6d 100644 --- a/roles/dtc/remove/tasks/msd/vrfs.yml +++ b/roles/dtc/remove/tasks/msd/vrfs.yml @@ -38,11 +38,11 @@ - (multisite_vrf_delete_mode is defined) and (multisite_vrf_delete_mode is true|bool) - name: Set VRF Config to MultiSite VRF Data - set_fact: + ansible.builtin.set_fact: vrf_config: "{{ MD_Multisite }}" - name: Override VRF Config Based On Diff Run Settings - set_fact: + ansible.builtin.set_fact: vrf_config: "{{ vrf_diff_result.removed }}" when: - run_map_read_result.diff_run is true|bool From e04e05b51200a73f646517e0b0cad09e63e48281 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Wed, 15 Oct 2025 11:04:11 -0400 Subject: [PATCH 58/65] Move remove tasks out of import --- .../remove/tasks/msd/vrf_network_common.yml | 59 ------------------- roles/dtc/remove/tasks/sub_main_msd.yml | 41 +++++++++++-- 2 files changed, 37 insertions(+), 63 deletions(-) delete mode 100644 roles/dtc/remove/tasks/msd/vrf_network_common.yml diff --git a/roles/dtc/remove/tasks/msd/vrf_network_common.yml b/roles/dtc/remove/tasks/msd/vrf_network_common.yml deleted file mode 100644 index f1baaf638..000000000 --- a/roles/dtc/remove/tasks/msd/vrf_network_common.yml +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright (c) 2025 Cisco Systems, Inc. and its affiliates -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in -# the Software without restriction, including without limitation the rights to -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -# the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# SPDX-License-Identifier: MIT - ---- - -# ------------------------------------------------------------------------------------ -# This file is only imported in the remove role when the diff_run feature is disabled. -# If the diff_run feature is enabled, then the vrfs and networks tasks were imported -# when the create role was run. -# ------------------------------------------------------------------------------------ - -- name: Set path_name Var - ansible.builtin.set_fact: - path_name: "{{ role_path }}/../common/files/msd/{{ MD_Extended.vxlan.fabric.name }}/" - delegate_to: localhost - -- name: Run dtc.common.tasks.msd.ndfc_vrfs.yml - ansible.builtin.import_tasks: "{{ role_path }}/../common/tasks/msd/ndfc_vrfs.yml" - -- name: Run dtc.common.tasks.msd.ndfc_networks.yml - ansible.builtin.import_tasks: "{{ role_path }}/../common/tasks/msd/ndfc_networks.yml" - -# ---------------------------------------------------------------------------------- -# Changes detected flags for Multisite VRF and Networks is set when the tasks above -# are imported. We need to retrieve and store the values. -# ---------------------------------------------------------------------------------- -- name: Retrieve Multisite Flag Values - cisco.nac_dc_vxlan.common.change_flag_manager: - fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" - fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" - role_path: "{{ common_role_path }}" - operation: get - tags: "{{ nac_tags.common_role }}" - register: change_flag_multisite_result - delegate_to: localhost - -- name: Store Change Flags For Use In Subsequent Roles - ansible.builtin.set_fact: - change_flags_multisite: "{{ change_flag_multisite_result['flags'] }}" - tags: "{{ nac_tags.common_role }}" - delegate_to: localhost diff --git a/roles/dtc/remove/tasks/sub_main_msd.yml b/roles/dtc/remove/tasks/sub_main_msd.yml index ac8425b26..d88cadcaf 100644 --- a/roles/dtc/remove/tasks/sub_main_msd.yml +++ b/roles/dtc/remove/tasks/sub_main_msd.yml @@ -47,10 +47,43 @@ # If the diff_run feature is enabled, then the vrfs and networks tasks were imported # when the create role was run. # ------------------------------------------------------------------------------------ -- name: Import VRF and Network Roles From Common If Needed - ansible.builtin.include_tasks: msd/vrf_network_common.yml - tags: "{{ nac_tags.remove_networks }}" - when: not run_map_read_result.diff_run + +- name: Set path_name Var + ansible.builtin.set_fact: + path_name: "{{ role_path }}/../common/files/msd/{{ MD_Extended.vxlan.fabric.name }}/" + delegate_to: localhost + when: run_map_read_result.diff_run is false|bool + +- name: Run dtc.common.tasks.msd.ndfc_vrfs.yml + ansible.builtin.import_tasks: "{{ role_path }}/../common/tasks/msd/ndfc_vrfs.yml" + when: run_map_read_result.diff_run is false|bool + +- name: Run dtc.common.tasks.msd.ndfc_networks.yml + ansible.builtin.import_tasks: "{{ role_path }}/../common/tasks/msd/ndfc_networks.yml" + when: run_map_read_result.diff_run is false|bool + +# ---------------------------------------------------------------------------------- +# Changes detected flags for Multisite VRF and Networks is set when the tasks above +# are imported. We need to retrieve and store the values. +# ---------------------------------------------------------------------------------- +- name: Retrieve Multisite Flag Values + cisco.nac_dc_vxlan.common.change_flag_manager: + fabric_type: "{{ MD_Extended.vxlan.fabric.type }}" + fabric_name: "{{ MD_Extended.vxlan.fabric.name }}" + role_path: "{{ common_role_path }}" + operation: get + tags: "{{ nac_tags.common_role }}" + register: change_flag_multisite_result + delegate_to: localhost + when: run_map_read_result.diff_run is false|bool + +- name: Store Change Flags For Use In Subsequent Roles + ansible.builtin.set_fact: + change_flags_multisite: "{{ change_flag_multisite_result['flags'] }}" + tags: "{{ nac_tags.common_role }}" + delegate_to: localhost + when: run_map_read_result.diff_run is false|bool +# ---------------------------------------------------------------------------------- - name: Remove MSD Fabric Networks from Nexus Dashboard ansible.builtin.import_tasks: msd/networks.yml From f5473e010179534803863502b06903dd5db36f0d Mon Sep 17 00:00:00 2001 From: mwiebe Date: Wed, 15 Oct 2025 11:19:11 -0400 Subject: [PATCH 59/65] Fix key error --- roles/dtc/remove/tasks/msd/networks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/dtc/remove/tasks/msd/networks.yml b/roles/dtc/remove/tasks/msd/networks.yml index 620c0af23..839dd0b7c 100644 --- a/roles/dtc/remove/tasks/msd/networks.yml +++ b/roles/dtc/remove/tasks/msd/networks.yml @@ -50,7 +50,7 @@ - name: Remove Unmanaged Fabric Networks in Nexus Dashboard cisco.nac_dc_vxlan.dtc.unmanaged_child_fabric_networks: fabric: "{{ MD_Extended.vxlan.fabric.name }}" - msite_data: "{{ network_config }}" + data: "{{ network_config }}" register: child_fabric_network_results when: - multisite_network_delete_mode is defined From b296e22f97fe746d6bad93e10a987ca8c95ffd5a Mon Sep 17 00:00:00 2001 From: mwiebe Date: Wed, 15 Oct 2025 13:04:36 -0400 Subject: [PATCH 60/65] MSD Fixes --- plugins/action/common/run_map.py | 2 ++ .../dtc/unmanaged_child_fabric_networks.py | 5 +++++ .../action/dtc/unmanaged_child_fabric_vrfs.py | 5 +++++ roles/dtc/remove/tasks/msd/networks.yml | 1 + roles/dtc/remove/tasks/sub_main_msd.yml | 18 ++++++++---------- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/plugins/action/common/run_map.py b/plugins/action/common/run_map.py index 8b1e17c64..3e151c702 100644 --- a/plugins/action/common/run_map.py +++ b/plugins/action/common/run_map.py @@ -91,5 +91,7 @@ def run(self, tmp=None, task_vars=None): with open(run_map_file_path, 'w') as outfile: outfile.write("### This File Is Auto Generated, Do Not Edit ###\n") yaml.dump(updated_run_map, outfile, default_flow_style=False) + # Add run map to results dictonary + results['updated'] = updated_run_map return results diff --git a/plugins/action/dtc/unmanaged_child_fabric_networks.py b/plugins/action/dtc/unmanaged_child_fabric_networks.py index e56aefba7..d45e690a0 100644 --- a/plugins/action/dtc/unmanaged_child_fabric_networks.py +++ b/plugins/action/dtc/unmanaged_child_fabric_networks.py @@ -202,6 +202,11 @@ def run(self, tmp=None, task_vars=None): else: config = data + # If config is an empty list then we can return early as + # there is nothing to delete + if not config: + return results + ndfc_deleted_networks = self._execute_module( module_name="cisco.dcnm.dcnm_network", module_args={ diff --git a/plugins/action/dtc/unmanaged_child_fabric_vrfs.py b/plugins/action/dtc/unmanaged_child_fabric_vrfs.py index 0ccb125a1..2776c9cb5 100644 --- a/plugins/action/dtc/unmanaged_child_fabric_vrfs.py +++ b/plugins/action/dtc/unmanaged_child_fabric_vrfs.py @@ -198,6 +198,11 @@ def run(self, tmp=None, task_vars=None): else: config = data + # If config is an empty list then we can return early as + # there is nothing to delete + if not config: + return results + ndfc_deleted_vrfs = self._execute_module( module_name="cisco.dcnm.dcnm_vrf", module_args={ diff --git a/roles/dtc/remove/tasks/msd/networks.yml b/roles/dtc/remove/tasks/msd/networks.yml index 839dd0b7c..7b999ac93 100644 --- a/roles/dtc/remove/tasks/msd/networks.yml +++ b/roles/dtc/remove/tasks/msd/networks.yml @@ -51,6 +51,7 @@ cisco.nac_dc_vxlan.dtc.unmanaged_child_fabric_networks: fabric: "{{ MD_Extended.vxlan.fabric.name }}" data: "{{ network_config }}" + diff_run: "{{ run_map_read_result.diff_run }}" register: child_fabric_network_results when: - multisite_network_delete_mode is defined diff --git a/roles/dtc/remove/tasks/sub_main_msd.yml b/roles/dtc/remove/tasks/sub_main_msd.yml index d88cadcaf..6b77daab2 100644 --- a/roles/dtc/remove/tasks/sub_main_msd.yml +++ b/roles/dtc/remove/tasks/sub_main_msd.yml @@ -42,25 +42,23 @@ - "{{ nac_tags.remove_networks }}" - "{{ nac_tags.remove_vrfs }}" -# ------------------------------------------------------------------------------------ -# This file is only imported in the remove role when the diff_run feature is disabled. -# If the diff_run feature is enabled, then the vrfs and networks tasks were imported -# when the create role was run. -# ------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------------- +# These task files are only imported in the remove role if the create role did NOT run +# ------------------------------------------------------------------------------------- - name: Set path_name Var ansible.builtin.set_fact: path_name: "{{ role_path }}/../common/files/msd/{{ MD_Extended.vxlan.fabric.name }}/" delegate_to: localhost - when: run_map_read_result.diff_run is false|bool + when: run_map.updated.role_create_completed is false|bool - name: Run dtc.common.tasks.msd.ndfc_vrfs.yml ansible.builtin.import_tasks: "{{ role_path }}/../common/tasks/msd/ndfc_vrfs.yml" - when: run_map_read_result.diff_run is false|bool + when: run_map.updated.role_create_completed is false|bool - name: Run dtc.common.tasks.msd.ndfc_networks.yml ansible.builtin.import_tasks: "{{ role_path }}/../common/tasks/msd/ndfc_networks.yml" - when: run_map_read_result.diff_run is false|bool + when: run_map.updated.role_create_completed is false|bool # ---------------------------------------------------------------------------------- # Changes detected flags for Multisite VRF and Networks is set when the tasks above @@ -75,14 +73,14 @@ tags: "{{ nac_tags.common_role }}" register: change_flag_multisite_result delegate_to: localhost - when: run_map_read_result.diff_run is false|bool + when: run_map.updated.role_create_completed is false|bool - name: Store Change Flags For Use In Subsequent Roles ansible.builtin.set_fact: change_flags_multisite: "{{ change_flag_multisite_result['flags'] }}" tags: "{{ nac_tags.common_role }}" delegate_to: localhost - when: run_map_read_result.diff_run is false|bool + when: run_map.updated.role_create_completed is false|bool # ---------------------------------------------------------------------------------- - name: Remove MSD Fabric Networks from Nexus Dashboard From 31d545234dd358f1d697d6a23f9ffe7a9b2d9ff3 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Wed, 15 Oct 2025 15:23:39 -0400 Subject: [PATCH 61/65] More MSD fixes --- plugins/action/dtc/fabric_deploy_manager.py | 7 +++--- .../dtc/unmanaged_child_fabric_networks.py | 4 +++- .../action/dtc/unmanaged_child_fabric_vrfs.py | 4 +++- roles/dtc/remove/tasks/sub_main_msd.yml | 22 +++++++++++++++++++ 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/plugins/action/dtc/fabric_deploy_manager.py b/plugins/action/dtc/fabric_deploy_manager.py index a01a4048b..ee7c45f79 100644 --- a/plugins/action/dtc/fabric_deploy_manager.py +++ b/plugins/action/dtc/fabric_deploy_manager.py @@ -86,6 +86,7 @@ def fabric_check_sync(self): response = self._send_request("GET", self.api_paths["get_switches_by_fabric"]) display.banner(f">>>> Fabric: ({self.fabric_name}) Type: ({self.fabric_type}) in sync: {self.fabric_in_sync}") + display.banner(">>>>") def _fabric_check_sync_helper(self, response): if response.get('DATA'): @@ -103,7 +104,7 @@ def fabric_config_save(self): response = self._send_request("POST", self.api_paths["config_save"]) if response.get('RETURN_CODE') == 200: - display.banner(f">>>> Succeeded for Fabric {self.fabric_name}") + pass else: self.fabric_save_succeeded = False display.warning(f">>>> Failed for Fabric {self.fabric_name}: {response}") @@ -115,7 +116,7 @@ def fabric_deploy(self): response = self._send_request("POST", self.api_paths["config_deploy"]) if response.get('RETURN_CODE') == 200: - display.banner(f">>>> Succeeded for Fabric {self.fabric_name}") + pass else: self.fabric_deploy_succeeded = False display.warning(f">>>> Failed for Fabric {self.fabric_name}: {response}") @@ -127,7 +128,7 @@ def fabric_history_get(self): response = self._send_request("GET", self.api_paths["fabric_history"]) if response.get('RETURN_CODE') == 200: - display.banner(f">>>> Succeeded for Fabric {self.fabric_name}") + pass else: display.warning(f">>>> Failed for Fabric {self.fabric_name}: {response}") diff --git a/plugins/action/dtc/unmanaged_child_fabric_networks.py b/plugins/action/dtc/unmanaged_child_fabric_networks.py index d45e690a0..88d0cc769 100644 --- a/plugins/action/dtc/unmanaged_child_fabric_networks.py +++ b/plugins/action/dtc/unmanaged_child_fabric_networks.py @@ -166,7 +166,6 @@ def dm_nd_diff(self, fabric, data): # If the network is in NDFC but not in the data model, delete it diff_ndfc_network_names = [ndfc_network_name for ndfc_network_name in ndfc_network_names if ndfc_network_name not in network_names] - display.warning(f"Removing network_names: {diff_ndfc_network_names} from fabric: {fabric}") if diff_ndfc_network_names: for ndfc_network_name in diff_ndfc_network_names: config.append( @@ -207,6 +206,9 @@ def run(self, tmp=None, task_vars=None): if not config: return results + network_names = [network['net_name'] for network in config] + display.warning(f"Removing network_names: {network_names} from fabric: {fabric}") + ndfc_deleted_networks = self._execute_module( module_name="cisco.dcnm.dcnm_network", module_args={ diff --git a/plugins/action/dtc/unmanaged_child_fabric_vrfs.py b/plugins/action/dtc/unmanaged_child_fabric_vrfs.py index 2776c9cb5..40b5f7d5a 100644 --- a/plugins/action/dtc/unmanaged_child_fabric_vrfs.py +++ b/plugins/action/dtc/unmanaged_child_fabric_vrfs.py @@ -162,7 +162,6 @@ def dm_nd_diff(self, fabric, data): # If the vrf is in NDFC but not in the data model, delete it diff_ndfc_vrf_names = [ndfc_vrf_name for ndfc_vrf_name in ndfc_vrf_names if ndfc_vrf_name not in vrf_names] - display.warning(f"Removing vrf_names: {diff_ndfc_vrf_names} from fabric: {fabric}") if diff_ndfc_vrf_names: for ndfc_vrf_name in diff_ndfc_vrf_names: config.append( @@ -203,6 +202,9 @@ def run(self, tmp=None, task_vars=None): if not config: return results + vrf_names = [vrf['vrf_name'] for vrf in config] + display.warning(f"Removing vrf_names: {vrf_names} from fabric: {fabric}") + ndfc_deleted_vrfs = self._execute_module( module_name="cisco.dcnm.dcnm_vrf", module_args={ diff --git a/roles/dtc/remove/tasks/sub_main_msd.yml b/roles/dtc/remove/tasks/sub_main_msd.yml index 6b77daab2..10cc7519d 100644 --- a/roles/dtc/remove/tasks/sub_main_msd.yml +++ b/roles/dtc/remove/tasks/sub_main_msd.yml @@ -42,6 +42,22 @@ - "{{ nac_tags.remove_networks }}" - "{{ nac_tags.remove_vrfs }}" +# ------------------------------------------------------------------------------------- +# There is an issue in Ansible were data that is needed to remove the networks and +# vrfs gets overwritten by the import_tasks on line 69 and 73. To get around this +# issue we include the tasks to remove networks and vrfs here WHEN the create role +# has already been run. +# ------------------------------------------------------------------------------------- +- name: Remove MSD Fabric Networks from Nexus Dashboard + ansible.builtin.import_tasks: msd/networks.yml + tags: "{{ nac_tags.remove_networks }}" + when: run_map.updated.role_create_completed is true|bool + +- name: Remove MSD Fabric VRFs from Nexus Dashboard + ansible.builtin.import_tasks: msd/vrfs.yml + tags: "{{ nac_tags.remove_vrfs }}" + when: run_map.updated.role_create_completed is true|bool + # ------------------------------------------------------------------------------------- # These task files are only imported in the remove role if the create role did NOT run # ------------------------------------------------------------------------------------- @@ -83,13 +99,19 @@ when: run_map.updated.role_create_completed is false|bool # ---------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------------- +# These task files here to remove networks and vrfs are only imported here if the +# create role did NOT run +# ------------------------------------------------------------------------------------- - name: Remove MSD Fabric Networks from Nexus Dashboard ansible.builtin.import_tasks: msd/networks.yml tags: "{{ nac_tags.remove_networks }}" + when: run_map.updated.role_create_completed is false|bool - name: Remove MSD Fabric VRFs from Nexus Dashboard ansible.builtin.import_tasks: msd/vrfs.yml tags: "{{ nac_tags.remove_vrfs }}" + when: run_map.updated.role_create_completed is false|bool - name: Remove MSD Fabric Child Fabrics from Nexus Dashboard ansible.builtin.import_tasks: msd/child_fabrics.yml From 87b42bc8efdca3e17fc02f6103d62f9af1061501 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Wed, 15 Oct 2025 15:26:14 -0400 Subject: [PATCH 62/65] Fix comment --- roles/dtc/remove/tasks/sub_main_msd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/dtc/remove/tasks/sub_main_msd.yml b/roles/dtc/remove/tasks/sub_main_msd.yml index 10cc7519d..5e31e7ac1 100644 --- a/roles/dtc/remove/tasks/sub_main_msd.yml +++ b/roles/dtc/remove/tasks/sub_main_msd.yml @@ -44,7 +44,7 @@ # ------------------------------------------------------------------------------------- # There is an issue in Ansible were data that is needed to remove the networks and -# vrfs gets overwritten by the import_tasks on line 69 and 73. To get around this +# vrfs gets overwritten by the import_tasks from common. To get around this # issue we include the tasks to remove networks and vrfs here WHEN the create role # has already been run. # ------------------------------------------------------------------------------------- From 64202aacd6528e1e91bde551ef466f9382c2dc01 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Wed, 15 Oct 2025 19:12:34 -0400 Subject: [PATCH 63/65] Change import to include --- roles/dtc/common/tasks/main.yml | 35 ++++++------ .../dtc/common/tasks/sub_main_ebgp_vxlan.yml | 50 ++++++++-------- roles/dtc/common/tasks/sub_main_external.yml | 40 ++++++------- roles/dtc/common/tasks/sub_main_isn.yml | 38 ++++++------- roles/dtc/common/tasks/sub_main_msd.yml | 8 +-- roles/dtc/common/tasks/sub_main_vxlan.yml | 52 ++++++++--------- roles/dtc/connectivity_check/tasks/main.yml | 10 ++-- roles/dtc/create/tasks/common/devices.yml | 2 +- roles/dtc/create/tasks/main.yml | 10 ++-- roles/dtc/create/tasks/msd/vrfs_networks.yml | 4 +- .../dtc/create/tasks/sub_main_ebgp_vxlan.yml | 36 ++++++++---- roles/dtc/create/tasks/sub_main_external.yml | 37 +++++++----- roles/dtc/create/tasks/sub_main_isn.yml | 30 ++++++---- roles/dtc/create/tasks/sub_main_msd.yml | 14 +++-- roles/dtc/create/tasks/sub_main_vxlan.yml | 48 ++++++++++------ roles/dtc/deploy/tasks/main.yml | 57 +++++++++---------- roles/dtc/remove/tasks/main.yml | 10 ++-- .../dtc/remove/tasks/sub_main_ebgp_vxlan.yml | 36 ++++++++---- roles/dtc/remove/tasks/sub_main_external.yml | 30 ++++++---- roles/dtc/remove/tasks/sub_main_isn.yml | 24 +++++--- roles/dtc/remove/tasks/sub_main_msd.yml | 32 +++++++---- roles/dtc/remove/tasks/sub_main_vxlan.yml | 48 ++++++++++------ roles/validate/tasks/main.yml | 7 ++- .../tasks/manage_model_files_current.yml | 3 +- roles/validate/tasks/sub_main.yml | 4 +- 25 files changed, 384 insertions(+), 281 deletions(-) diff --git a/roles/dtc/common/tasks/main.yml b/roles/dtc/common/tasks/main.yml index 1a2dff901..6586a869a 100644 --- a/roles/dtc/common/tasks/main.yml +++ b/roles/dtc/common/tasks/main.yml @@ -35,30 +35,27 @@ tags: "{{ nac_tags.common_role }}" delegate_to: localhost -- name: Import Role Tasks for iBGP VXLAN Fabric - ansible.builtin.import_tasks: sub_main_vxlan.yml - tags: "{{ nac_tags.common_role }}" - when: MD_Extended.vxlan.fabric.type == 'VXLAN_EVPN' +- block: + - name: Import Role Tasks for iBGP VXLAN Fabric + ansible.builtin.include_tasks: sub_main_vxlan.yml + when: MD_Extended.vxlan.fabric.type == 'VXLAN_EVPN' -- name: Import Role Tasks for eBGP VXLAN Fabric - ansible.builtin.import_tasks: sub_main_ebgp_vxlan.yml - tags: "{{ nac_tags.common_role }}" - when: MD_Extended.vxlan.fabric.type == 'eBGP_VXLAN' + - name: Import Role Tasks for eBGP VXLAN Fabric + ansible.builtin.include_tasks: sub_main_ebgp_vxlan.yml + when: MD_Extended.vxlan.fabric.type == 'eBGP_VXLAN' -- name: Import Role Tasks for ISN Fabric - ansible.builtin.import_tasks: sub_main_isn.yml - tags: "{{ nac_tags.common_role }}" - when: MD_Extended.vxlan.fabric.type == 'ISN' + - name: Import Role Tasks for ISN Fabric + ansible.builtin.include_tasks: sub_main_isn.yml + when: MD_Extended.vxlan.fabric.type == 'ISN' -- name: Import Role Tasks for MSD Fabric - ansible.builtin.import_tasks: sub_main_msd.yml - tags: "{{ nac_tags.common_role }}" - when: MD_Extended.vxlan.fabric.type == 'MSD' + - name: Import Role Tasks for MSD Fabric + ansible.builtin.include_tasks: sub_main_msd.yml + when: MD_Extended.vxlan.fabric.type == 'MSD' -- name: Import Role Tasks for External Fabric - ansible.builtin.import_tasks: sub_main_external.yml + - name: Import Role Tasks for External Fabric + ansible.builtin.include_tasks: sub_main_external.yml + when: MD_Extended.vxlan.fabric.type == 'External' tags: "{{ nac_tags.common_role }}" - when: MD_Extended.vxlan.fabric.type == 'External' - name: Retrieve Flag Values cisco.nac_dc_vxlan.common.change_flag_manager: diff --git a/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml b/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml index 3261393a9..ccd27aad7 100644 --- a/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml +++ b/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml @@ -36,7 +36,7 @@ delegate_to: localhost - name: Cleanup Files from Previous Run if run_map requires it - ansible.builtin.import_tasks: cleanup_files.yml + ansible.builtin.include_tasks: cleanup_files.yml when: - not run_map_read_result.diff_run or ((force_run_all is defined) and (force_run_all is true|bool)) @@ -45,165 +45,165 @@ # -------------------------------------------------------------------- - name: Build eBGP VXLAN Fabric Create Parameters - ansible.builtin.import_tasks: common/ndfc_fabric.yml + ansible.builtin.include_tasks: common/ndfc_fabric.yml # -------------------------------------------------------------------- # Build eBGP VXLAN Fabric Switch Inventory List From Template # -------------------------------------------------------------------- - name: Build eBGP VXLAN Fabric Switch Inventory List From Template - ansible.builtin.import_tasks: common/ndfc_inventory.yml + ansible.builtin.include_tasks: common/ndfc_inventory.yml # We need to also build an inventory list without bootstrap settings # This will be used for device removal. - name: Build eBGP VXLAN Fabric Switch Inventory List From Template - No Bootstrap - ansible.builtin.import_tasks: common/ndfc_inventory_no_bootstrap.yml + ansible.builtin.include_tasks: common/ndfc_inventory_no_bootstrap.yml # -------------------------------------------------------------------- # Build vPC Domain ID Resource From Template # -------------------------------------------------------------------- - name: Build vPC Domain ID Resource From Template - ansible.builtin.import_tasks: common/ndfc_vpc_domain_id_resource.yml + ansible.builtin.include_tasks: common/ndfc_vpc_domain_id_resource.yml # -------------------------------------------------------------------- # Build vPC Intra Fabric Links for vPC Peering From Template # -------------------------------------------------------------------- - name: Build vPC Intra Fabric Links From Template - ansible.builtin.import_tasks: common/ndfc_vpc_fabric_peering_links.yml + ansible.builtin.include_tasks: common/ndfc_vpc_fabric_peering_links.yml # -------------------------------------------------------------------- # Build vPC Peering parameter List From Template # -------------------------------------------------------------------- - name: Build vPC Peering Parameters - ansible.builtin.import_tasks: common/ndfc_vpc_peering_pairs.yml + ansible.builtin.include_tasks: common/ndfc_vpc_peering_pairs.yml # -------------------------------------------------------------------- # Build NDFC Fabric VRFs Attach List From Template # -------------------------------------------------------------------- - name: Build NDFC Fabric VRFs Attach List From Template - ansible.builtin.import_tasks: vxlan/ndfc_vrfs.yml + ansible.builtin.include_tasks: vxlan/ndfc_vrfs.yml # -------------------------------------------------------------------- # Build eBGP VXLAN Fabric Networks Attach List From Template # -------------------------------------------------------------------- - name: Build eBGP VXLAN Fabric Networks Attach List From Template - ansible.builtin.import_tasks: vxlan/ndfc_networks.yml + ansible.builtin.include_tasks: vxlan/ndfc_networks.yml # -------------------------------------------------------------------- # Build eBGP VXLAN Fabric Breakout Interfaces List From Template # -------------------------------------------------------------------- - name: Build eBGP VXLAN Fabric Breakout Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_breakout.yml + ansible.builtin.include_tasks: common/ndfc_interface_breakout.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric PreProv Breakout Interfaces List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric Breakout PreProv Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_breakout_preprov.yml + ansible.builtin.include_tasks: common/ndfc_interface_breakout_preprov.yml # -------------------------------------------------------------------- # Build eBGP VXLAN Fabric Loopback Interfaces List From Template # -------------------------------------------------------------------- - name: Build eBGP VXLAN Fabric Loopback Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_loopback.yml + ansible.builtin.include_tasks: common/ndfc_interface_loopback.yml # -------------------------------------------------------------------- # Build eBGP VXLAN Fabric Access Port-Channel Interfaces List From Template # -------------------------------------------------------------------- - name: Build eBGP VXLAN Fabric Access Port-Channel Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_access_po.yml + ansible.builtin.include_tasks: common/ndfc_interface_access_po.yml # -------------------------------------------------------------------- # Build eBGP VXLAN Fabric Trunk Port-Channel Interfaces List From Template # -------------------------------------------------------------------- - name: Build eBGP VXLAN Fabric Trunk Port-Channel Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_trunk_po.yml + ansible.builtin.include_tasks: common/ndfc_interface_trunk_po.yml # -------------------------------------------------------------------- # Build eBGP VXLAN Fabric Interface Routed List From Template # -------------------------------------------------------------------- - name: Build eBGP VXLAN Fabric Interface Routed List From Template - ansible.builtin.import_tasks: common/ndfc_interface_routed.yml + ansible.builtin.include_tasks: common/ndfc_interface_routed.yml # -------------------------------------------------------------------- # Build eBGP VXLAN Fabric Sub-Interface Routed List From Template # -------------------------------------------------------------------- - name: Build eBGP VXLAN Fabric Sub-Interface Routed List From Template - ansible.builtin.import_tasks: common/ndfc_sub_interface_routed.yml + ansible.builtin.include_tasks: common/ndfc_sub_interface_routed.yml # -------------------------------------------------------------------- # Build eBGP VXLAN Fabric Routed Port-Channel Interface List From Template # -------------------------------------------------------------------- - name: Build eBGP VXLAN Fabric Routed Port-Channel Interface List From Template - ansible.builtin.import_tasks: common/ndfc_interface_po_routed.yml + ansible.builtin.include_tasks: common/ndfc_interface_po_routed.yml # -------------------------------------------------------------------- # Build Trunk Interfaces List From Template # -------------------------------------------------------------------- - name: Build Trunk Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_trunk.yml + ansible.builtin.include_tasks: common/ndfc_interface_trunk.yml # -------------------------------------------------------------------- # Build Access Interfaces List From Template # -------------------------------------------------------------------- - name: Build Access Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_access.yml + ansible.builtin.include_tasks: common/ndfc_interface_access.yml # -------------------------------------------------------------------- # Build Dot1q Interfaces List From Template # -------------------------------------------------------------------- - name: Build Dot1q Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_dot1q.yml + ansible.builtin.include_tasks: common/ndfc_interface_dot1q.yml # -------------------------------------------------------------------- # Build eBGP VXLAN Fabric Interface vPC List From Template # -------------------------------------------------------------------- - name: Build eBGP VXLAN Fabric interface vPC List From Template - ansible.builtin.import_tasks: common/ndfc_interface_vpc.yml + ansible.builtin.include_tasks: common/ndfc_interface_vpc.yml # -------------------------------------------------------------------- # Build eBGP VXLAN Fabric interface all List From Template # -------------------------------------------------------------------- - name: Build eBGP VXLAN Fabric interface All List From Template - ansible.builtin.import_tasks: common/ndfc_interface_all.yml + ansible.builtin.include_tasks: common/ndfc_interface_all.yml # -------------------------------------------------------------------- # Build eBGP VXLAN Fabric Policy List From Template # -------------------------------------------------------------------- - name: Build eBGP VXLAN Fabric Policy List From Template - ansible.builtin.import_tasks: common/ndfc_policy.yml + ansible.builtin.include_tasks: common/ndfc_policy.yml # # -------------------------------------------------------------------- # # Build eBGP VXLAN Fabric Links List From Template # # -------------------------------------------------------------------- # - name: Build eBGP VXLAN Fabric Links List From Template -# ansible.builtin.import_tasks: common/ndfc_fabric_links.yml +# ansible.builtin.include_tasks: common/ndfc_fabric_links.yml # # -------------------------------------------------------------------- # # Build Edge Connections List From Template # # -------------------------------------------------------------------- # - name: Edge Connections List From Template -# ansible.builtin.import_tasks: common/ndfc_edge_connections.yml +# ansible.builtin.include_tasks: common/ndfc_edge_connections.yml # -------------------------------------------------------------------- # Save Local Variables To NameSpace Dict For Use Elsewhere diff --git a/roles/dtc/common/tasks/sub_main_external.yml b/roles/dtc/common/tasks/sub_main_external.yml index 24fa53654..604f30bb4 100644 --- a/roles/dtc/common/tasks/sub_main_external.yml +++ b/roles/dtc/common/tasks/sub_main_external.yml @@ -36,7 +36,7 @@ delegate_to: localhost - name: Cleanup Files from Previous Run if run_map requires it - ansible.builtin.import_tasks: cleanup_files.yml + ansible.builtin.include_tasks: cleanup_files.yml when: - not run_map_read_result.diff_run or ((force_run_all is defined) and (force_run_all is true|bool)) @@ -45,131 +45,131 @@ # ------------------------------------------------------------------------ - name: Build External Fabric List From Template - ansible.builtin.import_tasks: common/ndfc_fabric.yml + ansible.builtin.include_tasks: common/ndfc_fabric.yml # ------------------------------------------------------------------------ # Build External Fabric Switch Inventory List From Template # ------------------------------------------------------------------------ - name: Build External Fabric Switch Inventory List From Template - ansible.builtin.import_tasks: common/ndfc_inventory.yml + ansible.builtin.include_tasks: common/ndfc_inventory.yml # We need to also build an inventory list without bootstrap settings # This will be used for device removal. - name: Build External Fabric Switch Inventory List From Template - No Bootstrap - ansible.builtin.import_tasks: common/ndfc_inventory_no_bootstrap.yml + ansible.builtin.include_tasks: common/ndfc_inventory_no_bootstrap.yml # -------------------------------------------------------------------- # Build External Fabric vPC Peering Template # -------------------------------------------------------------------- - name: Build External Fabric vPC Peering Template - ansible.builtin.import_tasks: external/ndfc_vpc_peering_pairs.yml + ansible.builtin.include_tasks: external/ndfc_vpc_peering_pairs.yml # ------------------------------------------------------------------------ # Build External Fabric Breakout Interfaces List From Template # ------------------------------------------------------------------------ - name: Build External Fabric Breakout Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_breakout.yml + ansible.builtin.include_tasks: common/ndfc_interface_breakout.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric PreProv Breakout Interfaces List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric Breakout PreProv Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_breakout_preprov.yml + ansible.builtin.include_tasks: common/ndfc_interface_breakout_preprov.yml # ---------------------------------------------------------------------------- # Build External Fabric Access Port-Channel Interfaces List From Template # ---------------------------------------------------------------------------- - name: Build NDFC Fabric Access Port-Channel Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_access_po.yml + ansible.builtin.include_tasks: common/ndfc_interface_access_po.yml # ------------------------------------------------------------------------ # Build External Fabric Access Interfaces List From Template # ------------------------------------------------------------------------ - name: Build External Fabric Access Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_access.yml + ansible.builtin.include_tasks: common/ndfc_interface_access.yml # ------------------------------------------------------------------------ # Build External Fabric Dot1q Interfaces List From Template # ------------------------------------------------------------------------ - name: Build External Fabric Dot1q Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_dot1q.yml + ansible.builtin.include_tasks: common/ndfc_interface_dot1q.yml # ------------------------------------------------------------------------ # Build External Fabric Loopback Interfaces List From Template # ------------------------------------------------------------------------ - name: Build External Fabric Loopback Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_loopback.yml + ansible.builtin.include_tasks: common/ndfc_interface_loopback.yml # ------------------------------------------------------------------------ # Build External Fabric Routed Port-Channel Interface List From Template # ------------------------------------------------------------------------ - name: Build External Fabric Routed Port-Channel Interface List From Template - ansible.builtin.import_tasks: common/ndfc_interface_po_routed.yml + ansible.builtin.include_tasks: common/ndfc_interface_po_routed.yml # ------------------------------------------------------------------------ # Build External Fabric Interface Routed List From Template # ------------------------------------------------------------------------ - name: Build External Fabric Interface Routed List From Template - ansible.builtin.import_tasks: common/ndfc_interface_routed.yml + ansible.builtin.include_tasks: common/ndfc_interface_routed.yml # ------------------------------------------------------------------------ # Build External Fabric Trunk Port-Channel Interfaces List From Template # ------------------------------------------------------------------------ - name: Build External Fabric Trunk Port-Channel Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_trunk_po.yml + ansible.builtin.include_tasks: common/ndfc_interface_trunk_po.yml # ------------------------------------------------------------------------ # Build External Fabric Trunk Interfaces List From Template # ------------------------------------------------------------------------ - name: Build External Fabric Trunk Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_trunk.yml + ansible.builtin.include_tasks: common/ndfc_interface_trunk.yml # ------------------------------------------------------------------------ # Build External Fabric vPC Interface List From Template # ------------------------------------------------------------------------ - name: Build External Fabric vPC Interface List From Template - ansible.builtin.import_tasks: common/ndfc_interface_vpc.yml + ansible.builtin.include_tasks: common/ndfc_interface_vpc.yml # ------------------------------------------------------------------------ # Build External Fabric Sub-Interface Routed List From Template # ------------------------------------------------------------------------ - name: Build External Fabric Sub-Interface Routed List From Template - ansible.builtin.import_tasks: common/ndfc_sub_interface_routed.yml + ansible.builtin.include_tasks: common/ndfc_sub_interface_routed.yml # ------------------------------------------------------------------------ # Build External Fabric Interface All List From Template # ------------------------------------------------------------------------ - name: Build External Fabric Interface All List From Template - ansible.builtin.import_tasks: common/ndfc_interface_all.yml + ansible.builtin.include_tasks: common/ndfc_interface_all.yml # ------------------------------------------------------------------------ # Build External Fabric Policy List From Template # ------------------------------------------------------------------------ - name: Build External Fabric Policy List From Template - ansible.builtin.import_tasks: common/ndfc_policy.yml + ansible.builtin.include_tasks: common/ndfc_policy.yml # ------------------------------------------------------------------------ # Build External Fabric Edge Connections List From Template # ------------------------------------------------------------------------ - name: Build External Fabric Edge Connections List From Template - ansible.builtin.import_tasks: common/ndfc_edge_connections.yml + ansible.builtin.include_tasks: common/ndfc_edge_connections.yml # ------------------------------------------------------------------------ # Save Local Variables To NameSpace Dict For Use Elsewhere diff --git a/roles/dtc/common/tasks/sub_main_isn.yml b/roles/dtc/common/tasks/sub_main_isn.yml index 0e58389de..55a023d50 100644 --- a/roles/dtc/common/tasks/sub_main_isn.yml +++ b/roles/dtc/common/tasks/sub_main_isn.yml @@ -36,7 +36,7 @@ delegate_to: localhost - name: Cleanup Files from Previous Run if run_map requires it - ansible.builtin.import_tasks: cleanup_files.yml + ansible.builtin.include_tasks: cleanup_files.yml when: - not run_map_read_result.diff_run or ((force_run_all is defined) and (force_run_all is true|bool)) @@ -45,124 +45,124 @@ # ------------------------------------------------------------------------ - name: Build ISN Fabric List From Template - ansible.builtin.import_tasks: common/ndfc_fabric.yml + ansible.builtin.include_tasks: common/ndfc_fabric.yml # ------------------------------------------------------------------------ # Build ISN Fabric Switch Inventory List From Template # ------------------------------------------------------------------------ - name: Build ISN Fabric Switch Inventory List From Template - ansible.builtin.import_tasks: common/ndfc_inventory.yml + ansible.builtin.include_tasks: common/ndfc_inventory.yml # We need to also build an inventory list without bootstrap settings # This will be used for device removal. - name: Build ISN Fabric Switch Inventory List From Template - No Bootstrap - ansible.builtin.import_tasks: common/ndfc_inventory_no_bootstrap.yml + ansible.builtin.include_tasks: common/ndfc_inventory_no_bootstrap.yml # ------------------------------------------------------------------------ # Build ISN Fabric Breakout Interfaces List From Template # ------------------------------------------------------------------------ - name: Build ISN Fabric Breakout Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_breakout.yml + ansible.builtin.include_tasks: common/ndfc_interface_breakout.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric PreProv Breakout Interfaces List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric Breakout PreProv Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_breakout_preprov.yml + ansible.builtin.include_tasks: common/ndfc_interface_breakout_preprov.yml # ------------------------------------------------------------------------ # Build ISN Fabric Loopback Interfaces List From Template # ------------------------------------------------------------------------ - name: Build ISN Fabric Loopback Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_loopback.yml + ansible.builtin.include_tasks: common/ndfc_interface_loopback.yml # ------------------------------------------------------------------------ # Build ISN Fabric Access Port-Channel Interfaces List From Template # ------------------------------------------------------------------------ - name: Build ISN Fabric Access Port-Channel Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_access_po.yml + ansible.builtin.include_tasks: common/ndfc_interface_access_po.yml # ------------------------------------------------------------------------ # Build ISN Fabric Trunk Port-Channel Interfaces List From Template # ------------------------------------------------------------------------ - name: Build ISN Fabric Trunk Port-Channel Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_trunk_po.yml + ansible.builtin.include_tasks: common/ndfc_interface_trunk_po.yml # ------------------------------------------------------------------------ # Build ISN Fabric Interface Routed List From Template # ------------------------------------------------------------------------ - name: Build ISN Fabric Interface Routed List From Template - ansible.builtin.import_tasks: common/ndfc_interface_routed.yml + ansible.builtin.include_tasks: common/ndfc_interface_routed.yml # ------------------------------------------------------------------------ # Build ISN Fabric Sub-Interface Routed List From Template # ------------------------------------------------------------------------ - name: Build ISN Fabric Sub-Interface Routed List From Template - ansible.builtin.import_tasks: common/ndfc_sub_interface_routed.yml + ansible.builtin.include_tasks: common/ndfc_sub_interface_routed.yml # ------------------------------------------------------------------------ # Build ISN Fabric Routed Port-Channel Interface List From Template # ------------------------------------------------------------------------ - name: Build ISN Fabric Routed Port-Channel Interface List From Template - ansible.builtin.import_tasks: common/ndfc_interface_po_routed.yml + ansible.builtin.include_tasks: common/ndfc_interface_po_routed.yml # ------------------------------------------------------------------------ # Build ISN Fabric Trunk Interfaces List From Template # ------------------------------------------------------------------------ - name: Build ISN Fabric Trunk Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_trunk.yml + ansible.builtin.include_tasks: common/ndfc_interface_trunk.yml # ------------------------------------------------------------------------ # Build ISN Fabric Access Interfaces List From Template # ------------------------------------------------------------------------ - name: Build ISN Fabric Access Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_access.yml + ansible.builtin.include_tasks: common/ndfc_interface_access.yml # ------------------------------------------------------------------------ # Build ISN Fabric Dot1q Interfaces List From Template # ------------------------------------------------------------------------ - name: Build ISN Fabric Dot1q Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_dot1q.yml + ansible.builtin.include_tasks: common/ndfc_interface_dot1q.yml # ------------------------------------------------------------------------ # Build ISN Fabric vPC Interface List From Template # ------------------------------------------------------------------------ - name: Build ISN Fabric vPC Interface List From Template - ansible.builtin.import_tasks: common/ndfc_interface_vpc.yml + ansible.builtin.include_tasks: common/ndfc_interface_vpc.yml # ------------------------------------------------------------------------ # Build ISN Fabric Interface All List From Template # ------------------------------------------------------------------------ - name: Build ISN Fabric Interface All List From Template - ansible.builtin.import_tasks: common/ndfc_interface_all.yml + ansible.builtin.include_tasks: common/ndfc_interface_all.yml # ------------------------------------------------------------------------ # Build ISN Fabric Policy List From Template # ------------------------------------------------------------------------ - name: Build ISN Fabric Policy List From Template - ansible.builtin.import_tasks: common/ndfc_policy.yml + ansible.builtin.include_tasks: common/ndfc_policy.yml # ------------------------------------------------------------------------ # Build ISN Edge Connections List From Template # ------------------------------------------------------------------------ - name: Build ISN Edge Connections List From Template - ansible.builtin.import_tasks: common/ndfc_edge_connections.yml + ansible.builtin.include_tasks: common/ndfc_edge_connections.yml # ------------------------------------------------------------------------ # Save Local Variables To NameSpace Dict For Use Elsewhere diff --git a/roles/dtc/common/tasks/sub_main_msd.yml b/roles/dtc/common/tasks/sub_main_msd.yml index f769273a1..5a45f258a 100644 --- a/roles/dtc/common/tasks/sub_main_msd.yml +++ b/roles/dtc/common/tasks/sub_main_msd.yml @@ -36,7 +36,7 @@ delegate_to: localhost - name: Cleanup Files from Previous Run if run_map requires it - ansible.builtin.import_tasks: cleanup_files.yml + ansible.builtin.include_tasks: cleanup_files.yml when: - not run_map_read_result.diff_run or ((force_run_all is defined) and (force_run_all is true|bool)) @@ -45,21 +45,21 @@ # ------------------------------------------------------------------------ - name: Build MSD Fabric List From Template - ansible.builtin.import_tasks: common/ndfc_fabric.yml + ansible.builtin.include_tasks: common/ndfc_fabric.yml # ------------------------------------------------------------------------ # Build MSD Child Fabric Inventory List From Template # ------------------------------------------------------------------------ - name: Build MSD Child Fabric Inventory List From Template - ansible.builtin.import_tasks: msd/ndfc_child_fabrics.yml + ansible.builtin.include_tasks: msd/ndfc_child_fabrics.yml # ------------------------------------------------------------------------ # Build NDFC Child Fabric BGW Anycast VIP List From Template # ------------------------------------------------------------------------ - name: Build MSD Child Fabric BGW Anycast VIP List From Template - ansible.builtin.import_tasks: msd/ndfc_bgw_anycast_vip.yml + ansible.builtin.include_tasks: msd/ndfc_bgw_anycast_vip.yml # ------------------------------------------------------------------------ # Save Local Variables To NameSpace Dict For Use Elsewhere diff --git a/roles/dtc/common/tasks/sub_main_vxlan.yml b/roles/dtc/common/tasks/sub_main_vxlan.yml index 3c704bee1..8b5665b78 100644 --- a/roles/dtc/common/tasks/sub_main_vxlan.yml +++ b/roles/dtc/common/tasks/sub_main_vxlan.yml @@ -36,7 +36,7 @@ delegate_to: localhost - name: Cleanup Files from Previous Run if run_map requires it - ansible.builtin.import_tasks: cleanup_files.yml + ansible.builtin.include_tasks: cleanup_files.yml when: - not run_map_read_result.diff_run or ((force_run_all is defined) and (force_run_all is true|bool)) @@ -45,173 +45,173 @@ # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric List From Template - ansible.builtin.import_tasks: common/ndfc_fabric.yml + ansible.builtin.include_tasks: common/ndfc_fabric.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric Switch Inventory List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric Switch Inventory List From Template - ansible.builtin.import_tasks: common/ndfc_inventory.yml + ansible.builtin.include_tasks: common/ndfc_inventory.yml # We need to also build an inventory list without bootstrap settings # This will be used for device removal. - name: Build iBGP VXLAN Fabric Switch Inventory List From Template - No Bootstrap - ansible.builtin.import_tasks: common/ndfc_inventory_no_bootstrap.yml + ansible.builtin.include_tasks: common/ndfc_inventory_no_bootstrap.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric vPC Domain ID Resource From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric vPC Domain ID Resource From Template - ansible.builtin.import_tasks: common/ndfc_vpc_domain_id_resource.yml + ansible.builtin.include_tasks: common/ndfc_vpc_domain_id_resource.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric Intra Links for vPC Peering From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric Intra Links for vPC Peering From Template - ansible.builtin.import_tasks: common/ndfc_vpc_fabric_peering_links.yml + ansible.builtin.include_tasks: common/ndfc_vpc_fabric_peering_links.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric vPC Peering Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric vPC Peering Template - ansible.builtin.import_tasks: common/ndfc_vpc_peering_pairs.yml + ansible.builtin.include_tasks: common/ndfc_vpc_peering_pairs.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric VRFs and Attach List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric VRFs and Attach List From Template - ansible.builtin.import_tasks: vxlan/ndfc_vrfs.yml + ansible.builtin.include_tasks: vxlan/ndfc_vrfs.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric Networks and Attach List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric Networks and Attach List From Template - ansible.builtin.import_tasks: vxlan/ndfc_networks.yml + ansible.builtin.include_tasks: vxlan/ndfc_networks.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric Breakout Interfaces List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric Breakout Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_breakout.yml + ansible.builtin.include_tasks: common/ndfc_interface_breakout.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric PreProv Breakout Interfaces List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric Breakout PreProv Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_breakout_preprov.yml + ansible.builtin.include_tasks: common/ndfc_interface_breakout_preprov.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric Loopback Interfaces List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric Loopback Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_loopback.yml + ansible.builtin.include_tasks: common/ndfc_interface_loopback.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric Access Port-Channel Interfaces List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric Access Port-Channel Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_access_po.yml + ansible.builtin.include_tasks: common/ndfc_interface_access_po.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric Trunk Port-Channel Interfaces List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric Trunk Port-Channel Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_trunk_po.yml + ansible.builtin.include_tasks: common/ndfc_interface_trunk_po.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric Interface Routed List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric Interface Routed List From Template - ansible.builtin.import_tasks: common/ndfc_interface_routed.yml + ansible.builtin.include_tasks: common/ndfc_interface_routed.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric Sub-Interface Routed List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric Sub-Interface Routed List From Template - ansible.builtin.import_tasks: common/ndfc_sub_interface_routed.yml + ansible.builtin.include_tasks: common/ndfc_sub_interface_routed.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric Routed Port-Channel Interface List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric Routed Port-Channel Interface List From Template - ansible.builtin.import_tasks: common/ndfc_interface_po_routed.yml + ansible.builtin.include_tasks: common/ndfc_interface_po_routed.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric Trunk Interfaces List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric Trunk Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_trunk.yml + ansible.builtin.include_tasks: common/ndfc_interface_trunk.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric Access Interfaces List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric Access Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_access.yml + ansible.builtin.include_tasks: common/ndfc_interface_access.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric Dot1q Interfaces List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric Dot1q Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_dot1q.yml + ansible.builtin.include_tasks: common/ndfc_interface_dot1q.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric vPC Interfaces List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric vPC Interfaces List From Template - ansible.builtin.import_tasks: common/ndfc_interface_vpc.yml + ansible.builtin.include_tasks: common/ndfc_interface_vpc.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric Interface All List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric Interface All List From Template - ansible.builtin.import_tasks: common/ndfc_interface_all.yml + ansible.builtin.include_tasks: common/ndfc_interface_all.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric Policy List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric Policy List From Template - ansible.builtin.import_tasks: common/ndfc_policy.yml + ansible.builtin.include_tasks: common/ndfc_policy.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric Links List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric Links List From Template - ansible.builtin.import_tasks: common/ndfc_fabric_links.yml + ansible.builtin.include_tasks: common/ndfc_fabric_links.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric Underlay Resources List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric Underlay Resources List From Template - ansible.builtin.import_tasks: common/ndfc_underlay_ip_address.yml + ansible.builtin.include_tasks: common/ndfc_underlay_ip_address.yml # ------------------------------------------------------------------------ # Build iBGP VXLAN Fabric Edge Connections List From Template # ------------------------------------------------------------------------ - name: Build iBGP VXLAN Fabric Edge Connections List From Template - ansible.builtin.import_tasks: common/ndfc_edge_connections.yml + ansible.builtin.include_tasks: common/ndfc_edge_connections.yml # ------------------------------------------------------------------------ # Save Local Variables To NameSpace Dict For Use Elsewhere diff --git a/roles/dtc/connectivity_check/tasks/main.yml b/roles/dtc/connectivity_check/tasks/main.yml index 5cc1c0399..3330dd6e6 100644 --- a/roles/dtc/connectivity_check/tasks/main.yml +++ b/roles/dtc/connectivity_check/tasks/main.yml @@ -21,12 +21,12 @@ --- -- name: Verify Connection to Nexus Dashboard - ansible.builtin.import_tasks: verify_ndfc_connectivity.yml - tags: "{{ nac_tags.connectivity_check }}" # Tags defined in roles/common_global/vars/main.yml +- block: + - name: Verify Connection to Nexus Dashboard + ansible.builtin.include_tasks: verify_ndfc_connectivity.yml -- name: Verify Authorization to Nexus Dashboard - ansible.builtin.import_tasks: verify_ndfc_authorization.yml + - name: Verify Authorization to Nexus Dashboard + ansible.builtin.include_tasks: verify_ndfc_authorization.yml tags: "{{ nac_tags.connectivity_check }}" # Tags defined in roles/common_global/vars/main.yml - name: Get Cisco Nexus Dashboard Version diff --git a/roles/dtc/create/tasks/common/devices.yml b/roles/dtc/create/tasks/common/devices.yml index ead6b9a8d..bbddb4432 100644 --- a/roles/dtc/create/tasks/common/devices.yml +++ b/roles/dtc/create/tasks/common/devices.yml @@ -29,4 +29,4 @@ - "----------------------------------------------------------------" - name: Manage Devices Discovery in Nexus Dashboard - ansible.builtin.import_tasks: devices_discovery.yml + ansible.builtin.include_tasks: devices_discovery.yml diff --git a/roles/dtc/create/tasks/main.yml b/roles/dtc/create/tasks/main.yml index 2b99ea444..1e8c99b9f 100644 --- a/roles/dtc/create/tasks/main.yml +++ b/roles/dtc/create/tasks/main.yml @@ -22,29 +22,29 @@ --- - name: Import iBGP VXLAN Fabric Role Tasks - ansible.builtin.import_tasks: sub_main_vxlan.yml + ansible.builtin.include_tasks: sub_main_vxlan.yml when: - MD_Extended.vxlan.fabric.type == 'VXLAN_EVPN' - change_flags.changes_detected_any - name: Import eBGP VXLAN Fabric Role Tasks - ansible.builtin.import_tasks: sub_main_ebgp_vxlan.yml + ansible.builtin.include_tasks: sub_main_ebgp_vxlan.yml when: - MD_Extended.vxlan.fabric.type == 'eBGP_VXLAN' - change_flags.changes_detected_any - name: Import ISN Fabric Role Tasks - ansible.builtin.import_tasks: sub_main_isn.yml + ansible.builtin.include_tasks: sub_main_isn.yml when: - MD_Extended.vxlan.fabric.type == 'ISN' - change_flags.changes_detected_any - name: Import MSD Fabric Role Tasks - ansible.builtin.import_tasks: sub_main_msd.yml + ansible.builtin.include_tasks: sub_main_msd.yml when: MD_Extended.vxlan.fabric.type == 'MSD' - name: Import External Fabric Role Tasks - ansible.builtin.import_tasks: sub_main_external.yml + ansible.builtin.include_tasks: sub_main_external.yml when: - MD_Extended.vxlan.fabric.type == 'External' - change_flags.changes_detected_any diff --git a/roles/dtc/create/tasks/msd/vrfs_networks.yml b/roles/dtc/create/tasks/msd/vrfs_networks.yml index e08e018a2..4f502da10 100644 --- a/roles/dtc/create/tasks/msd/vrfs_networks.yml +++ b/roles/dtc/create/tasks/msd/vrfs_networks.yml @@ -58,10 +58,10 @@ delegate_to: localhost - name: Run dtc.common.tasks.msd.ndfc_vrfs.yml - ansible.builtin.import_tasks: "{{ role_path }}/../common/tasks/msd/ndfc_vrfs.yml" + ansible.builtin.include_tasks: "{{ role_path }}/../common/tasks/msd/ndfc_vrfs.yml" - name: Run dtc.common.tasks.msd.ndfc_networks.yml - ansible.builtin.import_tasks: "{{ role_path }}/../common/tasks/msd/ndfc_networks.yml" + ansible.builtin.include_tasks: "{{ role_path }}/../common/tasks/msd/ndfc_networks.yml" # ---------------------------------------------------------------------------------- # Changes detected flags for Multisite VRF and Networks is set when the tasks above diff --git a/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml b/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml index a0f1fa613..bf9070af1 100644 --- a/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml +++ b/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml @@ -35,27 +35,33 @@ tags: "{{ nac_tags.create }}" - name: Create eBGP VXLAN Fabric in Nexus Dashboard - ansible.builtin.import_tasks: ebgp_vxlan/fabric.yml + ansible.builtin.include_tasks: + file: ebgp_vxlan/fabric.yml + apply: + tags: "{{ nac_tags.create_fabric }}" when: - MD_Extended.vxlan.fabric.name is defined - MD_Extended.vxlan.fabric.type == "eBGP_VXLAN" - MD_Extended.vxlan.global.ebgp is defined - change_flags.changes_detected_fabric - tags: "{{ nac_tags.create_fabric }}" - name: Manage eBGP VXLAN Fabric Switches in Nexus Dashboard - ansible.builtin.import_tasks: common/devices.yml + ansible.builtin.include_tasks: + file: common/devices.yml + apply: + tags: "{{ nac_tags.create_switches }}" when: - MD_Extended.vxlan.topology.switches | length > 0 - change_flags.changes_detected_inventory - tags: "{{ nac_tags.create_switches }}" - name: Manage eBGP VXLAN vPC Peering in Nexus Dashboard - ansible.builtin.import_tasks: common/vpc_peering.yml + ansible.builtin.include_tasks: + file: common/vpc_peering.yml + apply: + tags: "{{ nac_tags.create_vpc_peers }}" when: - MD_Extended.vxlan.topology.vpc_peers | length > 0 - change_flags.changes_detected_vpc_peering - tags: "{{ nac_tags.create_vpc_peers }}" - name: Config-Save Block to Propagate vPC Changes to eBGP VXLAN Fabric in Nexus Dashboard block: @@ -77,23 +83,29 @@ - change_flags.changes_detected_vpc_peering or change_flags.changes_detected_vpc_domain_id_resource - name: Manage eBGP VXLAN Fabric Interfaces in Nexus Dashboard - ansible.builtin.import_tasks: common/interfaces.yml + ansible.builtin.include_tasks: + file: common/interfaces.yml + apply: + tags: "{{ nac_tags.create_interfaces }}" when: - (MD_Extended.vxlan.topology.interfaces.modes.all.count >0) and (MD_Extended.vxlan.topology.switches | length > 0) - change_flags.changes_detected_interfaces - tags: "{{ nac_tags.create_interfaces }}" - name: Manage eBGP VXLAN Fabric VRFs and Networks in Nexus Dashboard - ansible.builtin.import_tasks: common_vxlan/vrfs_networks.yml + ansible.builtin.include_tasks: + file: common_vxlan/vrfs_networks.yml + apply: + tags: "{{ nac_tags.create_vrfs_networks }}" when: - MD_Extended.vxlan.overlay is defined - MD_Extended.vxlan.topology.switches | length > 0 - change_flags.changes_detected_vrfs or change_flags.changes_detected_networks - tags: "{{ nac_tags.create_vrfs_networks }}" - name: Manage eBGP VXLAN Fabric Policies in Nexus Dashboard - ansible.builtin.import_tasks: common/policies.yml + ansible.builtin.include_tasks: + file: common/policies.yml + apply: + tags: "{{ nac_tags.create_policy }}" when: - (MD_Extended.vxlan.policy is defined) and (MD_Extended.vxlan.policy.policies | length > 0) - change_flags.changes_detected_policy - tags: "{{ nac_tags.create_policy }}" diff --git a/roles/dtc/create/tasks/sub_main_external.yml b/roles/dtc/create/tasks/sub_main_external.yml index d223e4678..d030da6a6 100644 --- a/roles/dtc/create/tasks/sub_main_external.yml +++ b/roles/dtc/create/tasks/sub_main_external.yml @@ -35,46 +35,57 @@ tags: "{{ nac_tags.create }}" - name: Create External Fabric in Nexus Dashboard - ansible.builtin.import_tasks: external/fabric.yml + ansible.builtin.include_tasks: + file: external/fabric.yml + apply: + tags: "{{ nac_tags.create_fabric }}" when: - MD_Extended.vxlan.fabric.name is defined - MD_Extended.vxlan.fabric.type == "External" - MD_Extended.vxlan.global.external is defined - change_flags.changes_detected_fabric - tags: "{{ nac_tags.create_fabric }}" - name: Manage External Fabric Switches in Nexus Dashboard - ansible.builtin.import_tasks: common/devices.yml + ansible.builtin.include_tasks: + file: common/devices.yml + apply: + tags: "{{ nac_tags.create_switches }}" when: - MD_Extended.vxlan.topology.switches | length > 0 - change_flags.changes_detected_inventory - tags: "{{ nac_tags.create_switches }}" - name: Manage NDFC External VPC Peering - ansible.builtin.import_tasks: common/vpc_peering.yml + ansible.builtin.include_tasks: + file: common/vpc_peering.yml + apply: + tags: "{{ nac_tags.create_vpc_peers }}" when: - MD_Extended.vxlan.topology.vpc_peers | length > 0 - change_flags.changes_detected_vpc_peering - tags: "{{ nac_tags.create_vpc_peers }}" - - name: Manage External Fabric Inter Links in Nexus Dashboard - ansible.builtin.import_tasks: common/edge_connections.yml + ansible.builtin.include_tasks: + file: common/edge_connections.yml + apply: + tags: "{{ nac_tags.create_links }}" when: - MD_Extended.vxlan.topology.edge_connections | length > 0 - change_flags.changes_detected_edge_connections - tags: "{{ nac_tags.create_links }}" - name: Manage External Fabric Interfaces in Nexus Dashboard - ansible.builtin.import_tasks: common/interfaces.yml + ansible.builtin.include_tasks: + file: common/interfaces.yml + apply: + tags: "{{ nac_tags.create_interfaces }}" when: - (MD_Extended.vxlan.topology.interfaces.modes.all.count >0) and (MD_Extended.vxlan.topology.switches | length > 0) - change_flags.changes_detected_interfaces - tags: "{{ nac_tags.create_interfaces }}" - name: Manage External Fabric Policies in Nexus Dashboard - ansible.builtin.import_tasks: common/policies.yml + ansible.builtin.include_tasks: + file: common/policies.yml + apply: + tags: "{{ nac_tags.create_policy }}" when: - (MD_Extended.vxlan.policy is defined) and (MD_Extended.vxlan.policy.policies | length > 0) - change_flags.changes_detected_policy - tags: "{{ nac_tags.create_policy }}" diff --git a/roles/dtc/create/tasks/sub_main_isn.yml b/roles/dtc/create/tasks/sub_main_isn.yml index 24ae6af25..1e6964b36 100644 --- a/roles/dtc/create/tasks/sub_main_isn.yml +++ b/roles/dtc/create/tasks/sub_main_isn.yml @@ -35,38 +35,48 @@ tags: "{{ nac_tags.create }}" - name: Create ISN Fabric in Nexus Dashboard - ansible.builtin.import_tasks: common/fabric.yml + ansible.builtin.include_tasks: + file: common/fabric.yml + apply: + tags: "{{ nac_tags.create_fabric }}" when: - MD_Extended.vxlan.fabric.name is defined - MD_Extended.vxlan.fabric.type == "ISN" - MD_Extended.vxlan.multisite is defined - change_flags.changes_detected_fabric - tags: "{{ nac_tags.create_fabric }}" - name: Manage ISN Fabric Switches in Nexus Dashboard - ansible.builtin.import_tasks: common/devices.yml + ansible.builtin.include_tasks: + file: common/devices.yml + apply: + tags: "{{ nac_tags.create_switches }}" when: - MD_Extended.vxlan.topology.switches | length > 0 - change_flags.changes_detected_inventory - tags: "{{ nac_tags.create_switches }}" - name: Manage ISN Fabric Inter Links in Nexus Dashboard - ansible.builtin.import_tasks: common/edge_connections.yml + ansible.builtin.include_tasks: + file: common/edge_connections.yml + apply: + tags: "{{ nac_tags.create_links }}" when: - MD_Extended.vxlan.topology.edge_connections | length > 0 - change_flags.changes_detected_edge_connections - tags: "{{ nac_tags.create_links }}" - name: Manage ISN Fabric Interfaces in Nexus Dashboard - ansible.builtin.import_tasks: common/interfaces.yml + ansible.builtin.include_tasks: + file: common/interfaces.yml + apply: + tags: "{{ nac_tags.create_interfaces }}" when: - (MD_Extended.vxlan.topology.interfaces.modes.all.count >0) and (MD_Extended.vxlan.topology.switches | length > 0) - change_flags.changes_detected_interfaces - tags: "{{ nac_tags.create_interfaces }}" - name: Manage ISN Fabric Policies in Nexus Dashboard - ansible.builtin.import_tasks: common/policies.yml + ansible.builtin.include_tasks: + file: common/policies.yml + apply: + tags: "{{ nac_tags.create_policy }}" when: - (MD_Extended.vxlan.policy is defined) and (MD_Extended.vxlan.policy.policies | length > 0) - change_flags.changes_detected_policy - tags: "{{ nac_tags.create_policy }}" diff --git a/roles/dtc/create/tasks/sub_main_msd.yml b/roles/dtc/create/tasks/sub_main_msd.yml index 6515ceecf..875f37ef1 100644 --- a/roles/dtc/create/tasks/sub_main_msd.yml +++ b/roles/dtc/create/tasks/sub_main_msd.yml @@ -35,15 +35,17 @@ tags: "{{ nac_tags.create }}" - name: Create MSD Fabric in Nexus Dashboard - ansible.builtin.import_tasks: common/fabric.yml + ansible.builtin.include_tasks: + file: common/fabric.yml + apply: + tags: "{{ nac_tags.create_fabric }}" when: - MD_Extended.vxlan.fabric.name is defined - MD_Extended.vxlan.fabric.type == "MSD" - change_flags.changes_detected_fabric - tags: "{{ nac_tags.create_fabric }}" - name: Manage MSD Fabric Child Fabrics in Nexus Dashboard - ansible.builtin.import_tasks: msd/child_fabrics.yml + ansible.builtin.include_tasks: msd/child_fabrics.yml when: - MD_Extended.vxlan.multisite.child_fabrics is defined and MD_Extended.vxlan.multisite.child_fabrics | length > 0 @@ -72,8 +74,10 @@ - change_flags.changes_detected_bgw_anycast_vip - name: Manage MSD Fabric VRFs and Networks in Nexus Dashboard - ansible.builtin.import_tasks: msd/vrfs_networks.yml + ansible.builtin.include_tasks: + file: msd/vrfs_networks.yml + apply: + tags: "{{ nac_tags.create_vrfs_networks }}" when: - MD_Extended.vxlan.multisite.overlay is defined - MD_Extended.vxlan.multisite.overlay - tags: "{{ nac_tags.create_vrfs_networks }}" diff --git a/roles/dtc/create/tasks/sub_main_vxlan.yml b/roles/dtc/create/tasks/sub_main_vxlan.yml index a604a0a16..b2ad59649 100644 --- a/roles/dtc/create/tasks/sub_main_vxlan.yml +++ b/roles/dtc/create/tasks/sub_main_vxlan.yml @@ -35,27 +35,33 @@ tags: "{{ nac_tags.create }}" - name: Create iBGP VXLAN Fabric in Nexus Dashboard - ansible.builtin.import_tasks: common/fabric.yml + ansible.builtin.include_tasks: + file: common/fabric.yml + apply: + tags: "{{ nac_tags.create_fabric }}" when: - MD_Extended.vxlan.fabric.name is defined - MD_Extended.vxlan.fabric.type == "VXLAN_EVPN" - MD_Extended.vxlan.global.ibgp is defined - change_flags.changes_detected_fabric - tags: "{{ nac_tags.create_fabric }}" - name: Manage iBGP VXLAN Fabric Switches in Nexus Dashboard - ansible.builtin.import_tasks: common/devices.yml + ansible.builtin.include_tasks: + file: common/devices.yml + apply: + tags: "{{ nac_tags.create_switches }}" when: - MD_Extended.vxlan.topology.switches | length > 0 - change_flags.changes_detected_inventory or change_flags.changes_detected_underlay_ip_address - tags: "{{ nac_tags.create_switches }}" - name: Manage iBGP VXLAN vPC Peering in Nexus Dashboard - ansible.builtin.import_tasks: common/vpc_peering.yml + ansible.builtin.include_tasks: + file: common/vpc_peering.yml + apply: + tags: "{{ nac_tags.create_vpc_peers }}" when: - MD_Extended.vxlan.topology.vpc_peers | length > 0 - change_flags.changes_detected_vpc_peering or change_flags.changes_detected_vpc_domain_id_resource - tags: "{{ nac_tags.create_vpc_peers }}" - name: Config-Save Block to Propagate vPC Changes to iBGP VXLAN Fabric in Nexus Dashboard block: @@ -78,37 +84,47 @@ - change_flags.changes_detected_vpc_peering or change_flags.changes_detected_vpc_domain_id_resource - name: Manage iBGP VXLAN Fabric Interfaces in Nexus Dashboard - ansible.builtin.import_tasks: common/interfaces.yml + ansible.builtin.include_tasks: + file: common/interfaces.yml + apply: + tags: "{{ nac_tags.create_interfaces }}" when: - (MD_Extended.vxlan.topology.interfaces.modes.all.count >0) and (MD_Extended.vxlan.topology.switches | length > 0) - change_flags.changes_detected_interfaces - tags: "{{ nac_tags.create_interfaces }}" - name: Manage iBGP VXLAN Fabric Inter Links in Nexus Dashboard - ansible.builtin.import_tasks: common/edge_connections.yml + ansible.builtin.include_tasks: + file: common/edge_connections.yml + apply: + tags: "{{ nac_tags.create_links }}" when: - MD_Extended.vxlan.topology.edge_connections | length > 0 - change_flags.changes_detected_edge_connections - tags: "{{ nac_tags.create_links }}" - name: Manage iBGP VXLAN Fabric VRFs and Networks in Nexus Dashboard - ansible.builtin.import_tasks: common_vxlan/vrfs_networks.yml + ansible.builtin.include_tasks: + file: common_vxlan/vrfs_networks.yml + apply: + tags: "{{ nac_tags.create_vrfs_networks }}" when: - MD_Extended.vxlan.overlay is defined - MD_Extended.vxlan.topology.switches | length > 0 - change_flags.changes_detected_vrfs or change_flags.changes_detected_networks - tags: "{{ nac_tags.create_vrfs_networks }}" - name: Manage iBGP VXLAN Fabric Intra Links in Nexus Dashboard - ansible.builtin.import_tasks: common/links.yml + ansible.builtin.include_tasks: + file: common/links.yml + apply: + tags: "{{ nac_tags.create_links }}" when: - MD_Extended.vxlan.topology.fabric_links | length > 0 - change_flags.changes_detected_fabric_links - tags: "{{ nac_tags.create_links }}" - name: Manage iBGP VXLAN Fabric Policies in Nexus Dashboard - ansible.builtin.import_tasks: common/policies.yml + ansible.builtin.include_tasks: + file: common/policies.yml + apply: + tags: "{{ nac_tags.create_policy }}" when: - (MD_Extended.vxlan.policy is defined) and (MD_Extended.vxlan.policy.policies | length > 0) - change_flags.changes_detected_policy - tags: "{{ nac_tags.create_policy }}" diff --git a/roles/dtc/deploy/tasks/main.yml b/roles/dtc/deploy/tasks/main.yml index 14ee51d69..bd90de7fa 100644 --- a/roles/dtc/deploy/tasks/main.yml +++ b/roles/dtc/deploy/tasks/main.yml @@ -21,41 +21,38 @@ --- -- name: Import iBGP VXLAN EVPN Role Tasks - ansible.builtin.import_tasks: sub_main_vxlan.yml - tags: "{{ nac_tags.deploy }}" # Tags defined in roles/common_global/vars/main.yml - when: - - MD_Extended.vxlan.fabric.type == 'VXLAN_EVPN' - - change_flags.changes_detected_any +- block: + - name: Import iBGP VXLAN EVPN Role Tasks + ansible.builtin.include_tasks: sub_main_vxlan.yml + when: + - MD_Extended.vxlan.fabric.type == 'VXLAN_EVPN' + - change_flags.changes_detected_any -- name: Import MSD Fabric Role Tasks - ansible.builtin.import_tasks: sub_main_msd.yml - tags: "{{ nac_tags.deploy }}" - when: > - (MD_Extended.vxlan.fabric.type == 'MSD') and - (change_flags.changes_detected_any or - (child_fabrics_vrfs_networks_changed is defined and child_fabrics_vrfs_networks_changed | length > 0)) + - name: Import MSD Fabric Role Tasks + ansible.builtin.include_tasks: sub_main_msd.yml + when: > + (MD_Extended.vxlan.fabric.type == 'MSD') and + (change_flags.changes_detected_any or + (child_fabrics_vrfs_networks_changed is defined and child_fabrics_vrfs_networks_changed | length > 0)) -- name: Import ISN Fabric Role Tasks - ansible.builtin.import_tasks: sub_main_isn.yml - tags: "{{ nac_tags.deploy }}" - when: - - MD_Extended.vxlan.fabric.type == 'ISN' - - change_flags.changes_detected_any + - name: Import ISN Fabric Role Tasks + ansible.builtin.include_tasks: sub_main_isn.yml + when: + - MD_Extended.vxlan.fabric.type == 'ISN' + - change_flags.changes_detected_any -- name: Import External Fabric Role Tasks - ansible.builtin.import_tasks: sub_main_external.yml - tags: "{{ nac_tags.deploy }}" - when: - - MD_Extended.vxlan.fabric.type == 'External' - - change_flags.changes_detected_any + - name: Import External Fabric Role Tasks + ansible.builtin.include_tasks: sub_main_external.yml + when: + - MD_Extended.vxlan.fabric.type == 'External' + - change_flags.changes_detected_any -- name: Import Role Tasks - ansible.builtin.import_tasks: sub_main_ebgp_vxlan.yml + - name: Import Role Tasks + ansible.builtin.include_tasks: sub_main_ebgp_vxlan.yml + when: + - MD_Extended.vxlan.fabric.type == 'eBGP_VXLAN' + - change_flags.changes_detected_any tags: "{{ nac_tags.deploy }}" - when: - - MD_Extended.vxlan.fabric.type == 'eBGP_VXLAN' - - change_flags.changes_detected_any - name: Mark Stage Role Deploy Completed cisco.nac_dc_vxlan.common.run_map: diff --git a/roles/dtc/remove/tasks/main.yml b/roles/dtc/remove/tasks/main.yml index db39ca2f0..bbf8951ea 100644 --- a/roles/dtc/remove/tasks/main.yml +++ b/roles/dtc/remove/tasks/main.yml @@ -22,7 +22,7 @@ --- - name: Import iBGP VXLAN Fabric Role Tasks - ansible.builtin.import_tasks: sub_main_vxlan.yml + ansible.builtin.include_tasks: sub_main_vxlan.yml # Check with Matt on changes_detected_policy here # Was not there previously when: @@ -30,26 +30,26 @@ - change_flags.changes_detected_any - name: Import MSD Fabric Role Tasks - ansible.builtin.import_tasks: sub_main_msd.yml + ansible.builtin.include_tasks: sub_main_msd.yml when: MD_Extended.vxlan.fabric.type == 'MSD' # Current implementation has to leverage the changes_detected flags # in the sub_main files to determine if the tasks should be run - name: Import ISN Fabric Role Tasks - ansible.builtin.import_tasks: sub_main_isn.yml + ansible.builtin.include_tasks: sub_main_isn.yml when: - MD_Extended.vxlan.fabric.type == 'ISN' - change_flags.changes_detected_any - name: Import External Fabric Role Tasks - ansible.builtin.import_tasks: sub_main_external.yml + ansible.builtin.include_tasks: sub_main_external.yml when: - MD_Extended.vxlan.fabric.type == 'External' - change_flags.changes_detected_any - name: Import eBGP Role Tasks - ansible.builtin.import_tasks: sub_main_ebgp_vxlan.yml + ansible.builtin.include_tasks: sub_main_ebgp_vxlan.yml # Check with Matt on changes_detected_policy here # Was not there previously when: diff --git a/roles/dtc/remove/tasks/sub_main_ebgp_vxlan.yml b/roles/dtc/remove/tasks/sub_main_ebgp_vxlan.yml index ef0088fb4..ac10d0ddd 100644 --- a/roles/dtc/remove/tasks/sub_main_ebgp_vxlan.yml +++ b/roles/dtc/remove/tasks/sub_main_ebgp_vxlan.yml @@ -41,37 +41,49 @@ tags: "{{ nac_tags.remove }}" - name: Remove eBGP VXLAN Fabric vPC Peering - ansible.builtin.import_tasks: common/vpc_peers.yml - tags: "{{ nac_tags.remove_vpc_peers }}" + ansible.builtin.include_tasks: + file: common/vpc_peers.yml + apply: + tags: "{{ nac_tags.remove_vpc_peers }}" when: - change_flags.changes_detected_vpc_peering - name: Remove eBGP VXLAN Fabric Policy from Nexus Dashboard - ansible.builtin.import_tasks: common/policy.yml - tags: "{{ nac_tags.remove_policy }}" + ansible.builtin.include_tasks: + file: common/policy.yml + apply: + tags: "{{ nac_tags.remove_policy }}" when: - change_flags.changes_detected_policy - name: Remove eBGP VXLAN Fabric Interfaces from Nexus Dashboard - ansible.builtin.import_tasks: common/interfaces.yml - tags: "{{ nac_tags.remove_interfaces }}" + ansible.builtin.include_tasks: + file: common/interfaces.yml + apply: + tags: "{{ nac_tags.remove_interfaces }}" when: - change_flags.changes_detected_interfaces - name: Remove eBGP VXLAN Fabric Networks from Nexus Dashboard - ansible.builtin.import_tasks: common_vxlan/networks.yml - tags: "{{ nac_tags.remove_networks }}" + ansible.builtin.include_tasks: + file: common_vxlan/networks.yml + apply: + tags: "{{ nac_tags.remove_networks }}" when: - change_flags.changes_detected_networks - name: Remove eBGP VXLAN Fabric VRFs from Nexus Dashboard - ansible.builtin.import_tasks: common_vxlan/vrfs.yml - tags: "{{ nac_tags.remove_vrfs }}" + ansible.builtin.include_tasks: + file: common_vxlan/vrfs.yml + apply: + tags: "{{ nac_tags.remove_vrfs }}" when: - change_flags.changes_detected_vrfs - name: Remove eBGP VXLAN Fabric Switches from Nexus Dashboard - ansible.builtin.import_tasks: common/switches.yml - tags: "{{ nac_tags.remove_switches }}" + ansible.builtin.include_tasks: + file: common/switches.yml + apply: + tags: "{{ nac_tags.remove_switches }}" when: - change_flags.changes_detected_inventory diff --git a/roles/dtc/remove/tasks/sub_main_external.yml b/roles/dtc/remove/tasks/sub_main_external.yml index a6c7f903a..87bea7e5c 100644 --- a/roles/dtc/remove/tasks/sub_main_external.yml +++ b/roles/dtc/remove/tasks/sub_main_external.yml @@ -41,31 +41,41 @@ tags: "{{ nac_tags.remove }}" - name: Remove External Fabric Edge Connections from Nexus Dashboard - ansible.builtin.import_tasks: common/edge_connections.yml - tags: "{{ nac_tags.remove_edge_connections }}" + ansible.builtin.include_tasks: + file: common/edge_connections.yml + apply: + tags: "{{ nac_tags.remove_edge_connections }}" when: - change_flags.changes_detected_edge_connections - name: Remove External Fabric Policy from Nexus Dashboard - ansible.builtin.import_tasks: common/policy.yml - tags: "{{ nac_tags.remove_policy }}" + ansible.builtin.include_tasks: + file: common/policy.yml + apply: + tags: "{{ nac_tags.remove_policy }}" when: - change_flags.changes_detected_policy - name: Remove External Fabric Interfaces from Nexus Dashboard - ansible.builtin.import_tasks: common/interfaces.yml - tags: "{{ nac_tags.remove_interfaces }}" + ansible.builtin.include_tasks: + file: common/interfaces.yml + apply: + tags: "{{ nac_tags.remove_interfaces }}" when: - change_flags.changes_detected_interfaces - name: Remove External Fabric vPC Peering from Nexus Dashboard - ansible.builtin.import_tasks: common/vpc_peers.yml - tags: "{{ nac_tags.remove_vpc_peers }}" + ansible.builtin.include_tasks: + file: common/vpc_peers.yml + apply: + tags: "{{ nac_tags.remove_vpc_peers }}" when: - change_flags.changes_detected_vpc_peering - name: Remove External Fabric Switches from Nexus Dashboard - ansible.builtin.import_tasks: common/switches.yml - tags: "{{ nac_tags.remove_switches }}" + ansible.builtin.include_tasks: + file: common/switches.yml + apply: + tags: "{{ nac_tags.remove_switches }}" when: - change_flags.changes_detected_inventory diff --git a/roles/dtc/remove/tasks/sub_main_isn.yml b/roles/dtc/remove/tasks/sub_main_isn.yml index 8f70c2a3b..3d6afc9aa 100644 --- a/roles/dtc/remove/tasks/sub_main_isn.yml +++ b/roles/dtc/remove/tasks/sub_main_isn.yml @@ -41,25 +41,33 @@ tags: "{{ nac_tags.remove }}" - name: Remove ISN Fabric Edge Connections from Nexus Dashboard - ansible.builtin.import_tasks: common/edge_connections.yml - tags: "{{ nac_tags.remove_edge_connections }}" + ansible.builtin.include_tasks: + file: common/edge_connections.yml + apply: + tags: "{{ nac_tags.remove_edge_connections }}" when: - change_flags.changes_detected_edge_connections - name: Remove ISN Fabric Policy from Nexus Dashboard - ansible.builtin.import_tasks: common/policy.yml - tags: "{{ nac_tags.remove_policy }}" + ansible.builtin.include_tasks: + file: common/policy.yml + apply: + tags: "{{ nac_tags.remove_policy }}" when: - change_flags.changes_detected_policy - name: Remove ISN Fabric Interfaces from Nexus Dashboard - ansible.builtin.import_tasks: common/interfaces.yml - tags: "{{ nac_tags.remove_interfaces }}" + ansible.builtin.include_tasks: + file: common/interfaces.yml + apply: + tags: "{{ nac_tags.remove_interfaces }}" when: - change_flags.changes_detected_interfaces - name: Remove ISN Fabric Switches from Nexus Dashboard - ansible.builtin.import_tasks: common/switches.yml - tags: "{{ nac_tags.remove_switches }}" + ansible.builtin.include_tasks: + file: common/switches.yml + apply: + tags: "{{ nac_tags.remove_switches }}" when: - change_flags.changes_detected_inventory diff --git a/roles/dtc/remove/tasks/sub_main_msd.yml b/roles/dtc/remove/tasks/sub_main_msd.yml index 5e31e7ac1..01fc9c70c 100644 --- a/roles/dtc/remove/tasks/sub_main_msd.yml +++ b/roles/dtc/remove/tasks/sub_main_msd.yml @@ -44,18 +44,22 @@ # ------------------------------------------------------------------------------------- # There is an issue in Ansible were data that is needed to remove the networks and -# vrfs gets overwritten by the import_tasks from common. To get around this +# vrfs gets overwritten by the include_tasks from common. To get around this # issue we include the tasks to remove networks and vrfs here WHEN the create role # has already been run. # ------------------------------------------------------------------------------------- - name: Remove MSD Fabric Networks from Nexus Dashboard - ansible.builtin.import_tasks: msd/networks.yml - tags: "{{ nac_tags.remove_networks }}" + ansible.builtin.include_tasks: + file: msd/networks.yml + apply: + tags: "{{ nac_tags.remove_networks }}" when: run_map.updated.role_create_completed is true|bool - name: Remove MSD Fabric VRFs from Nexus Dashboard - ansible.builtin.import_tasks: msd/vrfs.yml - tags: "{{ nac_tags.remove_vrfs }}" + ansible.builtin.include_tasks: + file: msd/vrfs.yml + apply: + tags: "{{ nac_tags.remove_vrfs }}" when: run_map.updated.role_create_completed is true|bool # ------------------------------------------------------------------------------------- @@ -69,11 +73,11 @@ when: run_map.updated.role_create_completed is false|bool - name: Run dtc.common.tasks.msd.ndfc_vrfs.yml - ansible.builtin.import_tasks: "{{ role_path }}/../common/tasks/msd/ndfc_vrfs.yml" + ansible.builtin.include_tasks: "{{ role_path }}/../common/tasks/msd/ndfc_vrfs.yml" when: run_map.updated.role_create_completed is false|bool - name: Run dtc.common.tasks.msd.ndfc_networks.yml - ansible.builtin.import_tasks: "{{ role_path }}/../common/tasks/msd/ndfc_networks.yml" + ansible.builtin.include_tasks: "{{ role_path }}/../common/tasks/msd/ndfc_networks.yml" when: run_map.updated.role_create_completed is false|bool # ---------------------------------------------------------------------------------- @@ -104,14 +108,18 @@ # create role did NOT run # ------------------------------------------------------------------------------------- - name: Remove MSD Fabric Networks from Nexus Dashboard - ansible.builtin.import_tasks: msd/networks.yml - tags: "{{ nac_tags.remove_networks }}" + ansible.builtin.include_tasks: + file: msd/networks.yml + apply: + tags: "{{ nac_tags.remove_networks }}" when: run_map.updated.role_create_completed is false|bool - name: Remove MSD Fabric VRFs from Nexus Dashboard - ansible.builtin.import_tasks: msd/vrfs.yml - tags: "{{ nac_tags.remove_vrfs }}" + ansible.builtin.include_tasks: + file: msd/vrfs.yml + apply: + tags: "{{ nac_tags.remove_vrfs }}" when: run_map.updated.role_create_completed is false|bool - name: Remove MSD Fabric Child Fabrics from Nexus Dashboard - ansible.builtin.import_tasks: msd/child_fabrics.yml + ansible.builtin.include_tasks: msd/child_fabrics.yml diff --git a/roles/dtc/remove/tasks/sub_main_vxlan.yml b/roles/dtc/remove/tasks/sub_main_vxlan.yml index de6ab058f..e44d246e5 100644 --- a/roles/dtc/remove/tasks/sub_main_vxlan.yml +++ b/roles/dtc/remove/tasks/sub_main_vxlan.yml @@ -41,49 +41,65 @@ tags: "{{ nac_tags.remove }}" - name: Remove iBGP VXLAN Fabric Edge Connections from Nexus Dashboard - ansible.builtin.import_tasks: common/edge_connections.yml - tags: "{{ nac_tags.remove_edge_connections }}" + ansible.builtin.include_tasks: + file: common/edge_connections.yml + apply: + tags: "{{ nac_tags.remove_edge_connections }}" when: - change_flags.changes_detected_edge_connections - name: Remove iBGP VXLAN Fabric Policy from Nexus Dashboard - ansible.builtin.import_tasks: common/policy.yml - tags: "{{ nac_tags.remove_policy }}" + ansible.builtin.include_tasks: + file: common/policy.yml + apply: + tags: "{{ nac_tags.remove_policy }}" when: - change_flags.changes_detected_policy - name: Remove iBGP VXLAN Fabric Interfaces from Nexus Dashboard - ansible.builtin.import_tasks: common/interfaces.yml - tags: "{{ nac_tags.remove_interfaces }}" + ansible.builtin.include_tasks: + file: common/interfaces.yml + apply: + tags: "{{ nac_tags.remove_interfaces }}" when: - change_flags.changes_detected_interfaces - name: Remove iBGP VXLAN Fabric Networks from Nexus Dashboard - ansible.builtin.import_tasks: common_vxlan/networks.yml - tags: "{{ nac_tags.remove_networks }}" + ansible.builtin.include_tasks: + file: common_vxlan/networks.yml + apply: + tags: "{{ nac_tags.remove_networks }}" when: - change_flags.changes_detected_networks - name: Remove iBGP VXLAN Fabric VRFs from Nexus Dashboard - ansible.builtin.import_tasks: common_vxlan/vrfs.yml - tags: "{{ nac_tags.remove_vrfs }}" + ansible.builtin.include_tasks: + file: common_vxlan/vrfs.yml + apply: + tags: "{{ nac_tags.remove_vrfs }}" when: - change_flags.changes_detected_vrfs - name: Remove iBGP VXLAN Fabric Links from Nexus Dashboard - ansible.builtin.import_tasks: common/links.yml - tags: "{{ nac_tags.remove_links }}" + ansible.builtin.include_tasks: + file: common/links.yml + apply: + tags: "{{ nac_tags.remove_links }}" when: - change_flags.changes_detected_fabric_links - name: Remove iBGP VXLAN Fabric vPC Peering from Nexus Dashboard - ansible.builtin.import_tasks: common/vpc_peers.yml - tags: "{{ nac_tags.remove_vpc_peers }}" + ansible.builtin.include_tasks: + file: common/vpc_peers.yml + apply: + tags: "{{ nac_tags.remove_vpc_peers }}" when: - change_flags.changes_detected_vpc_peering - name: Remove iBGP VXLAN Fabric Switches from Nexus Dashboard - ansible.builtin.import_tasks: common/switches.yml - tags: "{{ nac_tags.remove_switches }}" + ansible.builtin.include_tasks: + file: common/switches.yml + apply: + tags: "{{ nac_tags.remove_switches }}" when: - change_flags.changes_detected_inventory diff --git a/roles/validate/tasks/main.yml b/roles/validate/tasks/main.yml index e112592e8..79f7dca35 100644 --- a/roles/validate/tasks/main.yml +++ b/roles/validate/tasks/main.yml @@ -21,8 +21,11 @@ --- - name: Import Role Tasks - ansible.builtin.import_tasks: sub_main.yml - tags: "{{ nac_tags.validate_role }}" # Tags defined in roles/common_global/vars/main.yml + ansible.builtin.include_tasks: + file: sub_main.yml + apply: + tags: "{{ nac_tags.validate_role }}" # Tags defined in roles/common_global/vars/main.yml + # Problems with lower versions of python and ansible # Python 3.9.16 and Ansible 7.3.0 (Ansible-Core 2.14.4) # Could ignore errors and try again with tags specified as below as a work around ... diff --git a/roles/validate/tasks/manage_model_files_current.yml b/roles/validate/tasks/manage_model_files_current.yml index 4c152fee9..55f02345f 100644 --- a/roles/validate/tasks/manage_model_files_current.yml +++ b/roles/validate/tasks/manage_model_files_current.yml @@ -87,7 +87,6 @@ # Remove all files from the previous run if force_run_all is true # ------------------------------------------------------------------------ - name: Cleanup Files from Previous Run if run_map requires it - ansible.builtin.import_tasks: cleanup_model_files.yml + ansible.builtin.include_tasks: cleanup_model_files.yml when: - ((force_run_all is defined) and (force_run_all is true|bool)) - delegate_to: localhost diff --git a/roles/validate/tasks/sub_main.yml b/roles/validate/tasks/sub_main.yml index c83f72955..0e117b0de 100644 --- a/roles/validate/tasks/sub_main.yml +++ b/roles/validate/tasks/sub_main.yml @@ -148,9 +148,9 @@ delegate_to: localhost - name: Manage Previous Service Model Data Files - ansible.builtin.import_tasks: manage_model_files_previous.yml + ansible.builtin.include_tasks: manage_model_files_previous.yml when: check_roles['save_previous'] - name: Manage Current Service Model Data Files - ansible.builtin.import_tasks: manage_model_files_current.yml + ansible.builtin.include_tasks: manage_model_files_current.yml when: check_roles['save_previous'] From ecf378c79ad896bc13f34781747f8260717de7c0 Mon Sep 17 00:00:00 2001 From: mwiebe Date: Wed, 15 Oct 2025 19:27:45 -0400 Subject: [PATCH 64/65] Fix validate role --- roles/validate/tasks/main.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/roles/validate/tasks/main.yml b/roles/validate/tasks/main.yml index 79f7dca35..84a1e6d03 100644 --- a/roles/validate/tasks/main.yml +++ b/roles/validate/tasks/main.yml @@ -20,11 +20,10 @@ # SPDX-License-Identifier: MIT --- -- name: Import Role Tasks - ansible.builtin.include_tasks: - file: sub_main.yml - apply: - tags: "{{ nac_tags.validate_role }}" # Tags defined in roles/common_global/vars/main.yml +- block: + - name: Import Role Tasks + ansible.builtin.include_tasks: sub_main.yml + tags: "{{ nac_tags.validate_role }}" # Tags defined in roles/common_global/vars/main.yml # Problems with lower versions of python and ansible # Python 3.9.16 and Ansible 7.3.0 (Ansible-Core 2.14.4) From 212c4166632d77bcdd6bad5c409ddcb31d15c17a Mon Sep 17 00:00:00 2001 From: ccoueffe Date: Fri, 17 Oct 2025 14:06:43 +0200 Subject: [PATCH 65/65] add tags Signed-off-by: ccoueffe --- roles/dtc/create/tasks/main.yml | 5 +++++ roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml | 6 ++++++ roles/dtc/create/tasks/sub_main_external.yml | 6 ++++++ roles/dtc/create/tasks/sub_main_isn.yml | 5 +++++ roles/dtc/create/tasks/sub_main_msd.yml | 2 ++ roles/dtc/create/tasks/sub_main_vxlan.yml | 8 ++++++++ 6 files changed, 32 insertions(+) diff --git a/roles/dtc/create/tasks/main.yml b/roles/dtc/create/tasks/main.yml index 1e8c99b9f..e0b35a666 100644 --- a/roles/dtc/create/tasks/main.yml +++ b/roles/dtc/create/tasks/main.yml @@ -22,28 +22,33 @@ --- - name: Import iBGP VXLAN Fabric Role Tasks + tags: "{{ nac_tags.create }}" ansible.builtin.include_tasks: sub_main_vxlan.yml when: - MD_Extended.vxlan.fabric.type == 'VXLAN_EVPN' - change_flags.changes_detected_any - name: Import eBGP VXLAN Fabric Role Tasks + tags: "{{ nac_tags.create }}" ansible.builtin.include_tasks: sub_main_ebgp_vxlan.yml when: - MD_Extended.vxlan.fabric.type == 'eBGP_VXLAN' - change_flags.changes_detected_any - name: Import ISN Fabric Role Tasks + tags: "{{ nac_tags.create }}" ansible.builtin.include_tasks: sub_main_isn.yml when: - MD_Extended.vxlan.fabric.type == 'ISN' - change_flags.changes_detected_any - name: Import MSD Fabric Role Tasks + tags: "{{ nac_tags.create }}" ansible.builtin.include_tasks: sub_main_msd.yml when: MD_Extended.vxlan.fabric.type == 'MSD' - name: Import External Fabric Role Tasks + tags: "{{ nac_tags.create }}" ansible.builtin.include_tasks: sub_main_external.yml when: - MD_Extended.vxlan.fabric.type == 'External' diff --git a/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml b/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml index bf9070af1..d1d8e9bf0 100644 --- a/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml +++ b/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml @@ -35,6 +35,7 @@ tags: "{{ nac_tags.create }}" - name: Create eBGP VXLAN Fabric in Nexus Dashboard + tags: "{{ nac_tags.create_fabric }}" ansible.builtin.include_tasks: file: ebgp_vxlan/fabric.yml apply: @@ -46,6 +47,7 @@ - change_flags.changes_detected_fabric - name: Manage eBGP VXLAN Fabric Switches in Nexus Dashboard + tags: "{{ nac_tags.create_switches }}" ansible.builtin.include_tasks: file: common/devices.yml apply: @@ -55,6 +57,7 @@ - change_flags.changes_detected_inventory - name: Manage eBGP VXLAN vPC Peering in Nexus Dashboard + tags: "{{ nac_tags.create_vpc_peers }}" ansible.builtin.include_tasks: file: common/vpc_peering.yml apply: @@ -83,6 +86,7 @@ - change_flags.changes_detected_vpc_peering or change_flags.changes_detected_vpc_domain_id_resource - name: Manage eBGP VXLAN Fabric Interfaces in Nexus Dashboard + tags: "{{ nac_tags.create_interfaces }}" ansible.builtin.include_tasks: file: common/interfaces.yml apply: @@ -92,6 +96,7 @@ - change_flags.changes_detected_interfaces - name: Manage eBGP VXLAN Fabric VRFs and Networks in Nexus Dashboard + tags: "{{ nac_tags.create_vrfs_networks }}" ansible.builtin.include_tasks: file: common_vxlan/vrfs_networks.yml apply: @@ -102,6 +107,7 @@ - change_flags.changes_detected_vrfs or change_flags.changes_detected_networks - name: Manage eBGP VXLAN Fabric Policies in Nexus Dashboard + tags: "{{ nac_tags.create_policy }}" ansible.builtin.include_tasks: file: common/policies.yml apply: diff --git a/roles/dtc/create/tasks/sub_main_external.yml b/roles/dtc/create/tasks/sub_main_external.yml index d030da6a6..ba2b32a68 100644 --- a/roles/dtc/create/tasks/sub_main_external.yml +++ b/roles/dtc/create/tasks/sub_main_external.yml @@ -35,6 +35,7 @@ tags: "{{ nac_tags.create }}" - name: Create External Fabric in Nexus Dashboard + tags: "{{ nac_tags.create_fabric }}" ansible.builtin.include_tasks: file: external/fabric.yml apply: @@ -46,6 +47,7 @@ - change_flags.changes_detected_fabric - name: Manage External Fabric Switches in Nexus Dashboard + tags: "{{ nac_tags.create_switches }}" ansible.builtin.include_tasks: file: common/devices.yml apply: @@ -55,6 +57,7 @@ - change_flags.changes_detected_inventory - name: Manage NDFC External VPC Peering + tags: "{{ nac_tags.create_vpc_peers }}" ansible.builtin.include_tasks: file: common/vpc_peering.yml apply: @@ -64,6 +67,7 @@ - change_flags.changes_detected_vpc_peering - name: Manage External Fabric Inter Links in Nexus Dashboard + tags: "{{ nac_tags.create_links }}" ansible.builtin.include_tasks: file: common/edge_connections.yml apply: @@ -73,6 +77,7 @@ - change_flags.changes_detected_edge_connections - name: Manage External Fabric Interfaces in Nexus Dashboard + tags: "{{ nac_tags.create_interfaces }}" ansible.builtin.include_tasks: file: common/interfaces.yml apply: @@ -82,6 +87,7 @@ - change_flags.changes_detected_interfaces - name: Manage External Fabric Policies in Nexus Dashboard + tags: "{{ nac_tags.create_policy }}" ansible.builtin.include_tasks: file: common/policies.yml apply: diff --git a/roles/dtc/create/tasks/sub_main_isn.yml b/roles/dtc/create/tasks/sub_main_isn.yml index 1e6964b36..037df3939 100644 --- a/roles/dtc/create/tasks/sub_main_isn.yml +++ b/roles/dtc/create/tasks/sub_main_isn.yml @@ -35,6 +35,7 @@ tags: "{{ nac_tags.create }}" - name: Create ISN Fabric in Nexus Dashboard + tags: "{{ nac_tags.create_fabric }}" ansible.builtin.include_tasks: file: common/fabric.yml apply: @@ -46,6 +47,7 @@ - change_flags.changes_detected_fabric - name: Manage ISN Fabric Switches in Nexus Dashboard + tags: "{{ nac_tags.create_switches }}" ansible.builtin.include_tasks: file: common/devices.yml apply: @@ -55,6 +57,7 @@ - change_flags.changes_detected_inventory - name: Manage ISN Fabric Inter Links in Nexus Dashboard + tags: "{{ nac_tags.create_links }}" ansible.builtin.include_tasks: file: common/edge_connections.yml apply: @@ -64,6 +67,7 @@ - change_flags.changes_detected_edge_connections - name: Manage ISN Fabric Interfaces in Nexus Dashboard + tags: "{{ nac_tags.create_interfaces }}" ansible.builtin.include_tasks: file: common/interfaces.yml apply: @@ -73,6 +77,7 @@ - change_flags.changes_detected_interfaces - name: Manage ISN Fabric Policies in Nexus Dashboard + tags: "{{ nac_tags.create_policy }}" ansible.builtin.include_tasks: file: common/policies.yml apply: diff --git a/roles/dtc/create/tasks/sub_main_msd.yml b/roles/dtc/create/tasks/sub_main_msd.yml index 875f37ef1..840235afe 100644 --- a/roles/dtc/create/tasks/sub_main_msd.yml +++ b/roles/dtc/create/tasks/sub_main_msd.yml @@ -35,6 +35,7 @@ tags: "{{ nac_tags.create }}" - name: Create MSD Fabric in Nexus Dashboard + tags: "{{ nac_tags.create_fabric }}" ansible.builtin.include_tasks: file: common/fabric.yml apply: @@ -74,6 +75,7 @@ - change_flags.changes_detected_bgw_anycast_vip - name: Manage MSD Fabric VRFs and Networks in Nexus Dashboard + tags: "{{ nac_tags.create_vrfs_networks }}" ansible.builtin.include_tasks: file: msd/vrfs_networks.yml apply: diff --git a/roles/dtc/create/tasks/sub_main_vxlan.yml b/roles/dtc/create/tasks/sub_main_vxlan.yml index b2ad59649..5600e7d99 100644 --- a/roles/dtc/create/tasks/sub_main_vxlan.yml +++ b/roles/dtc/create/tasks/sub_main_vxlan.yml @@ -35,6 +35,7 @@ tags: "{{ nac_tags.create }}" - name: Create iBGP VXLAN Fabric in Nexus Dashboard + tags: "{{ nac_tags.create_fabric }}" ansible.builtin.include_tasks: file: common/fabric.yml apply: @@ -46,6 +47,7 @@ - change_flags.changes_detected_fabric - name: Manage iBGP VXLAN Fabric Switches in Nexus Dashboard + tags: "{{ nac_tags.create_switches }}" ansible.builtin.include_tasks: file: common/devices.yml apply: @@ -55,6 +57,7 @@ - change_flags.changes_detected_inventory or change_flags.changes_detected_underlay_ip_address - name: Manage iBGP VXLAN vPC Peering in Nexus Dashboard + tags: "{{ nac_tags.create_vpc_peers }}" ansible.builtin.include_tasks: file: common/vpc_peering.yml apply: @@ -84,6 +87,7 @@ - change_flags.changes_detected_vpc_peering or change_flags.changes_detected_vpc_domain_id_resource - name: Manage iBGP VXLAN Fabric Interfaces in Nexus Dashboard + tags: "{{ nac_tags.create_interfaces }}" ansible.builtin.include_tasks: file: common/interfaces.yml apply: @@ -93,6 +97,7 @@ - change_flags.changes_detected_interfaces - name: Manage iBGP VXLAN Fabric Inter Links in Nexus Dashboard + tags: "{{ nac_tags.create_links }}" ansible.builtin.include_tasks: file: common/edge_connections.yml apply: @@ -102,6 +107,7 @@ - change_flags.changes_detected_edge_connections - name: Manage iBGP VXLAN Fabric VRFs and Networks in Nexus Dashboard + tags: "{{ nac_tags.create_vrfs_networks }}" ansible.builtin.include_tasks: file: common_vxlan/vrfs_networks.yml apply: @@ -112,6 +118,7 @@ - change_flags.changes_detected_vrfs or change_flags.changes_detected_networks - name: Manage iBGP VXLAN Fabric Intra Links in Nexus Dashboard + tags: "{{ nac_tags.create_links }}" ansible.builtin.include_tasks: file: common/links.yml apply: @@ -121,6 +128,7 @@ - change_flags.changes_detected_fabric_links - name: Manage iBGP VXLAN Fabric Policies in Nexus Dashboard + tags: "{{ nac_tags.create_policy }}" ansible.builtin.include_tasks: file: common/policies.yml apply: