diff --git a/plugins/action/common/change_flag_manager.py b/plugins/action/common/change_flag_manager.py new file mode 100644 index 000000000..f01c6be2d --- /dev/null +++ b/plugins/action/common/change_flag_manager.py @@ -0,0 +1,342 @@ +# 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.plugins.action import ActionBase +import json +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_vpc_domain_id_resource': 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 + results['flags'] = {} + + # 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', 'get', 'display']: + results['failed'] = True + results['msg'] = "Parameter 'operation' must be one of: [initialize, update, get, 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'] == "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) + from time import sleep + sleep(2) + + 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 a0218ef6b..1662dd902 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,18 @@ 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 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 + # gets run in isolation. + 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/common/run_map.py b/plugins/action/common/run_map.py index a8460f475..3e151c702 100644 --- a/plugins/action/common/run_map.py +++ b/plugins/action/common/run_map.py @@ -82,9 +82,16 @@ 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") 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/diff_compare.py b/plugins/action/dtc/diff_compare.py new file mode 100644 index 000000000..4c3b94b83 --- /dev/null +++ b/plugins/action/dtc/diff_compare.py @@ -0,0 +1,330 @@ +# 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 + +import yaml +import os +import datetime +from ansible.utils.display import Display +from ansible.plugins.action import ActionBase + +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 __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['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') + + 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 = [] + + 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") + + # 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'): + removed_items = self.order_interface_remove(removed_items) + + 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) + + 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. + """ + 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', + '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 _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. + + 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 not isinstance(item, dict): + return None + + filename = self.new_file_path + + # 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): + 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. + """ + + 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 + + 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. + """ + # 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'] + breakout_interfaces = [item for item in removed_items if item.get('type') == 'breakout'] + + # 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 diff --git a/plugins/action/dtc/fabric_deploy_manager.py b/plugins/action/dtc/fabric_deploy_manager.py new file mode 100644 index 000000000..ee7c45f79 --- /dev/null +++ b/plugins/action/dtc/fabric_deploy_manager.py @@ -0,0 +1,229 @@ +# 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 +from time import sleep + +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 + base_path = "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest" + self.api_paths = { + "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 + 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})") + + self.fabric_in_sync = True + response = self._send_request("GET", self.api_paths["get_switches_by_fabric"]) + 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}/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"]) + + 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'): + 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': + self.fabric_in_sync = False + break + + 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.get('RETURN_CODE') == 200: + pass + 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.get('RETURN_CODE') == 200: + pass + 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.get('RETURN_CODE') == 200: + pass + else: + display.warning(f">>>> Failed for Fabric {self.fabric_name}: {response}") + + # Get last 2 history entries + self.fabric_history = 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 + ) + if 'response' in response.keys(): + response = response['response'] + if 'msg' in response.keys(): + response = response['msg'] + 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 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() + 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']: + 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() + 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/plugins/action/dtc/unmanaged_child_fabric_networks.py b/plugins/action/dtc/unmanaged_child_fabric_networks.py index e1460b3af..88d0cc769 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 @@ -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,22 @@ 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 +175,58 @@ 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 + + # If config is an empty list then we can return early as + # there is nothing to delete + 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={ + "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/plugins/action/dtc/unmanaged_child_fabric_vrfs.py b/plugins/action/dtc/unmanaged_child_fabric_vrfs.py index 49f720bf1..40b5f7d5a 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,17 +147,22 @@ 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 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: - config = [] for ndfc_vrf_name in diff_ndfc_vrf_names: config.append( { @@ -165,24 +171,58 @@ 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 + + # If config is an empty list then we can return early as + # there is nothing to delete + 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={ + "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/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/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_edge_connections.yml b/roles/dtc/common/tasks/common/ndfc_edge_connections.yml index 81008166e..b307d3b0a 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" @@ -77,8 +72,13 @@ delegate_to: localhost - 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: "{{ common_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..e50d16533 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: @@ -77,8 +71,13 @@ delegate_to: localhost - 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: "{{ common_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 646cd6f31..d713c2aee 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" @@ -69,7 +64,16 @@ when: MD_Extended.vxlan.topology.fabric_links | length > 0 delegate_to: localhost -- name: Diff Previous and Current Data Files +- 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 + +- 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 }}" @@ -77,8 +81,13 @@ delegate_to: localhost - 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: "{{ common_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..8e6eb0a5d 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" @@ -77,8 +72,13 @@ delegate_to: localhost - 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: "{{ common_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..d633fcf7f 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" @@ -77,8 +72,13 @@ delegate_to: localhost - 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: "{{ common_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 b18be5062..82059fd11 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" @@ -51,40 +46,73 @@ 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: 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 + + 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.breakout_preprov.count > 0 or + MD_Extended.vxlan.topology.interfaces.modes.all.count > 0 + delegate_to: localhost + +- name: Set interface_all Var + ansible.builtin.set_fact: + interface_all_create: "{{ + interface_breakout + interface_trunk + - interface_trunk_po + interface_routed + - interface_po_routed + sub_interface_routed + - interface_vpc + + interface_access + + interface_trunk_po + + interface_access_po + + 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 MD_Extended.vxlan.topology.interfaces.modes.all.count > 0 delegate_to: localhost -- name: Save interface_all +- 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 -- 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_compare: + 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 }}" @@ -92,8 +120,13 @@ delegate_to: localhost - 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: "{{ common_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..6809b34d2 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" @@ -77,8 +72,13 @@ delegate_to: localhost - 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: "{{ common_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..d6a846e98 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" @@ -77,8 +72,13 @@ delegate_to: localhost - 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: "{{ common_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..af99ede21 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" @@ -77,8 +72,13 @@ delegate_to: localhost - 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: "{{ common_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..bc956e3c1 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" @@ -80,8 +75,13 @@ delegate_to: localhost - 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: "{{ common_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..309020f08 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" @@ -77,8 +72,13 @@ delegate_to: localhost - 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: "{{ common_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..381b58a49 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" @@ -77,8 +72,13 @@ delegate_to: localhost - 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: "{{ common_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..46f41e1b6 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" @@ -77,8 +72,13 @@ delegate_to: localhost - 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: "{{ common_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..f7e3e68b7 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" @@ -77,8 +72,13 @@ delegate_to: localhost - 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: "{{ common_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..e62520498 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" @@ -77,8 +72,13 @@ delegate_to: localhost - 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: "{{ common_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..f13eb82d8 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" @@ -100,8 +95,13 @@ delegate_to: localhost - 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: "{{ common_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..22e411c57 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: @@ -78,8 +72,13 @@ delegate_to: localhost - 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: "{{ common_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..2cd3cb017 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" @@ -77,8 +72,13 @@ delegate_to: localhost - 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: "{{ common_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 278a1cd44..b53caac29 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,6 @@ # SPDX-License-Identifier: MIT --- -- 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: @@ -62,7 +58,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 +67,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 }}" @@ -79,8 +84,13 @@ delegate_to: localhost - 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: "{{ common_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 44d857bb1..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 @@ -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" @@ -69,7 +64,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 }}" @@ -77,8 +81,13 @@ delegate_to: localhost - 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: "{{ common_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..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 @@ -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" @@ -80,8 +75,13 @@ delegate_to: localhost - 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: "{{ common_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 8d0f479f2..58bf88c56 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 @@ -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" @@ -69,7 +64,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 }}" @@ -77,8 +81,13 @@ delegate_to: localhost - 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: "{{ common_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 deleted file mode 100644 index 0b0823a75..000000000 --- a/roles/dtc/common/tasks/external/ndfc_fabric.yml +++ /dev/null @@ -1,80 +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'] 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 8ed96053e..000000000 --- a/roles/dtc/common/tasks/external/ndfc_interface_access.yml +++ /dev/null @@ -1,85 +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'] 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 6589cff43..000000000 --- a/roles/dtc/common/tasks/external/ndfc_interface_access_po.yml +++ /dev/null @@ -1,85 +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'] 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 fc2658daa..000000000 --- a/roles/dtc/common/tasks/external/ndfc_interface_all.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_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'] 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 46c21da63..000000000 --- a/roles/dtc/common/tasks/external/ndfc_interface_loopback.yml +++ /dev/null @@ -1,88 +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'] 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 4faafa3c6..000000000 --- a/roles/dtc/common/tasks/external/ndfc_interface_po_routed.yml +++ /dev/null @@ -1,85 +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'] 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 2faf943b3..000000000 --- a/roles/dtc/common/tasks/external/ndfc_interface_routed.yml +++ /dev/null @@ -1,85 +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'] 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 d3e20e825..000000000 --- a/roles/dtc/common/tasks/external/ndfc_interface_trunk.yml +++ /dev/null @@ -1,85 +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'] 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 f0e6d1cdc..000000000 --- a/roles/dtc/common/tasks/external/ndfc_interface_trunk_po.yml +++ /dev/null @@ -1,85 +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'] 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 cf1c51d7c..000000000 --- a/roles/dtc/common/tasks/external/ndfc_interface_vpc.yml +++ /dev/null @@ -1,85 +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'] 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 12226a3d9..000000000 --- a/roles/dtc/common/tasks/external/ndfc_policy.yml +++ /dev/null @@ -1,81 +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'] 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 f81a7f0cb..000000000 --- a/roles/dtc/common/tasks/external/ndfc_sub_interface_routed.yml +++ /dev/null @@ -1,85 +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'] 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..c6efcd834 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" @@ -74,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 }}" @@ -82,8 +86,13 @@ delegate_to: localhost - 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: "{{ common_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/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/main.yml b/roles/dtc/common/tasks/main.yml index 6e403d010..6586a869a 100644 --- a/roles/dtc/common/tasks/main.yml +++ b/roles/dtc/common/tasks/main.yml @@ -21,114 +21,63 @@ --- -# ------------------------------------------------------------------------ -# Initialize NameSpace Dicts For Variable Sharing -# ------------------------------------------------------------------------ -- name: Initialize NameSpace Dict For Sharing Variables +- name: Create Fact To Store Common Role Path 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_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 + common_role_path: "{{ role_path }}" 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 - when: MD_Extended.vxlan.fabric.type == 'VXLAN_EVPN' +- 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: "{{ common_role_path }}" + operation: initialize + tags: "{{ nac_tags.common_role }}" + delegate_to: localhost -- 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 - when: MD_Extended.vxlan.fabric.type == 'eBGP_VXLAN' +- 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 ISN Fabric - ansible.builtin.import_tasks: sub_main_isn.yml - tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml - when: MD_Extended.vxlan.fabric.type == 'ISN' + - 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 MSD Fabric - ansible.builtin.import_tasks: sub_main_msd.yml - tags: "{{ nac_tags.common_role }}" # Tags defined in roles/common_global/vars/main.yml - when: MD_Extended.vxlan.fabric.type == 'MSD' + - 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 External Fabric - 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: 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.include_tasks: sub_main_external.yml + when: MD_Extended.vxlan.fabric.type == 'External' + tags: "{{ nac_tags.common_role }}" + +- 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: Store Change Flags For Use In Subsequent Roles + ansible.builtin.set_fact: + change_flags: "{{ change_flag_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 + 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 9b1a51e8e..2d4d25420 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: @@ -75,8 +71,13 @@ delegate_to: localhost - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_bgw_anycast_vip: 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: "{{ common_role_path }}" + operation: update + change_flag: changes_detected_bgw_anycast_vip + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/msd/ndfc_child_vrfs.yml b/roles/dtc/common/tasks/msd/ndfc_child_vrfs.yml index fc16c9d3a..ddb56b51e 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" @@ -77,8 +72,13 @@ delegate_to: localhost - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_vrfs: 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: "{{ common_role_path }}" + operation: update + change_flag: changes_detected_vrfs + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/msd/ndfc_fabric.yml b/roles/dtc/common/tasks/msd/ndfc_fabric.yml index f3863e2f7..5b72784f9 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" @@ -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: @@ -77,8 +71,13 @@ delegate_to: localhost - 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: "{{ common_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/msd/ndfc_networks.yml b/roles/dtc/common/tasks/msd/ndfc_networks.yml index c243eed3b..ea9011489 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" @@ -69,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" @@ -77,8 +81,13 @@ delegate_to: localhost - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_networks: 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: "{{ common_role_path }}" + operation: update + change_flag: changes_detected_networks + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/msd/ndfc_vrfs.yml b/roles/dtc/common/tasks/msd/ndfc_vrfs.yml index 21849224a..22ea02f3e 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" @@ -69,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" @@ -77,8 +81,13 @@ delegate_to: localhost - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_vrfs: 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: "{{ common_role_path }}" + operation: update + change_flag: changes_detected_vrfs + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml b/roles/dtc/common/tasks/sub_main_ebgp_vxlan.yml index 2704bbe81..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 @@ -211,38 +211,17 @@ - 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 }}" + # 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 }}" - interface_all: "{{ interface_all }}" + 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 }}" @@ -262,37 +241,9 @@ 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 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 }}" + vrf_diff_result: "{{ vrf_diff_result }}" diff --git a/roles/dtc/common/tasks/sub_main_external.yml b/roles/dtc/common/tasks/sub_main_external.yml index 53a2bc68c..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 @@ -177,30 +177,14 @@ - 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 }}" 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 }}" int_loopback_config: "{{ int_loopback_config }}" interface_po_routed: "{{ interface_po_routed }}" interface_routed: "{{ interface_routed }}" @@ -214,31 +198,6 @@ 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 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 897b13cb5..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 @@ -170,29 +170,13 @@ - 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 }}" 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 }}" int_loopback_config: "{{ int_loopback_config }}" interface_po_routed: "{{ interface_po_routed }}" interface_routed: "{{ interface_routed }}" @@ -206,31 +190,5 @@ 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 Result Data + interface_diff_result: "{{ interface_diff_result }}" diff --git a/roles/dtc/common/tasks/sub_main_msd.yml b/roles/dtc/common/tasks/sub_main_msd.yml index f1c09d880..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,35 +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 - -# ------------------------------------------------------------------------ -# 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 + ansible.builtin.include_tasks: msd/ndfc_bgw_anycast_vip.yml # ------------------------------------------------------------------------ # Save Local Variables To NameSpace Dict For Use Elsewhere @@ -81,33 +67,5 @@ - 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 - # 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 }}" - -- 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 bfdbd4357..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 @@ -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_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 }}" - changes_detected_underlay_ip_address: "{{ changes_detected_underlay_ip_address }}" fabric_config: "{{ fabric_config }}" fabric_links: "{{ fabric_links }}" edge_connections: "{{ edge_connections }}" @@ -250,10 +226,12 @@ 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 }}" 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 }}" @@ -263,7 +241,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 }}" @@ -271,37 +248,11 @@ vrf_config: "{{ vrf_config }}" vrf_attach_config: "{{ vrf_attach_config }}" underlay_ip_address: "{{ underlay_ip_address }}" - -- 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 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 }}" + 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_networks.yml b/roles/dtc/common/tasks/vxlan/ndfc_networks.yml index f6539d67f..5cde7f64f 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 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" @@ -78,8 +82,13 @@ delegate_to: localhost - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_networks: 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: "{{ common_role_path }}" + operation: "update" + change_flag: changes_detected_networks + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed diff --git a/roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml b/roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml index 83efd520e..61d7cca24 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" @@ -70,6 +65,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" @@ -78,8 +82,13 @@ delegate_to: localhost - name: Set File Change Flag Based on File Diff Result - ansible.builtin.set_fact: - changes_detected_vrfs: 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: "{{ common_role_path }}" + operation: "update" + change_flag: changes_detected_vrfs + flag_value: true delegate_to: localhost when: - file_diff_result.file_data_changed 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/common/devices_discovery.yml b/roles/dtc/create/tasks/common/devices_discovery.yml index a5f8b88b1..b0e43892a 100644 --- a/roles/dtc/create/tasks/common/devices_discovery.yml +++ b/roles/dtc/create/tasks/common/devices_discovery.yml @@ -58,17 +58,46 @@ ansible_connect_timeout: 3000 when: - MD_Extended.vxlan.topology.switches | length > 0 - - vars_common_local.changes_detected_inventory + - 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 Underlay IP Addresses + 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 + - 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 + 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 + - 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: "{{ underlay_ip_config_list }}" 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) + - (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 @@ -86,8 +115,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/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/interfaces.yml b/roles/dtc/create/tasks/common/interfaces.yml index 384c21f25..e64f81236 100644 --- a/roles/dtc/create/tasks/common/interfaces.yml +++ b/roles/dtc/create/tasks/common/interfaces.yml @@ -53,142 +53,34 @@ - "+ 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 -# ---------------------------------------------------------------------- +# -------------------------------------------------------------------- +# 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: 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: Initialize Interface Config List to All Interfaces + ansible.builtin.set_fact: + interface_config_list: "{{ vars_common_local.interface_all_create }}" -# ---------------------------------------------------------------------- -# Manage Interface vPC Configuration in Nexus Dashboard -# ---------------------------------------------------------------------- +- name: Override Interface Config List Based On Diff Run Settings + ansible.builtin.set_fact: + interface_config_list: "{{ vars_common_local.interface_diff_result.updated }}" + when: + - run_map_read_result.diff_run is true|bool -- name: Manage Interface vPC 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_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 }}" -# vars: -# ansible_command_timeout: 3000 -# ansible_connect_timeout: 3000 -# when: MD_Extended.vxlan.topology.interfaces.modes.all.count > 0 -# delegate_to: localhost + config: "{{ interface_config_list }}" + vars: + 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 5c64651dd..7c9854f34 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 + ansible.builtin.set_fact: + fabric_links_config_list: "{{ fabric_links }}" + +- name: Override Fabric Links Config List Based On Diff Run Settings + ansible.builtin.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,7 +73,7 @@ - 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_config_list }}" switch_data_model: "{{ MD_Extended.vxlan.topology.switches }}" register: required_links when: result_links.response is defined diff --git a/roles/dtc/create/tasks/common/vpc_peering.yml b/roles/dtc/create/tasks/common/vpc_peering.yml index 61bd209c6..e7e5cd6cb 100644 --- a/roles/dtc/create/tasks/common/vpc_peering.yml +++ b/roles/dtc/create/tasks/common/vpc_peering.yml @@ -57,14 +57,29 @@ # Manage vPC Domain ID # -------------------------------------------------------------------- +- name: Initialize vPC Domain ID Resource Config List to All Interfaces + 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 + 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 + - 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: "{{ vpc_domain_id_resource_config_list }}" when: - - vars_common_vxlan.vpc_domain_id_resource is defined - - vars_common_vxlan.vpc_domain_id_resource | 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 @@ -84,9 +99,27 @@ # Manage vPC Peering in Nexus Dashboard # -------------------------------------------------------------------- +- name: Initialize vPC Peering Config List to All Interfaces + 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 + 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 + - 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: "{{ 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 2e09cc44f..f20698294 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,19 +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 + ansible.builtin.set_fact: + vrf_config_list: "{{ vars_common_local.vrf_config }}" + +- name: Override VRF Config List Based On Diff Run Settings + ansible.builtin.set_fact: + vrf_config_list: "{{ vars_common_local.vrf_diff_result.updated }}" + when: + - run_map_read_result.diff_run is true|bool + - 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 - MD_Extended.vxlan.overlay.vrfs - - vars_common_local.changes_detected_vrfs + - change_flags.changes_detected_vrfs + - vrf_config_list | length > 0 - not is_active_child_fabric # -------------------------------------------------------------------- @@ -89,9 +100,13 @@ 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 + +# -------------------------------------------------------------------- +# 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,17 +114,25 @@ - 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 + ansible.builtin.set_fact: + network_config_list: "{{ vars_common_local.net_config }}" + +- name: Override Network Config List Based On Diff Run Settings + ansible.builtin.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 - MD_Extended.vxlan.overlay.networks - - vars_common_local.changes_detected_networks + - change_flags.changes_detected_networks + - network_config_list | length > 0 - not is_active_child_fabric 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/main.yml b/roles/dtc/create/tasks/main.yml index 0afdf633d..e0b35a666 100644 --- a/roles/dtc/create/tasks/main.yml +++ b/roles/dtc/create/tasks/main.yml @@ -22,65 +22,37 @@ --- - 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) + 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 - 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) + 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 - 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) + 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 - ansible.builtin.import_tasks: sub_main_msd.yml - when: > - (MD_Extended.vxlan.fabric.type == 'MSD') + tags: "{{ nac_tags.create }}" + ansible.builtin.include_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) + tags: "{{ nac_tags.create }}" + ansible.builtin.include_tasks: sub_main_external.yml + 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/msd/vrfs_networks.yml b/roles/dtc/create/tasks/msd/vrfs_networks.yml index e71faa4e8..4f502da10 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 @@ -57,41 +58,68 @@ 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 +# 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 -# -------------------------------------------------------------------- -# Update Local Variables To NameSpace Dict For Use Elsewhere -# -------------------------------------------------------------------- +- 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 + +- name: Override Networks List Based On Diff Run Settings + ansible.builtin.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 + ansible.builtin.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 +# ---------------------------------------------------------------------------------- - 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 +135,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 +156,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 +170,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/create/tasks/sub_main_ebgp_vxlan.yml b/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml index 9064b2b13..d1d8e9bf0 100644 --- a/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml +++ b/roles/dtc/create/tasks/sub_main_ebgp_vxlan.yml @@ -35,27 +35,36 @@ tags: "{{ nac_tags.create }}" - name: Create eBGP VXLAN Fabric in Nexus Dashboard - ansible.builtin.import_tasks: ebgp_vxlan/fabric.yml + tags: "{{ nac_tags.create_fabric }}" + 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 - - vars_common_ebgp_vxlan.changes_detected_fabric - tags: "{{ nac_tags.create_fabric }}" + - change_flags.changes_detected_fabric - name: Manage eBGP VXLAN Fabric Switches in Nexus Dashboard - ansible.builtin.import_tasks: common/devices.yml + tags: "{{ nac_tags.create_switches }}" + ansible.builtin.include_tasks: + file: common/devices.yml + apply: + tags: "{{ nac_tags.create_switches }}" when: - MD_Extended.vxlan.topology.switches | length > 0 - - vars_common_ebgp_vxlan.changes_detected_inventory - tags: "{{ nac_tags.create_switches }}" + - change_flags.changes_detected_inventory - name: Manage eBGP VXLAN vPC Peering in Nexus Dashboard - ansible.builtin.import_tasks: common/vpc_peering.yml + tags: "{{ nac_tags.create_vpc_peers }}" + 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 - - vars_common_ebgp_vxlan.changes_detected_vpc_peering - tags: "{{ nac_tags.create_vpc_peers }}" + - change_flags.changes_detected_vpc_peering - name: Config-Save Block to Propagate vPC Changes to eBGP VXLAN Fabric in Nexus Dashboard block: @@ -63,32 +72,46 @@ 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 + tags: "{{ nac_tags.create_interfaces }}" + 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) - - vars_common_ebgp_vxlan.changes_detected_interfaces - tags: "{{ nac_tags.create_interfaces }}" + - change_flags.changes_detected_interfaces - name: Manage eBGP VXLAN Fabric VRFs and Networks in Nexus Dashboard - ansible.builtin.import_tasks: common_vxlan/vrfs_networks.yml + tags: "{{ nac_tags.create_vrfs_networks }}" + 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 - - vars_common_ebgp_vxlan.changes_detected_vrfs or vars_common_ebgp_vxlan.changes_detected_networks - tags: "{{ nac_tags.create_vrfs_networks }}" + - change_flags.changes_detected_vrfs or change_flags.changes_detected_networks - name: Manage eBGP VXLAN Fabric Policies in Nexus Dashboard - ansible.builtin.import_tasks: common/policies.yml + tags: "{{ nac_tags.create_policy }}" + 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) - - vars_common_ebgp_vxlan.changes_detected_policy - tags: "{{ nac_tags.create_policy }}" + - change_flags.changes_detected_policy diff --git a/roles/dtc/create/tasks/sub_main_external.yml b/roles/dtc/create/tasks/sub_main_external.yml index fa53ee952..ba2b32a68 100644 --- a/roles/dtc/create/tasks/sub_main_external.yml +++ b/roles/dtc/create/tasks/sub_main_external.yml @@ -35,46 +35,63 @@ tags: "{{ nac_tags.create }}" - name: Create External Fabric in Nexus Dashboard - ansible.builtin.import_tasks: external/fabric.yml + tags: "{{ nac_tags.create_fabric }}" + 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 - - vars_common_external.changes_detected_fabric - tags: "{{ nac_tags.create_fabric }}" + - change_flags.changes_detected_fabric - name: Manage External Fabric Switches in Nexus Dashboard - ansible.builtin.import_tasks: common/devices.yml + tags: "{{ nac_tags.create_switches }}" + ansible.builtin.include_tasks: + file: common/devices.yml + apply: + tags: "{{ nac_tags.create_switches }}" when: - MD_Extended.vxlan.topology.switches | length > 0 - - vars_common_external.changes_detected_inventory - tags: "{{ nac_tags.create_switches }}" + - change_flags.changes_detected_inventory - name: Manage NDFC External VPC Peering - ansible.builtin.import_tasks: common/vpc_peering.yml + tags: "{{ nac_tags.create_vpc_peers }}" + 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 - - vars_common_external.changes_detected_vpc_peering - tags: "{{ nac_tags.create_vpc_peers }}" - + - change_flags.changes_detected_vpc_peering - name: Manage External Fabric Inter Links in Nexus Dashboard - ansible.builtin.import_tasks: common/edge_connections.yml + tags: "{{ nac_tags.create_links }}" + ansible.builtin.include_tasks: + file: common/edge_connections.yml + apply: + tags: "{{ nac_tags.create_links }}" when: - MD_Extended.vxlan.topology.edge_connections | length > 0 - - changes_detected_edge_connections - tags: "{{ nac_tags.create_links }}" + - change_flags.changes_detected_edge_connections - name: Manage External Fabric Interfaces in Nexus Dashboard - ansible.builtin.import_tasks: common/interfaces.yml + tags: "{{ nac_tags.create_interfaces }}" + 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) - - vars_common_external.changes_detected_interfaces - tags: "{{ nac_tags.create_interfaces }}" + - change_flags.changes_detected_interfaces - name: Manage External Fabric Policies in Nexus Dashboard - ansible.builtin.import_tasks: common/policies.yml + tags: "{{ nac_tags.create_policy }}" + 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) - - vars_common_external.changes_detected_policy - tags: "{{ nac_tags.create_policy }}" + - change_flags.changes_detected_policy diff --git a/roles/dtc/create/tasks/sub_main_isn.yml b/roles/dtc/create/tasks/sub_main_isn.yml index 48a9304ec..037df3939 100644 --- a/roles/dtc/create/tasks/sub_main_isn.yml +++ b/roles/dtc/create/tasks/sub_main_isn.yml @@ -35,38 +35,53 @@ tags: "{{ nac_tags.create }}" - name: Create ISN Fabric in Nexus Dashboard - ansible.builtin.import_tasks: common/fabric.yml + tags: "{{ nac_tags.create_fabric }}" + 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 - - vars_common_isn.changes_detected_fabric - tags: "{{ nac_tags.create_fabric }}" + - change_flags.changes_detected_fabric - name: Manage ISN Fabric Switches in Nexus Dashboard - ansible.builtin.import_tasks: common/devices.yml + tags: "{{ nac_tags.create_switches }}" + ansible.builtin.include_tasks: + file: common/devices.yml + apply: + tags: "{{ nac_tags.create_switches }}" when: - MD_Extended.vxlan.topology.switches | length > 0 - - vars_common_isn.changes_detected_inventory - tags: "{{ nac_tags.create_switches }}" + - change_flags.changes_detected_inventory - name: Manage ISN Fabric Inter Links in Nexus Dashboard - ansible.builtin.import_tasks: common/edge_connections.yml + tags: "{{ nac_tags.create_links }}" + ansible.builtin.include_tasks: + file: common/edge_connections.yml + apply: + tags: "{{ nac_tags.create_links }}" when: - MD_Extended.vxlan.topology.edge_connections | length > 0 - - changes_detected_edge_connections - tags: "{{ nac_tags.create_links }}" + - change_flags.changes_detected_edge_connections - name: Manage ISN Fabric Interfaces in Nexus Dashboard - ansible.builtin.import_tasks: common/interfaces.yml + tags: "{{ nac_tags.create_interfaces }}" + 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) - - vars_common_isn.changes_detected_interfaces - tags: "{{ nac_tags.create_interfaces }}" + - change_flags.changes_detected_interfaces - name: Manage ISN Fabric Policies in Nexus Dashboard - ansible.builtin.import_tasks: common/policies.yml + tags: "{{ nac_tags.create_policy }}" + 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) - - vars_common_isn.changes_detected_policy - tags: "{{ nac_tags.create_policy }}" + - change_flags.changes_detected_policy diff --git a/roles/dtc/create/tasks/sub_main_msd.yml b/roles/dtc/create/tasks/sub_main_msd.yml index e6c16e951..840235afe 100644 --- a/roles/dtc/create/tasks/sub_main_msd.yml +++ b/roles/dtc/create/tasks/sub_main_msd.yml @@ -35,15 +35,18 @@ tags: "{{ nac_tags.create }}" - name: Create MSD Fabric in Nexus Dashboard - ansible.builtin.import_tasks: common/fabric.yml + tags: "{{ nac_tags.create_fabric }}" + 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" - - vars_common_msd.changes_detected_fabric - tags: "{{ nac_tags.create_fabric }}" + - change_flags.changes_detected_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 @@ -69,11 +72,14 @@ | 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 + tags: "{{ nac_tags.create_vrfs_networks }}" + 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 9f8d7ef24..5600e7d99 100644 --- a/roles/dtc/create/tasks/sub_main_vxlan.yml +++ b/roles/dtc/create/tasks/sub_main_vxlan.yml @@ -35,27 +35,36 @@ tags: "{{ nac_tags.create }}" - name: Create iBGP VXLAN Fabric in Nexus Dashboard - ansible.builtin.import_tasks: common/fabric.yml + tags: "{{ nac_tags.create_fabric }}" + 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 - - vars_common_vxlan.changes_detected_fabric - tags: "{{ nac_tags.create_fabric }}" + - change_flags.changes_detected_fabric - name: Manage iBGP VXLAN Fabric Switches in Nexus Dashboard - ansible.builtin.import_tasks: common/devices.yml + tags: "{{ nac_tags.create_switches }}" + ansible.builtin.include_tasks: + file: common/devices.yml + apply: + tags: "{{ nac_tags.create_switches }}" when: - MD_Extended.vxlan.topology.switches | length > 0 - - vars_common_vxlan.changes_detected_inventory or vars_common_vxlan.changes_detected_underlay_ip_address - tags: "{{ nac_tags.create_switches }}" + - change_flags.changes_detected_inventory or change_flags.changes_detected_underlay_ip_address - name: Manage iBGP VXLAN vPC Peering in Nexus Dashboard - ansible.builtin.import_tasks: common/vpc_peering.yml + tags: "{{ nac_tags.create_vpc_peers }}" + 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 - - vars_common_vxlan.changes_detected_vpc_peering - tags: "{{ nac_tags.create_vpc_peers }}" + - change_flags.changes_detected_vpc_peering or change_flags.changes_detected_vpc_domain_id_resource - name: Config-Save Block to Propagate vPC Changes to iBGP VXLAN Fabric in Nexus Dashboard block: @@ -63,7 +72,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 @@ -71,40 +82,57 @@ - 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 + tags: "{{ nac_tags.create_interfaces }}" + 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) - - vars_common_vxlan.changes_detected_interfaces - tags: "{{ nac_tags.create_interfaces }}" + - change_flags.changes_detected_interfaces - name: Manage iBGP VXLAN Fabric Inter Links in Nexus Dashboard - ansible.builtin.import_tasks: common/edge_connections.yml + tags: "{{ nac_tags.create_links }}" + ansible.builtin.include_tasks: + file: common/edge_connections.yml + apply: + tags: "{{ nac_tags.create_links }}" when: - MD_Extended.vxlan.topology.edge_connections | length > 0 - - vars_common_vxlan.changes_detected_edge_connections - tags: "{{ nac_tags.create_links }}" + - change_flags.changes_detected_edge_connections - name: Manage iBGP VXLAN Fabric VRFs and Networks in Nexus Dashboard - ansible.builtin.import_tasks: common_vxlan/vrfs_networks.yml + tags: "{{ nac_tags.create_vrfs_networks }}" + 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 - - vars_common_vxlan.changes_detected_vrfs or vars_common_vxlan.changes_detected_networks - tags: "{{ nac_tags.create_vrfs_networks }}" + - change_flags.changes_detected_vrfs or change_flags.changes_detected_networks - name: Manage iBGP VXLAN Fabric Intra Links in Nexus Dashboard - ansible.builtin.import_tasks: common/links.yml + tags: "{{ nac_tags.create_links }}" + ansible.builtin.include_tasks: + file: common/links.yml + apply: + tags: "{{ nac_tags.create_links }}" when: - MD_Extended.vxlan.topology.fabric_links | length > 0 - - vars_common_vxlan.changes_detected_fabric_links - tags: "{{ nac_tags.create_links }}" + - change_flags.changes_detected_fabric_links - name: Manage iBGP VXLAN Fabric Policies in Nexus Dashboard - ansible.builtin.import_tasks: common/policies.yml + tags: "{{ nac_tags.create_policy }}" + 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) - - vars_common_vxlan.changes_detected_policy - tags: "{{ nac_tags.create_policy }}" + - change_flags.changes_detected_policy diff --git a/roles/dtc/deploy/tasks/main.yml b/roles/dtc/deploy/tasks/main.yml index 3aea0c55c..bd90de7fa 100644 --- a/roles/dtc/deploy/tasks/main.yml +++ b/roles/dtc/deploy/tasks/main.yml @@ -21,111 +21,43 @@ --- -- 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) - -- 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) - -# Additional conditions to be added when needed: -# vars_common_ebgp_vxlan.changes_detected_fabric_links or +- 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.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.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.include_tasks: sub_main_external.yml + when: + - MD_Extended.vxlan.fabric.type == 'External' + - change_flags.changes_detected_any + + - 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 }}" - name: Mark Stage Role Deploy Completed cisco.nac_dc_vxlan.common.run_map: model_data: "{{ MD_Extended }}" stage: role_deploy_completed register: run_map + tags: "{{ nac_tags.deploy }}" delegate_to: localhost diff --git a/roles/dtc/deploy/tasks/sub_main_ebgp_vxlan.yml b/roles/dtc/deploy/tasks/sub_main_ebgp_vxlan.yml index 922f9e523..fbd70dd2f 100644 --- a/roles/dtc/deploy/tasks/sub_main_ebgp_vxlan.yml +++ b/roles/dtc/deploy/tasks/sub_main_ebgp_vxlan.yml @@ -28,69 +28,14 @@ - "+ Calling Role - [cisco.nac_dc_vxlan.dtc.deploy] +" - "----------------------------------------------------------------" -- 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 fe77fbbaa..102d900bc 100644 --- a/roles/dtc/deploy/tasks/sub_main_external.yml +++ b/roles/dtc/deploy/tasks/sub_main_external.yml @@ -28,34 +28,14 @@ - "+ Calling Role - [cisco.nac_dc_vxlan.dtc.deploy] +" - "----------------------------------------------------------------" -- 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 c1bbe3b9a..b8fac9f78 100644 --- a/roles/dtc/deploy/tasks/sub_main_isn.yml +++ b/roles/dtc/deploy/tasks/sub_main_isn.yml @@ -28,34 +28,14 @@ - "+ Calling Role - [cisco.nac_dc_vxlan.dtc.deploy] +" - "----------------------------------------------------------------" -- 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 7df425ac1..67aa37e42 100644 --- a/roles/dtc/deploy/tasks/sub_main_msd.yml +++ b/roles/dtc/deploy/tasks/sub_main_msd.yml @@ -28,37 +28,19 @@ - "+ Calling Role - [cisco.nac_dc_vxlan.dtc.deploy] +" - "----------------------------------------------------------------" -- 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 +# 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 }}" diff --git a/roles/dtc/deploy/tasks/sub_main_vxlan.yml b/roles/dtc/deploy/tasks/sub_main_vxlan.yml index 6499b4c62..a84f303d4 100644 --- a/roles/dtc/deploy/tasks/sub_main_vxlan.yml +++ b/roles/dtc/deploy/tasks/sub_main_vxlan.yml @@ -28,69 +28,14 @@ - "+ Calling Role - [cisco.nac_dc_vxlan.dtc.deploy] +" - "----------------------------------------------------------------" -- 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 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 feb277bc0..ddac8e54d 100644 --- a/roles/dtc/remove/tasks/common/interfaces.yml +++ b/roles/dtc/remove/tasks/common/interfaces.yml @@ -52,40 +52,53 @@ - 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 +# ----------------------------------------------------------------------------- +# 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 Feature Active cisco.dcnm.dcnm_interface: fabric: "{{ MD_Extended.vxlan.fabric.name }}" - state: overridden - config: "{{ vars_common_local.interface_all }}" - # deploy: false + state: deleted + config: "{{ vars_common_local.interface_diff_result.removed }}" + deploy: false vars: ansible_command_timeout: 3000 ansible_connect_timeout: 3000 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) + - run_map_read_result.diff_run is true|bool + - force_run_all is false|bool -# - 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) +# TODO: We need to replay port-channel member config here if we delete the PC +# AND the members are defined in the data model -# - 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) +# ----------------------------------------------------------------------------- +# Remove Interfaces Default Mode +# ----------------------------------------------------------------------------- +- 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_remove_overridden }}" + # Might need to set this back to true to keep default behavior + 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 - name: Skip Remove Unmanaged Fabric Interfaces Task If interface_delete_mode is False ansible.builtin.debug: 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 681388a3b..4f26d63cc 100644 --- a/roles/dtc/remove/tasks/common/vpc_peers.yml +++ b/roles/dtc/remove/tasks/common/vpc_peers.yml @@ -52,10 +52,26 @@ - 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 + deploy: false + 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 + +- name: Remove Unmanaged vPC Peering from Nexus Dashboard - Diff Run False + cisco.dcnm.dcnm_vpc_pair: + src_fabric: "{{ MD_Extended.vxlan.fabric.name }}" + deploy: false state: overridden config: "{{ vars_common_local.vpc_peering }}" vars: @@ -64,6 +80,7 @@ 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 - name: Skip Remove Unmanaged vPC Peering Task If vpc_delete_mode is False ansible.builtin.debug: 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 diff --git a/roles/dtc/remove/tasks/common_vxlan/vrfs.yml b/roles/dtc/remove/tasks/common_vxlan/vrfs.yml index 1ab131658..226c62bbf 100644 --- a/roles/dtc/remove/tasks/common_vxlan/vrfs.yml +++ b/roles/dtc/remove/tasks/common_vxlan/vrfs.yml @@ -64,7 +64,35 @@ - (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 +# ----------------------------------------------------------------------------- +# 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 +103,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 diff --git a/roles/dtc/remove/tasks/main.yml b/roles/dtc/remove/tasks/main.yml index 761b812a3..bbf8951ea 100644 --- a/roles/dtc/remove/tasks/main.yml +++ b/roles/dtc/remove/tasks/main.yml @@ -22,59 +22,46 @@ --- - 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: > - (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 - when: > + 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 - 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) + 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 - 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) + 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: > - (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: 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' - 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..7b999ac93 100644 --- a/roles/dtc/remove/tasks/msd/networks.yml +++ b/roles/dtc/remove/tasks/msd/networks.yml @@ -27,38 +27,36 @@ 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 +- 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: Set Network Config to MultiSite VRF Data 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 + network_config: "{{ MD_Multisite }}" -- 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: Override Network Config Based On Diff Run Settings + ansible.builtin.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 }}" + data: "{{ network_config }}" + diff_run: "{{ run_map_read_result.diff_run }}" register: child_fabric_network_results 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/vrfs.yml b/roles/dtc/remove/tasks/msd/vrfs.yml index 2fbfb51d2..b30a8ec6d 100644 --- a/roles/dtc/remove/tasks/msd/vrfs.yml +++ b/roles/dtc/remove/tasks/msd/vrfs.yml @@ -27,38 +27,36 @@ 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 +- 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: Set VRF Config to MultiSite VRF Data 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 + vrf_config: "{{ MD_Multisite }}" -- 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: Override VRF Config Based On Diff Run Settings + ansible.builtin.set_fact: + vrf_config: "{{ vrf_diff_result.removed }}" + when: + - run_map_read_result.diff_run is true|bool - 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 - 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_ebgp_vxlan.yml b/roles/dtc/remove/tasks/sub_main_ebgp_vxlan.yml index 2326c290b..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: - - 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 }}" + ansible.builtin.include_tasks: + file: common/policy.yml + apply: + 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 }}" + ansible.builtin.include_tasks: + file: common/interfaces.yml + apply: + 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 }}" + ansible.builtin.include_tasks: + file: common_vxlan/networks.yml + apply: + 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 }}" + ansible.builtin.include_tasks: + file: common_vxlan/vrfs.yml + apply: + 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 }}" + ansible.builtin.include_tasks: + file: common/switches.yml + apply: + 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 1e23e0a74..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: - - 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 }}" + ansible.builtin.include_tasks: + file: common/policy.yml + apply: + 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 }}" + ansible.builtin.include_tasks: + file: common/interfaces.yml + apply: + 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 }}" + ansible.builtin.include_tasks: + file: common/vpc_peers.yml + apply: + 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 }}" + ansible.builtin.include_tasks: + file: common/switches.yml + apply: + 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 2a15e1b34..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: - - 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 }}" + ansible.builtin.include_tasks: + file: common/policy.yml + apply: + 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 }}" + ansible.builtin.include_tasks: + file: common/interfaces.yml + apply: + 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 }}" + ansible.builtin.include_tasks: + file: common/switches.yml + apply: + 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_msd.yml b/roles/dtc/remove/tasks/sub_main_msd.yml index 98bba072e..01fc9c70c 100644 --- a/roles/dtc/remove/tasks/sub_main_msd.yml +++ b/roles/dtc/remove/tasks/sub_main_msd.yml @@ -42,13 +42,84 @@ - "{{ 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 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 + +# ------------------------------------------------------------------------------------- +# 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.updated.role_create_completed is false|bool + +- name: Run dtc.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.include_tasks: "{{ role_path }}/../common/tasks/msd/ndfc_networks.yml" + when: run_map.updated.role_create_completed 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.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.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.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.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 cf1d6a38e..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: - - 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 }}" + ansible.builtin.include_tasks: + file: common/policy.yml + apply: + 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 }}" + ansible.builtin.include_tasks: + file: common/interfaces.yml + apply: + 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 }}" + ansible.builtin.include_tasks: + file: common_vxlan/networks.yml + apply: + 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 }}" + ansible.builtin.include_tasks: + file: common_vxlan/vrfs.yml + apply: + 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 }}" + ansible.builtin.include_tasks: + file: common/links.yml + apply: + 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 }}" + ansible.builtin.include_tasks: + file: common/vpc_peers.yml + apply: + 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 }}" + ansible.builtin.include_tasks: + file: common/switches.yml + apply: + tags: "{{ nac_tags.remove_switches }}" when: - - vars_common_vxlan.changes_detected_inventory + - change_flags.changes_detected_inventory 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) diff --git a/roles/dtc/create/tasks/external/devices.yml b/roles/validate/tasks/cleanup_model_files.yml similarity index 72% rename from roles/dtc/create/tasks/external/devices.yml rename to roles/validate/tasks/cleanup_model_files.yml index ead6b9a8d..cf4e80358 100644 --- a/roles/dtc/create/tasks/external/devices.yml +++ b/roles/validate/tasks/cleanup_model_files.yml @@ -21,12 +21,18 @@ --- -- name: Manage Devices Entry Point - ansible.builtin.debug: - msg: - - "----------------------------------------------------------------" - - "+ Manage Devices Fabric {{ MD_Extended.vxlan.fabric.name }}" - - "----------------------------------------------------------------" +- 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: Manage Devices Discovery in Nexus Dashboard - ansible.builtin.import_tasks: devices_discovery.yml +- name: Delete the found files + ansible.builtin.file: + path: "{{ item.path }}" + state: absent + loop: "{{ files_to_delete.files }}" + delegate_to: localhost diff --git a/roles/validate/tasks/main.yml b/roles/validate/tasks/main.yml index e112592e8..84a1e6d03 100644 --- a/roles/validate/tasks/main.yml +++ b/roles/validate/tasks/main.yml @@ -20,9 +20,11 @@ # SPDX-License-Identifier: MIT --- -- name: Import Role Tasks - ansible.builtin.import_tasks: sub_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) # 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 38af3dca6..55f02345f 100644 --- a/roles/validate/tasks/manage_model_files_current.yml +++ b/roles/validate/tasks/manage_model_files_current.yml @@ -50,5 +50,43 @@ 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 + - 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 + +- 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 + - run_map_read_result.diff_run is true|bool + - 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.include_tasks: cleanup_model_files.yml + when: + - ((force_run_all is defined) and (force_run_all is true|bool)) 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'] diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index 95b13a92e..2ff904334 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -43,5 +43,9 @@ 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 +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 95b13a92e..2ff904334 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -43,5 +43,9 @@ 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 +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 95b13a92e..2ff904334 100644 --- a/tests/sanity/ignore-2.16.txt +++ b/tests/sanity/ignore-2.16.txt @@ -43,5 +43,9 @@ 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 +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 95b13a92e..2ff904334 100644 --- a/tests/sanity/ignore-2.17.txt +++ b/tests/sanity/ignore-2.17.txt @@ -43,5 +43,9 @@ 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 +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