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>