From e13c1b3adc8cc442e29301a9d18763a6ff469082 Mon Sep 17 00:00:00 2001
From: Aleksandr Kurbatov <aleksandr.kurbatov@GL1342-AKURBATOV.local>
Date: Fri, 12 Jul 2024 14:07:30 +0100
Subject: [PATCH] TWAMP: verification workflow additions

---
 .../iptrunk_twamp/tasks/deploy_object.yaml    | 22 +++++++++++++++++++
 .../roles/iptrunk_twamp/vars/main.yml         |  1 +
 2 files changed, 23 insertions(+)

diff --git a/geant/gap_ansible/roles/iptrunk_twamp/tasks/deploy_object.yaml b/geant/gap_ansible/roles/iptrunk_twamp/tasks/deploy_object.yaml
index 78725f04..72336382 100644
--- a/geant/gap_ansible/roles/iptrunk_twamp/tasks/deploy_object.yaml
+++ b/geant/gap_ansible/roles/iptrunk_twamp/tasks/deploy_object.yaml
@@ -6,11 +6,22 @@
     src_format: text
     check_commit: true
   diff: true
+  register: output
   when: >
     local_side.iptrunk_side_node.vendor == "juniper"
     and
     ( dry_run | ansible.builtin.bool )
 
+- name: Fail if there is any diff
+  ansible.builtin.fail:
+    msg: TWAMP config drift detected!!!
+  when: >
+    output.changed | ansible.builtin.bool
+    and
+    is_verification_workflow | ansible.builtin.bool
+    and
+    local_side.iptrunk_side_node.vendor == "juniper"
+
 - name: Deploy "{{ config_object }}" on "{{ inventory_hostname }}" [AND COMMIT][JUNIPER]
   junipernetworks.junos.junos_config:
     update: 'replace'
@@ -31,12 +42,23 @@
     content: "{{ lookup('ansible.builtin.template', '{{ local_side.iptrunk_side_node.vendor }}/{{ config_object }}.j2') }}"
     commit: true
   diff: true
+  register: output
   check_mode: true
   when: >
     local_side.iptrunk_side_node.vendor == "nokia"
     and
     ( dry_run | ansible.builtin.bool )
 
+- name: Fail if there is any diff
+  ansible.builtin.fail:
+    msg: TWAMP config drift detected!!!
+  when: >
+    output.changed | ansible.builtin.bool
+    and
+    is_verification_workflow | ansible.builtin.bool
+    and
+    local_side.iptrunk_side_node.vendor == "nokia"
+
 - name: Deploy "{{ config_object }}"on "{{ inventory_hostname }}" [AND COMMIT][NOKIA]
   # ansible.netcommon.netconf_config:
   geant.gap_ansible.nokia_netconf_config:
diff --git a/geant/gap_ansible/roles/iptrunk_twamp/vars/main.yml b/geant/gap_ansible/roles/iptrunk_twamp/vars/main.yml
index ace9a7ac..a5c6e954 100644
--- a/geant/gap_ansible/roles/iptrunk_twamp/vars/main.yml
+++ b/geant/gap_ansible/roles/iptrunk_twamp/vars/main.yml
@@ -4,6 +4,7 @@
 #
 
 dry_run: "True"
+is_verification_workflow: false
 
 
 nokia_twamp_server:
-- 
GitLab