|
| 1 | +# Copyright (c) 2025 Cisco Systems, Inc. and its affiliates |
| 2 | +# |
| 3 | +# Permission is hereby granted, free of charge, to any person obtaining a copy of |
| 4 | +# this software and associated documentation files (the "Software"), to deal in |
| 5 | +# the Software without restriction, including without limitation the rights to |
| 6 | +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
| 7 | +# the Software, and to permit persons to whom the Software is furnished to do so, |
| 8 | +# subject to the following conditions: |
| 9 | +# |
| 10 | +# The above copyright notice and this permission notice shall be included in all |
| 11 | +# copies or substantial portions of the Software. |
| 12 | +# |
| 13 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
| 15 | +# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
| 16 | +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
| 17 | +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 18 | +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 19 | +# |
| 20 | +# SPDX-License-Identifier: MIT |
| 21 | + |
| 22 | +--- |
| 23 | +- name: Initialize changes_detected Var |
| 24 | + ansible.builtin.set_fact: |
| 25 | + changes_detected_anycast_bgw: false |
| 26 | + delegate_to: localhost |
| 27 | + |
| 28 | +- name: Set file_name Var |
| 29 | + ansible.builtin.set_fact: |
| 30 | + file_name: "ndfc_msd_anycast_bgw.yml" |
| 31 | + delegate_to: localhost |
| 32 | + |
| 33 | +- name: Stat Previous File If It Exists |
| 34 | + ansible.builtin.stat: |
| 35 | + path: "{{ path_name }}{{ file_name }}" |
| 36 | + register: data_file_previous |
| 37 | + delegate_to: localhost |
| 38 | + |
| 39 | +- name: Backup Previous Data File If It Exists |
| 40 | + ansible.builtin.copy: |
| 41 | + src: "{{ path_name }}{{ file_name }}" |
| 42 | + dest: "{{ path_name }}{{ file_name }}.old" |
| 43 | + when: data_file_previous.stat.exists |
| 44 | + |
| 45 | +- name: Delete Previous Data File If It Exists |
| 46 | + ansible.builtin.file: |
| 47 | + state: absent |
| 48 | + path: "{{ path_name }}{{ file_name }}" |
| 49 | + delegate_to: localhost |
| 50 | + when: data_file_previous.stat.exists |
| 51 | + |
| 52 | +- name: Build MSD Anycast BGW IP address allocation From Template |
| 53 | + ansible.builtin.template: |
| 54 | + src: ndfc_msd_anycast_bgw.j2 |
| 55 | + dest: "{{ path_name }}{{ file_name }}" |
| 56 | + delegate_to: localhost |
| 57 | + |
| 58 | +- name: Create Empty msd_anycast_bgw Var |
| 59 | + ansible.builtin.set_fact: |
| 60 | + msd_anycast_bgw: [] |
| 61 | + delegate_to: localhost |
| 62 | + |
| 63 | +- name: Set msd_anycast_bgw Var |
| 64 | + ansible.builtin.set_fact: |
| 65 | + msd_anycast_bgw: "{{ lookup('file', path_name + file_name) | from_yaml }}" |
| 66 | + delegate_to: localhost |
| 67 | + |
| 68 | +- name: Diff Previous and Current Data Files |
| 69 | + cisco.nac_dc_vxlan.dtc.diff_model_changes: |
| 70 | + file_name_previous: "{{ path_name }}{{ file_name }}.old" |
| 71 | + file_name_current: "{{ path_name }}{{ file_name }}" |
| 72 | + register: file_diff_result |
| 73 | + delegate_to: localhost |
| 74 | + |
| 75 | +- name: Set File Change Flag Based on File Diff Result |
| 76 | + ansible.builtin.set_fact: |
| 77 | + changes_detected_anycast_bgw: true |
| 78 | + delegate_to: localhost |
| 79 | + when: |
| 80 | + - file_diff_result.file_data_changed |
| 81 | + - check_roles['save_previous'] |
0 commit comments