From 3fd6dea1ca31e75e263ad52ebef3e512ea533cab Mon Sep 17 00:00:00 2001
From: Aleksandr Kurbatov <ak@geant.org>
Date: Wed, 22 Jan 2025 17:36:34 +0000
Subject: [PATCH 1/4] vprn.j2: SROS requires low-case "true"/"false" values

---
 .../gap_ansible/roles/bc_templates/routers/nokia/router/vprn.j2 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/geant/gap_ansible/roles/bc_templates/routers/nokia/router/vprn.j2 b/geant/gap_ansible/roles/bc_templates/routers/nokia/router/vprn.j2
index 62e377e5..a36ce1e4 100644
--- a/geant/gap_ansible/roles/bc_templates/routers/nokia/router/vprn.j2
+++ b/geant/gap_ansible/roles/bc_templates/routers/nokia/router/vprn.j2
@@ -32,7 +32,7 @@
             <aggregate>
                 <ip-prefix>{{ ag.ip_prefix }}</ip-prefix>
                 <community>{{ ag.community }}</community>
-                <discard-component-communities>{{ ag.dcc }}</discard-component-communities>
+                <discard-component-communities>{{ ag.dcc | lower }}</discard-component-communities>
             </aggregate>
           {% endfor %}
         </aggregates>
-- 
GitLab


From 2ef37c25478fb54e008d764650e3387fdfa5395c Mon Sep 17 00:00:00 2001
From: Aleksandr Kurbatov <ak@geant.org>
Date: Fri, 24 Jan 2025 15:50:19 +0000
Subject: [PATCH 2/4] PIM role

---
 geant/gap_ansible/roles/pim/README.md         | 38 +++++++++++++++++++
 geant/gap_ansible/roles/pim/defaults/main.yml |  3 ++
 geant/gap_ansible/roles/pim/meta/main.yml     | 35 +++++++++++++++++
 .../gap_ansible/roles/pim/tasks/compile.yaml  | 15 ++++++++
 geant/gap_ansible/roles/pim/tasks/main.yml    | 11 ++++++
 geant/gap_ansible/roles/pim/templates/pim.j2  | 21 ++++++++++
 geant/gap_ansible/roles/pim/vars/main.yml     |  5 +++
 7 files changed, 128 insertions(+)
 create mode 100644 geant/gap_ansible/roles/pim/README.md
 create mode 100644 geant/gap_ansible/roles/pim/defaults/main.yml
 create mode 100644 geant/gap_ansible/roles/pim/meta/main.yml
 create mode 100644 geant/gap_ansible/roles/pim/tasks/compile.yaml
 create mode 100644 geant/gap_ansible/roles/pim/tasks/main.yml
 create mode 100644 geant/gap_ansible/roles/pim/templates/pim.j2
 create mode 100644 geant/gap_ansible/roles/pim/vars/main.yml

diff --git a/geant/gap_ansible/roles/pim/README.md b/geant/gap_ansible/roles/pim/README.md
new file mode 100644
index 00000000..225dd44b
--- /dev/null
+++ b/geant/gap_ansible/roles/pim/README.md
@@ -0,0 +1,38 @@
+Role Name
+=========
+
+A brief description of the role goes here.
+
+Requirements
+------------
+
+Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
+
+Role Variables
+--------------
+
+A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
+
+Dependencies
+------------
+
+A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
+
+Example Playbook
+----------------
+
+Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
+
+    - hosts: servers
+      roles:
+         - { role: username.rolename, x: 42 }
+
+License
+-------
+
+BSD
+
+Author Information
+------------------
+
+An optional section for the role authors to include contact information, or a website (HTML is not allowed).
diff --git a/geant/gap_ansible/roles/pim/defaults/main.yml b/geant/gap_ansible/roles/pim/defaults/main.yml
new file mode 100644
index 00000000..0664bfb6
--- /dev/null
+++ b/geant/gap_ansible/roles/pim/defaults/main.yml
@@ -0,0 +1,3 @@
+#SPDX-License-Identifier: MIT-0
+---
+# defaults file for pim
diff --git a/geant/gap_ansible/roles/pim/meta/main.yml b/geant/gap_ansible/roles/pim/meta/main.yml
new file mode 100644
index 00000000..36d899dd
--- /dev/null
+++ b/geant/gap_ansible/roles/pim/meta/main.yml
@@ -0,0 +1,35 @@
+galaxy_info:
+  author: A. Kurbatov
+  description: GEANT Orchestration and Automation Team
+  company: GEANT
+
+  # If the issue tracker for your role is not on github, uncomment the
+  # next line and provide a value
+  # issue_tracker_url: http://example.com/issue/tracker
+
+  # Choose a valid license ID from https://spdx.org - some suggested licenses:
+  # - BSD-3-Clause (default)
+  # - MIT
+  # - GPL-2.0-or-later
+  # - GPL-3.0-only
+  # - Apache-2.0
+  # - CC-BY-4.0
+  license: MIT
+
+  min_ansible_version: '2.10'
+
+  # If this a Container Enabled role, provide the minimum Ansible Container version.
+  # min_ansible_container_version:
+
+  galaxy_tags:
+    - network
+    # List tags for your role here, one per line. A tag is a keyword that describes
+    # and categorizes the role. Users find roles by searching for tags. Be sure to
+    # remove the '[]' above, if you add tags to this list.
+    #
+    # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
+    #       Maximum 20 tags per role.
+
+dependencies: []
+  # List your role dependencies here, one per line. Be sure to remove the '[]' above,
+  # if you add dependencies to this list.
diff --git a/geant/gap_ansible/roles/pim/tasks/compile.yaml b/geant/gap_ansible/roles/pim/tasks/compile.yaml
new file mode 100644
index 00000000..8bccce4c
--- /dev/null
+++ b/geant/gap_ansible/roles/pim/tasks/compile.yaml
@@ -0,0 +1,15 @@
+---
+- name: Set ansible host to localhost to compile template
+  ansible.builtin.set_fact:
+    ansible_host: "localhost"
+    ansible_connection: local
+
+- name: Print the template in "/var/tmp/ansible_run_{{ opid }}/{{ partner_name }}_pim.conf"
+  # when: verb in ["deploy", "update", "terminate"]
+  ansible.builtin.template:
+    src: "pim.j2"
+    dest: "/var/tmp/ansible_run_{{ opid }}/{{ partner_name }}_pim.conf"
+    lstrip_blocks: true
+    trim_blocks: true
+    mode: '0755'
+  delegate_to: localhost
diff --git a/geant/gap_ansible/roles/pim/tasks/main.yml b/geant/gap_ansible/roles/pim/tasks/main.yml
new file mode 100644
index 00000000..6b3a8ac3
--- /dev/null
+++ b/geant/gap_ansible/roles/pim/tasks/main.yml
@@ -0,0 +1,11 @@
+---
+# tasks file for pim
+# - name: Merge vars
+#   ansible.builtin.include_tasks: merge_vars.yaml
+#
+- name: Include PIM compilation
+  ansible.builtin.include_tasks: compile.yaml
+
+# - name: Include PIM deployment
+#   when: is_standalone_run | ansible.builtin.bool
+#   ansible.builtin.include_tasks: deploy_sbp.yaml
diff --git a/geant/gap_ansible/roles/pim/templates/pim.j2 b/geant/gap_ansible/roles/pim/templates/pim.j2
new file mode 100644
index 00000000..dcb3109f
--- /dev/null
+++ b/geant/gap_ansible/roles/pim/templates/pim.j2
@@ -0,0 +1,21 @@
+
+        <router xmlns="urn:nokia.com:sros:ns:yang:sr:conf" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nokia-attr="urn:nokia.com:sros:ns:yang:sr:attributes">
+            <router-name>Base</router-name>
+
+            <pim xmlns="urn:nokia.com:sros:ns:yang:sr:conf" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nokia-attr="urn:nokia.com:sros:ns:yang:sr:attributes">
+                <interface alu:operation="replace">
+                    <interface-name>{{ lag_name }}.{{ ap.sbp.vlan_id }}</interface-name>
+                  {% if 'mcast-ipv4' in bgp_session_v4.families %}
+                    <ipv4>
+                        <multicast>true</multicast>
+                    </ipv4>
+                  {% endif %}
+                  {% if 'mcast-ipv6' in bgp_session_v6.families %}
+                    <ipv6>
+                        <multicast>true</multicast>
+                    </ipv6>
+                  {% endif %}
+                </interface>
+            </pim>
+
+        </router>
diff --git a/geant/gap_ansible/roles/pim/vars/main.yml b/geant/gap_ansible/roles/pim/vars/main.yml
new file mode 100644
index 00000000..2e0773b4
--- /dev/null
+++ b/geant/gap_ansible/roles/pim/vars/main.yml
@@ -0,0 +1,5 @@
+---
+# vars file for pim
+is_standalone_run: false
+
+lag_name: "{{ ap.sbp.edge_port.edge_port_name }}"
-- 
GitLab


From 92d7593361f94661c8579d88cec621a5ca3c938e Mon Sep 17 00:00:00 2001
From: Aleksandr Kurbatov <ak@geant.org>
Date: Fri, 24 Jan 2025 15:51:07 +0000
Subject: [PATCH 3/4] l3_core_service playbook: Include PIM role if any of the
 BGP sessions have `mcast-` families

---
 .../playbooks/l3_core_service.yaml            | 32 +++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/geant/gap_ansible/playbooks/l3_core_service.yaml b/geant/gap_ansible/playbooks/l3_core_service.yaml
index 67139f81..6a3b921c 100644
--- a/geant/gap_ansible/playbooks/l3_core_service.yaml
+++ b/geant/gap_ansible/playbooks/l3_core_service.yaml
@@ -75,6 +75,38 @@
     - name: Compile BGP-related config
       when: object == "bgp"
       block:
+        - name: Set BGP V4 session object to check for custom policies
+          ansible.builtin.set_fact:
+            bgp_session_v4: "{{ ap.sbp | json_query(query) }}"
+          vars:
+            query: "bgp_session_list[?ip_type == 'ipv4'] | [0]"
+          loop:
+            "{{ subscription.l3_core_service.ap_list }}"
+          loop_control:
+            loop_var: ap
+
+        - name: Set BGP V6 session object to check for custom policies
+          ansible.builtin.set_fact:
+            bgp_session_v6: "{{ ap.sbp | json_query(query) }}"
+          vars:
+            query: "bgp_session_list[?ip_type == 'ipv6'] | [0]"
+          loop:
+            "{{ subscription.l3_core_service.ap_list }}"
+          loop_control:
+            loop_var: ap
+
+        - name: Include PIM role if V4 multicast is enabled
+          when: >
+            bgp_session_v4.families is contains('mcast-ipv4') or bgp_session_v6 is contains('mcast-ipv6')
+            and
+            subscription.l3_core_service_type in ["GÉANT IP", "GEANT IP", "GEANT_IP"]
+          ansible.builtin.include_role:
+            name: pim
+          loop:
+            "{{ subscription.l3_core_service.ap_list }}"
+          loop_control:
+            loop_var: ap
+
         - name: Include Prefix-list role
           when: subscription.l3_core_service_type in ["GÉANT IP", "GEANT IP", "GEANT_IP"]
           ansible.builtin.include_role:
-- 
GitLab


From 3050caab702acefb791b10b3335f455eb13d3a58 Mon Sep 17 00:00:00 2001
From: Aleksandr Kurbatov <ak@geant.org>
Date: Mon, 27 Jan 2025 11:01:41 +0000
Subject: [PATCH 4/4] Linting

---
 geant/gap_ansible/roles/pim/defaults/main.yml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/geant/gap_ansible/roles/pim/defaults/main.yml b/geant/gap_ansible/roles/pim/defaults/main.yml
index 0664bfb6..c3f1987b 100644
--- a/geant/gap_ansible/roles/pim/defaults/main.yml
+++ b/geant/gap_ansible/roles/pim/defaults/main.yml
@@ -1,3 +1,2 @@
-#SPDX-License-Identifier: MIT-0
 ---
 # defaults file for pim
-- 
GitLab