From 7113da95516345ebe8d41cff5a8febb74b5a370f Mon Sep 17 00:00:00 2001
From: Aleksandr Kurbatov <aleksandr.kurbatov@GL1342-AKURBATOV.local>
Date: Wed, 14 Aug 2024 20:05:10 +0100
Subject: [PATCH] Added verbs

- deploy_routing_instances
- update_sdp_mesh
---
 .../tasks/compile_pe_base_config.yaml         | 17 +++++++---
 .../tasks/deploy_pe_base_config.yaml          | 34 ++++++++++++++++---
 .../roles/promote_p_to_pe/tasks/main.yml      |  4 +--
 .../roles/promote_p_to_pe/vars/main.yml       |  2 ++
 4 files changed, 47 insertions(+), 10 deletions(-)

diff --git a/geant/gap_ansible/roles/promote_p_to_pe/tasks/compile_pe_base_config.yaml b/geant/gap_ansible/roles/promote_p_to_pe/tasks/compile_pe_base_config.yaml
index e9c7c23e..d374f30c 100644
--- a/geant/gap_ansible/roles/promote_p_to_pe/tasks/compile_pe_base_config.yaml
+++ b/geant/gap_ansible/roles/promote_p_to_pe/tasks/compile_pe_base_config.yaml
@@ -15,7 +15,7 @@
     mode: '0755'
   delegate_to: localhost
 
-- name: Print the template in "/var/tmp/ansible_run_{{ opid }}/base_config.conf"
+- name: Print the template in "/var/tmp/ansible_run_{{ opid }}/pe_base_config.conf"
   when: verb == "deploy_pe_base_config"
   ansible.builtin.template:
     src: "routers/{{ subscription.router.vendor }}/pe_base_config.j2"
@@ -25,11 +25,20 @@
     mode: '0755'
   delegate_to: localhost
 
-- name: Print the template in "/var/tmp/ansible_run_{{ opid }}/sdp_mesh.conf"
+- name: Print the template in "/var/tmp/ansible_run_{{ opid }}/pe_base_vprn.conf"
+  when: verb == "deploy_routing_instances"
+  ansible.builtin.template:
+    src: "routers/{{ subscription.router.vendor }}/pe_base_vprn.j2"
+    dest: "/var/tmp/ansible_run_{{ opid }}/pe_base_vprn.conf"
+    lstrip_blocks: true
+    trim_blocks: true
+    mode: '0755'
+
+- name: Print the template in "/var/tmp/ansible_run_{{ opid }}/pe_update_sdp.conf"
   when: verb == "update_sdp_mesh"
   ansible.builtin.template:
-    src: "routers/{{ subscription.router.vendor }}/sdp_mesh.j2"
-    dest: "/var/tmp/ansible_run_{{ opid }}/sdp_mesh.conf"
+    src: "routers/{{ subscription.router.vendor }}/pe_update_sdp.j2"
+    dest: "/var/tmp/ansible_run_{{ opid }}/pe_update_sdp.conf"
     lstrip_blocks: true
     trim_blocks: true
     mode: '0755'
diff --git a/geant/gap_ansible/roles/promote_p_to_pe/tasks/deploy_pe_base_config.yaml b/geant/gap_ansible/roles/promote_p_to_pe/tasks/deploy_pe_base_config.yaml
index 3503ab20..5e2f1fe0 100644
--- a/geant/gap_ansible/roles/promote_p_to_pe/tasks/deploy_pe_base_config.yaml
+++ b/geant/gap_ansible/roles/promote_p_to_pe/tasks/deploy_pe_base_config.yaml
@@ -1,4 +1,4 @@
-- name: Deploy base_config on "{{ inventory_hostname }}" [CHECK ONLY][NOKIA]
+- name: Deploy PE base_config on "{{ inventory_hostname }}" [CHECK ONLY][NOKIA]
   when: >-
       dry_run | ansible.builtin.bool
       and verb == "deploy_pe_base_config"
@@ -12,6 +12,20 @@
   register: output
   check_mode: true
 
+- name: Deploy PE base VPRNs on "{{ inventory_hostname }}" [CHECK ONLY][NOKIA]
+  when: >-
+      dry_run | ansible.builtin.bool
+      and verb == "deploy_routing_instances"
+  geant.gap_ansible.nokia_netconf_config:
+    format: xml
+    default_operation: merge
+    content: "{{ lookup('ansible.builtin.template', 'routers/{{ subscription.router.vendor }}/pe_base_vprn.j2') }}"
+    commit: true
+    validate: true
+  diff: true
+  register: output
+  check_mode: true
+
 - name: Deploy SDP mesh on "{{ inventory_hostname }}" [CHECK ONLY][NOKIA]
   when: >-
       dry_run | ansible.builtin.bool
@@ -19,13 +33,12 @@
   geant.gap_ansible.nokia_netconf_config:
     format: xml
     default_operation: merge
-    content: "{{ lookup('ansible.builtin.template', 'routers/{{ subscription.router.vendor }}/sdp_mesh.j2') }}"
+    content: "{{ lookup('ansible.builtin.template', 'routers/{{ subscription.router.vendor }}/pe_update_sdp.j2') }}"
     commit: true
     validate: true
   diff: true
   register: output
   check_mode: true
-
 # - name: Fail if there is any diff
 #   ansible.builtin.fail:
 #     msg: Base config drift detected!!!
@@ -47,6 +60,19 @@
   diff: true
   check_mode: false
 
+- name: Deploy PE base VPRNs on "{{ inventory_hostname }}" [AND COMMIT][NOKIA]
+  when: >-
+      not (dry_run | ansible.builtin.bool) and
+      verb == "deploy_routing_instances"
+  geant.gap_ansible.nokia_netconf_config:
+    format: xml
+    default_operation: merge
+    content: "{{ lookup('ansible.builtin.template', 'routers/{{ subscription.router.vendor }}/pe_base_vprn.j2') }}"
+    commit: true
+    commit_comment: "{{ commit_comment }}"
+  diff: true
+  check_mode: false
+
 - name: Deploy updated SDP mesh on "{{ inventory_hostname }}" [AND COMMIT][NOKIA]
   when: >-
       not (dry_run | ansible.builtin.bool) and
@@ -54,7 +80,7 @@
   geant.gap_ansible.nokia_netconf_config:
     format: xml
     default_operation: merge
-    content: "{{ lookup('ansible.builtin.template', 'routers/{{ subscription.router.vendor }}/sdp_mesh.j2') }}"
+    content: "{{ lookup('ansible.builtin.template', 'routers/{{ subscription.router.vendor }}/pe_update_sdp.j2') }}"
     commit: true
     commit_comment: "{{ commit_comment }}"
   diff: true
diff --git a/geant/gap_ansible/roles/promote_p_to_pe/tasks/main.yml b/geant/gap_ansible/roles/promote_p_to_pe/tasks/main.yml
index 41dc0e6e..02a46992 100644
--- a/geant/gap_ansible/roles/promote_p_to_pe/tasks/main.yml
+++ b/geant/gap_ansible/roles/promote_p_to_pe/tasks/main.yml
@@ -49,11 +49,11 @@
   ansible.builtin.include_tasks: configure_isis_overload.yaml
 
 - name: Include templates compilation
-  when: verb in [ 'deploy_pe_base_config', 'update_sdp_mesh' ]
+  when: verb in [ 'deploy_pe_base_config', 'update_sdp_mesh' , 'deploy_routing_instances' ]
   ansible.builtin.include_tasks: compile_pe_base_config.yaml
 
 - name: Include deploy if selected
-  when: verb in [ 'deploy_pe_base_config', 'update_sdp_mesh' ]
+  when: verb in [ 'deploy_pe_base_config', 'update_sdp_mesh', 'deploy_routing_instances' ]
   ansible.builtin.include_tasks: deploy_pe_base_config.yaml
 
 - name: Include deletion of default static routes
diff --git a/geant/gap_ansible/roles/promote_p_to_pe/vars/main.yml b/geant/gap_ansible/roles/promote_p_to_pe/vars/main.yml
index a940cf7c..dd26c7d3 100644
--- a/geant/gap_ansible/roles/promote_p_to_pe/vars/main.yml
+++ b/geant/gap_ansible/roles/promote_p_to_pe/vars/main.yml
@@ -6,6 +6,8 @@ verbs:
   - remove_isis_overload # Remove overload bit from ISIS config
   - deploy_pe_base_config # Deploy PE-specific base config on top of existing P-only config
   - delete_default_routes # Delete default static routes configured as part P base-config
+  - deploy_routing_instances # Deploy standard PE VPRNs
+  - update_sdp_mesh # Upadate SDP mesh on other Nokia PE routers with this promoted router
 
 lo_ipv4_address: "{{ subscription.router.router_lo_ipv4_address }}"
 lo_ipv6_address: "{{ subscription.router.router_lo_ipv6_address }}"
-- 
GitLab