diff --git a/geant/gap_ansible/playbooks/l3_core_service.yaml b/geant/gap_ansible/playbooks/l3_core_service.yaml index 67139f81ab809941dfe0a2b786b3c34921ac06b9..6a3b921c493adfc2c3bd36b2c7ca172da9c5f572 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: 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 62e377e502b488bfe2baac8a25a424ba5a04f34f..a36ce1e4f42f05a27e63142f97bc534965920f12 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> diff --git a/geant/gap_ansible/roles/pim/README.md b/geant/gap_ansible/roles/pim/README.md new file mode 100644 index 0000000000000000000000000000000000000000..225dd44b9fc5b3abff7e9c68ff9e91d505cdd5f0 --- /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 0000000000000000000000000000000000000000..c3f1987b30ae6ea408b05d2d1bc62af10ff52e3f --- /dev/null +++ b/geant/gap_ansible/roles/pim/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# 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 0000000000000000000000000000000000000000..36d899dd86d8c01083aefc8c7000b2cf64cacd75 --- /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 0000000000000000000000000000000000000000..8bccce4c06cbaa792e994efb517d473cc5782add --- /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 0000000000000000000000000000000000000000..6b3a8ac3191c32af6a8cc2affaa39000dcdc75a3 --- /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 0000000000000000000000000000000000000000..dcb3109fb16fd5fedb0c37914bdb5d9c385b2927 --- /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 0000000000000000000000000000000000000000..2e0773b4c7f0df58f135b5b48c5c833656def4e2 --- /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 }}"