diff --git a/geant/gap_ansible/playbooks/l3_core_service.yaml b/geant/gap_ansible/playbooks/l3_core_service.yaml index 2223bb6c59951652373a17eaefb236297e228269..67139f81ab809941dfe0a2b786b3c34921ac06b9 100644 --- a/geant/gap_ansible/playbooks/l3_core_service.yaml +++ b/geant/gap_ansible/playbooks/l3_core_service.yaml @@ -3,13 +3,16 @@ gather_facts: false tasks: - name: Check SBP + # FIX: rewrite when: verb == 'check' - ansible.builtin.include_role: - name: service_checks - loop: - "{{ subscription.l3_core_service.ap_list }}" - loop_control: - loop_var: ap + ansible.builtin.meta: end_play + + # ansible.builtin.include_role: + # name: service_checks + # loop: + # "{{ subscription.l3_core_service.ap_list }}" + # loop_control: + # loop_var: ap # - name: Check BGP # # FIX: rewrite @@ -42,10 +45,13 @@ ansible.builtin.include_vars: dir: /opt/ansible_inventory/geant_services/{{ subscription.product.product_type }}/{{ subscription.l3_core_service_type | replace(' ', '_') }} - - name: Import partner specific variables for "{{ partner_name | upper }}" + - name: Import {{ partner_name | upper }} general variables ansible.builtin.include_vars: - dir: /opt/ansible_inventory/geant_partners/{{ partner_name | upper }} + file: /opt/ansible_inventory/geant_partners/{{ partner_name | upper }}/general.yaml + - name: Import {{ partner_name | upper }} specific variables for {{ subscription.l3_core_service_type | replace(' ', '_') }} + ansible.builtin.include_vars: + dir: /opt/ansible_inventory/geant_partners/{{ partner_name | upper }}/{{ subscription.l3_core_service_type | replace(' ', '_') }} - name: Compile SBP-related config when: object == 'sbp' @@ -66,20 +72,11 @@ loop_control: loop_var: ap - # - name: Compile SBP config - # block: - # - name: Include SBP role - # ansible.builtin.include_role: - # name: sbp - # loop: - # "{{ subscription.l3_core_service.ap_list }}" - # loop_control: - # loop_var: ap - # - name: Compile BGP-related config when: object == "bgp" block: - name: Include Prefix-list role + when: subscription.l3_core_service_type in ["GÉANT IP", "GEANT IP", "GEANT_IP"] ansible.builtin.include_role: name: po_prefix_lists loop: @@ -103,25 +100,6 @@ loop_control: loop_var: ap - # - name: Compile BGP policies - # block: - # - name: Include BGP policies - # ansible.builtin.include_role: - # name: policy_options - # loop: - # "{{ subscription.l3_core_service.ap_list }}" - # loop_control: - # loop_var: ap - # - # - name: Compile BGP sesssions config - # block: - # - name: Include BGP session - # ansible.builtin.include_role: - # name: bgp_config - # loop: - # "{{ subscription.l3_core_service.ap_list }}" - # loop_control: - # loop_var: ap - name: Deploy # when: verb == deploy diff --git a/geant/gap_ansible/playbooks/vrf_update.yaml b/geant/gap_ansible/playbooks/vrf_update.yaml index 99abbd3dd3525984f5215e16421191bc7927b1c5..17f26833e0eae216be77f1156e977a2bc030d578 100644 --- a/geant/gap_ansible/playbooks/vrf_update.yaml +++ b/geant/gap_ansible/playbooks/vrf_update.yaml @@ -41,7 +41,3 @@ - name: Assemble and deploy generated config ansible.builtin.include_role: name: deploy_service_config - loop: - "{{ subscription.vrf.vrf_router_list }}" - loop_control: - loop_var: router diff --git a/geant/gap_ansible/roles/bgp_config/tasks/main.yml b/geant/gap_ansible/roles/bgp_config/tasks/main.yml index 13eca9efa55c06677c5a50df361cb0c55512cff5..7bf1d663e56f855f221b65faabacf0b4837242e0 100644 --- a/geant/gap_ansible/roles/bgp_config/tasks/main.yml +++ b/geant/gap_ansible/roles/bgp_config/tasks/main.yml @@ -1,5 +1,17 @@ --- # tasks file for bgp_config +- 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]" + +- 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]" + - name: Load Standard Policy Statements vars ansible.builtin.include_tasks: merge_vars.yaml diff --git a/geant/gap_ansible/roles/bgp_config/tasks/merge_vars.yaml b/geant/gap_ansible/roles/bgp_config/tasks/merge_vars.yaml index 77676232f0a50f972531cc23264d6429c2fff79f..a29606a9541075c298d7a457c75805e82bc85b1a 100644 --- a/geant/gap_ansible/roles/bgp_config/tasks/merge_vars.yaml +++ b/geant/gap_ansible/roles/bgp_config/tasks/merge_vars.yaml @@ -1,7 +1,35 @@ --- -- name: Set Standard Import and export policies names +- name: Set Standard BGP import and export policy names for GEANT_IP + when: > + subscription.l3_core_service_type in ["GEANT_IP", "GEANT IP"] ansible.builtin.set_fact: import_policies_v4: "{{ bgp.policies.import.v4 }}" import_policies_v6: "{{ bgp.policies.import.v6 }}" export_policies_v4: "{{ bgp.policies.export.v4 }}" export_policies_v6: "{{ bgp.policies.export.v6 }}" + +- name: Set standard BGP import and export policy names for LHCONE + when: > + subscription.l3_core_service_type in ["LHCONE"] + and + not bgp_session_v4.has_custom_policies | ansible.builtin.bool + or + not bgp_session_v4.has_custom_policies | ansible.builtin.bool + ansible.builtin.set_fact: + import_policies_v4: "{{ bgp.policies.import.v4 }}" + import_policies_v6: "{{ bgp.policies.import.v6 }}" + export_policies_v4: "{{ bgp.policies.export.v4 }}" + export_policies_v6: "{{ bgp.policies.export.v6 }}" + +- name: Set custom BGP import and export policy names for LHCONE + when: > + subscription.l3_core_service_type in ["LHCONE"] + and + bgp_session_v4.has_custom_policies | ansible.builtin.bool + or + bgp_session_v4.has_custom_policies | ansible.builtin.bool + ansible.builtin.set_fact: + import_policies_v4: "{{ bgp_custom.policies.import.v4 }}" + import_policies_v6: "{{ bgp_custom.policies.import.v6 }}" + export_policies_v4: "{{ bgp_custom.policies.export.v4 }}" + export_policies_v6: "{{ bgp_custom.policies.export.v6 }}" diff --git a/geant/gap_ansible/roles/bgp_config/templates/bgp.j2 b/geant/gap_ansible/roles/bgp_config/templates/bgp.j2 index 47b82cfbed8b479f485baaa1b02904c55fb4bd2b..1ff0260942f57d516d1ba103e27261f62474a345 100644 --- a/geant/gap_ansible/roles/bgp_config/templates/bgp.j2 +++ b/geant/gap_ansible/roles/bgp_config/templates/bgp.j2 @@ -1,9 +1,17 @@ - + {% if subscription.l3_core_service_type in ['GEANT_IP', 'GEANT IP'] %} <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> <bgp 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"> {% include 'bgp_neighbor.j2' %} </bgp> - </router> - + {% elif subscription.l3_core_service_type in ['LHCONE'] %} + <service 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"> + <vprn 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"> + <service-name>{{ vprn_name }}</service-name> + <bgp 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"> + {% include 'bgp_neighbor.j2' %} + </bgp> + </vprn> + </service> + {% endif %} diff --git a/geant/gap_ansible/roles/deploy_service_config/tasks/main.yml b/geant/gap_ansible/roles/deploy_service_config/tasks/main.yml index 0330f464f3c8fae1f3a88a4860a389c586a46699..8b109a0e8327d34d521252178f8f76c68394ec34 100644 --- a/geant/gap_ansible/roles/deploy_service_config/tasks/main.yml +++ b/geant/gap_ansible/roles/deploy_service_config/tasks/main.yml @@ -9,7 +9,20 @@ when: subscription.product.product_type == 'L3CoreService' ansible.builtin.set_fact: router: "{{ ap.sbp.edge_port.node }}" - vendor: "{{ router.vendor }}" + vendor: "{{ ap.sbp.edge_port.node.vendor }}" + +- name: Extract current inventory router from "vrf_router_list" + when: subscription.product.product_type == 'VRF' + ansible.builtin.set_fact: + current_router: "{{ vrf_router_list | community.general.json_query(query) }}" + vars: + query: "[?router.router_fqdn == '{{ inventory_hostname }}'] | [0]" + +- name: Set router and vendor for the use with VRF update + when: subscription.product.product_type == 'VRF' + ansible.builtin.set_fact: + router: "{{ current_router.router }}" + vendor: "{{ current_router.router.vendor }}" - name: Assemble the config from fragments in previous roles ansible.builtin.include_tasks: assemble_config.yml diff --git a/geant/gap_ansible/roles/deploy_service_config/vars/main.yml b/geant/gap_ansible/roles/deploy_service_config/vars/main.yml index 5def5f74b90481c8b0e62b06a281ee954dc18eba..60eb6cd460f0fefd2f0d97a563dbf9b70bbdf442 100644 --- a/geant/gap_ansible/roles/deploy_service_config/vars/main.yml +++ b/geant/gap_ansible/roles/deploy_service_config/vars/main.yml @@ -2,6 +2,6 @@ # vars file for deploy_service_config dry_run: true is_verification_workflow: false - -router: "{{ ap.sbp.edge_port.node }}" -vendor: "{{ router.vendor }}" +# +# router: "{{ ap.sbp.edge_port.node }}" +# vendor: "{{ router.vendor }}" diff --git a/geant/gap_ansible/roles/fw_filters/tasks/merge_variables.yaml b/geant/gap_ansible/roles/fw_filters/tasks/merge_variables.yaml index e332f5121481844376651990f764490f0fe8e42d..a481e7f67d4eb8eaa11d8192f764ea7f582d85e5 100644 --- a/geant/gap_ansible/roles/fw_filters/tasks/merge_variables.yaml +++ b/geant/gap_ansible/roles/fw_filters/tasks/merge_variables.yaml @@ -4,7 +4,7 @@ when: >- subscription.product.product_type == "L3CoreService" and - subscription.l3_core_service_type == "GÉANT IP" + subscription.l3_core_service_type in ["GÉANT IP", "GEANT IP", "GEANT_IP"] and ap.sbp.custom_firewall_filters | ansible.builtin.bool block: @@ -21,7 +21,7 @@ when: >- subscription.product.product_type == "L3CoreService" and - subscription.l3_core_service_type == "GÉANT IP" + subscription.l3_core_service_type in ["GÉANT IP", "GEANT IP", "GEANT_IP", "LHCONE"] and not ap.sbp.custom_firewall_filters | ansible.builtin.bool block: diff --git a/geant/gap_ansible/roles/policy_options/tasks/main.yml b/geant/gap_ansible/roles/policy_options/tasks/main.yml index a896fc3be87179891fd46ecdd183b84893db492f..4c3793bf4e7363b0a5edda9144ab7f6361996ef6 100644 --- a/geant/gap_ansible/roles/policy_options/tasks/main.yml +++ b/geant/gap_ansible/roles/policy_options/tasks/main.yml @@ -1,5 +1,21 @@ --- # tasks file for policy_options +- name: Set BGP V4 session object to check for custom policies + when: > + subscription.product.product_type == "L3CoreService" + ansible.builtin.set_fact: + bgp_session_v4: "{{ ap.sbp | json_query(query) }}" + vars: + query: "bgp_session_list[?ip_type == 'ipv4'] | [0]" + +- name: Set BGP V6 session object to check for custom policies + when: > + subscription.product.product_type == "L3CoreService" + ansible.builtin.set_fact: + bgp_session_v6: "{{ ap.sbp | json_query(query) }}" + vars: + query: "bgp_session_list[?ip_type == 'ipv6'] | [0]" + - name: Load Standard Policy Statements vars when: > subscription.product.product_type == "L3CoreService" @@ -7,10 +23,21 @@ subscription.l3_core_service_type in ["GÉANT IP", "GEANT IP", "GEANT_IP"] ansible.builtin.include_tasks: merge_geant_ip_vars.yaml +- name: Load NREN custom VRF policies + when: > + subscription.product.product_type == "L3CoreService" + and + subscription.l3_core_service_type in ["LHCONE"] + and + (bgp_session_v4.has_custom_policies | ansible.builtin.bool + or + bgp_session_v6.has_custom_policies | ansible.builtin.bool) + ansible.builtin.include_tasks: merge_vrf_custom_vars.yaml + - name: Load Standard Policy Options for VRF {{ subscription.vrf.vrf_name }} when: > subscription.product.product_type == "VRF" - ansible.builtin.include_tasks: merge_vrf_vars.yaml + ansible.builtin.include_tasks: merge_vrf_standard_vars.yaml - name: Compile templates ansible.builtin.include_tasks: compile.yaml diff --git a/geant/gap_ansible/roles/policy_options/tasks/merge_vrf_custom_vars.yaml b/geant/gap_ansible/roles/policy_options/tasks/merge_vrf_custom_vars.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e223ce3ace92aafb0e32502f3e3fd9ee5e8ee921 --- /dev/null +++ b/geant/gap_ansible/roles/policy_options/tasks/merge_vrf_custom_vars.yaml @@ -0,0 +1,16 @@ +--- +- name: Set custom PO vars + # when: > + # bgp_session_v6.has_custom_policies | ansible.builtin.bool + block: + - name: Set NREN custom communities + ansible.builtin.set_fact: + po_final_communities: "{{ lookup('community.general.merge_variables', 'CUSTOM_COMMUNITIES') }}" + + # - name: Set NREN custom AS paths + # ansible.builtin.set_fact: + # po_final_aspath: "{{ lookup('community.general.merge_variables', 'CUSTOM_ASPATH') }}" + + - name: Set NREN custom policies + ansible.builtin.set_fact: + po_final_policies: "{{ lookup('community.general.merge_variables', 'CUSTOM_PO_POL_STATEMENTS') }}" diff --git a/geant/gap_ansible/roles/policy_options/tasks/merge_vrf_vars.yaml b/geant/gap_ansible/roles/policy_options/tasks/merge_vrf_standard_vars.yaml similarity index 66% rename from geant/gap_ansible/roles/policy_options/tasks/merge_vrf_vars.yaml rename to geant/gap_ansible/roles/policy_options/tasks/merge_vrf_standard_vars.yaml index 528a7b45777282c5ea0ea905926cca4e170c6811..b832e4e071c5a626303775619b2a24715ba80a06 100644 --- a/geant/gap_ansible/roles/policy_options/tasks/merge_vrf_vars.yaml +++ b/geant/gap_ansible/roles/policy_options/tasks/merge_vrf_standard_vars.yaml @@ -3,6 +3,10 @@ ansible.builtin.set_fact: po_final_prefix_lists: "{{ lookup('community.general.merge_variables', 'STANDARD_VRF_PO_PREFIX_LISTS') }}" +- name: Load Standard Policy Options prefix lists for VRF {{ subscription.vrf.vrf_name }} + ansible.builtin.set_fact: + po_final_communities: "{{ lookup('community.general.merge_variables', 'STANDARD_VRF_COMMUNITIES') }}" + - name: Load Standard Policy Options policies for VRF {{ subscription.vrf.vrf_name }} ansible.builtin.set_fact: po_final_policies: "{{ lookup('community.general.merge_variables', 'STANDARD_VRF_PO_POLICIES') }}" diff --git a/geant/gap_ansible/roles/policy_options/templates/policy_statements.j2 b/geant/gap_ansible/roles/policy_options/templates/policy_statements.j2 index 32570140396d4ae3b13b8daeccea839f4f1f8b39..1dd917a62bfe1083787261f556d87a6abb88ef39 100644 --- a/geant/gap_ansible/roles/policy_options/templates/policy_statements.j2 +++ b/geant/gap_ansible/roles/policy_options/templates/policy_statements.j2 @@ -57,6 +57,11 @@ <add>{{ community }}</add> </community> {% endfor %} + {% elif act_k == "as_path_prepend" %} + <as-path-prepend> + <as-path>{{ act_v.as_path }}</as-path> + <repeat>{{ act_v.repeat }}</repeat> + </as-path-prepend> {% elif act_k == "bgp_med" %} <bgp-med> <set>{{ act_v | default(bgp.standard_metric.med[ap_type]) }}</set> diff --git a/geant/gap_ansible/roles/sbp/templates/deploy_sbp.j2 b/geant/gap_ansible/roles/sbp/templates/deploy_sbp.j2 index cda9f6d5aa5535caa4783b0ddaacf0dde42ce9de..7aa5ef4bcdbac3daa6950773a4b4e35e1b1b94a1 100644 --- a/geant/gap_ansible/roles/sbp/templates/deploy_sbp.j2 +++ b/geant/gap_ansible/roles/sbp/templates/deploy_sbp.j2 @@ -4,11 +4,20 @@ {% endif %} <service 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"> + {% if subscription.l3_core_service_type in ['GEANT_IP', 'GEANT IP'] %} <ies 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"> - <service-name>{{ ies_re_name }}</service-name> + <service-name>{{ ies_re_name }}</service-name> + {% elif subscription.l3_core_service_type in ['LHCONE'] %} + <vprn 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"> + <service-name>{{ vprn_name }}</service-name> + {% endif %} <interface alu:operation="replace"> <interface-name>{{ lag_name }}.{{ ap.sbp.vlan_id }}</interface-name> + {% if subscription.l3_core_service_type in ['GEANT_IP', 'GEANT IP'] %} <description>SRV_GLOBAL CUSTOMER {{ partner_name }} #{{ partner_name }}-{{ ap.ap_type }} ${{ ap.sbp.gs_id }} | ASN{{ partner.asn }} | </description> + {% elif subscription.l3_core_service_type in ['LHCONE'] %} + <description>SRV_L3VPN CUSTOMER {{ partner_name }} #{{ partner_name }}-{{ ap.ap_type }} ${{ ap.sbp.gs_id }} | ASN{{ partner.asn }} | </description> + {% endif %} <ip-mtu>{{ sbp_params.ip_mtu }}</ip-mtu> <sap> {% if ap.sbp.is_tagged %} @@ -19,14 +28,24 @@ <admin-state>enable</admin-state> <ingress> <filter> + {% if subscription.l3_core_service_type in ['GEANT_IP', 'GEANT IP'] %} <ip>{{ partner_name | upper }}_EDGE_IN</ip> <ipv6>{{ partner_name | upper }}_EDGE_IN_V6</ipv6> + {% elif subscription.l3_core_service_type in ['LHCONE'] %} + <ip>LHCONE_{{ partner_name | upper }}_IN</ip> + <ipv6>LHCONE_{{ partner_name | upper }}_IN_V6</ipv6> + {% endif %} </filter> </ingress> <egress> <filter> + {% if subscription.l3_core_service_type in ['GEANT_IP', 'GEANT IP'] %} <ip>{{ partner_name | upper }}_EDGE_OUT</ip> <ipv6>{{ partner_name | upper }}_EDGE_OUT_V6</ipv6> + {% elif subscription.l3_core_service_type in ['LHCONE'] %} + <ip>LHCONE_{{ partner_name | upper }}_OUT</ip> + <ipv6>LHCONE_{{ partner_name | upper }}_OUT_V6</ipv6> + {% endif %} </filter> </egress> </sap> @@ -83,7 +102,11 @@ </address> </ipv6> </interface> + {% if subscription.l3_core_service_type in ['GEANT_IP', 'GEANT IP'] %} </ies> + {% elif subscription.l3_core_service_type in ['LHCONE'] %} + </vprn> + {% endif %} </service> {% if is_standalone_run %} diff --git a/geant/gap_ansible/roles/service_checks/tasks/main.yml b/geant/gap_ansible/roles/service_checks/tasks/main.yml index a6554fdd727299135902a84b2c432195544c666b..848c17d4c864663b5e3435774fe6c93e6c83f495 100644 --- a/geant/gap_ansible/roles/service_checks/tasks/main.yml +++ b/geant/gap_ansible/roles/service_checks/tasks/main.yml @@ -1,5 +1,14 @@ --- # tasks file for service_checks +- name: Import group_vars/all + ansible.builtin.include_vars: + dir: /opt/ansible_inventory/group_vars/all + +- name: Load netconf connection config + ansible.builtin.set_fact: + ansible_connection: "{{ netconf_access[ap.sbp.edge_port.node.vendor].ansible_connection }}" + ansible_network_os: "{{ netconf_access[ap.sbp.edge_port.node.vendor].ansible_network_os }}" + - name: Ping peer via SBP when: object == 'sbp' ansible.builtin.include_tasks: sbp_checks.yaml diff --git a/geant/gap_ansible/roles/vrf/templates/service.j2 b/geant/gap_ansible/roles/vrf/templates/service.j2 index 66a591cd6ae5f57a30967086fc7255e8806b07ac..63f32b15f1ecf53f57a140352e67a3431cfbf7de 100644 --- a/geant/gap_ansible/roles/vrf/templates/service.j2 +++ b/geant/gap_ansible/roles/vrf/templates/service.j2 @@ -1,6 +1,6 @@ <service 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"> -{% with pe_vprns=LHCONE_VPRN %} +{% with pe_vprns=VPRN %} {% include 'router/vprn.j2' %} {% endwith %} </service>