Skip to content
Snippets Groups Projects
Commit 6b7f148f authored by Aleksandr Kurbatov's avatar Aleksandr Kurbatov
Browse files

Updates to `promote_p_to_pe` role

parent acd1fb48
No related branches found
No related tags found
1 merge request!162promote-p-to-pe role
Showing
with 123 additions and 12 deletions
- name: Set variable to connect to nokia
ansible.builtin.set_fact:
ansible_network_os: nokia.sros.md
ansible_connection: netconf
- name: Check VPRN BGP summary
block:
- name: Get BGP summary
ansible.netcommon.netconf_rpc:
rpc: action
xmlns: "urn:ietf:params:xml:ns:yang:1"
content: |
<global-operations xmlns="urn:nokia.com:sros:ns:yang:sr:oper-global">
<md-cli-raw-command>
<md-cli-input-line>show router service-name "{{ vprn.name | quote }}" bgp summary</md-cli-input-line>
</md-cli-raw-command>
</global-operations>
display: json
register: out
- name: Show BGP summary for VPRN "{{ vprn.name | quote }}"
ansible.builtin.debug:
msg: "{{out.output['rpc-reply']['nokiaoper:results']['nokiaoper:md-cli-output-block'].split('\n')}}"
...@@ -44,6 +44,16 @@ ...@@ -44,6 +44,16 @@
mode: '0755' mode: '0755'
delegate_to: localhost delegate_to: localhost
- name: Print the template in "/var/tmp/ansible_run_{{ opid }}/delete_default_static_routes.conf"
when: verb == "delete_default_routes"
ansible.builtin.template:
src: "routers/{{ subscription.router.vendor }}/router/delete_default_static_routes.j2"
dest: "/var/tmp/ansible_run_{{ opid }}/delete_default_static_routes.conf"
lstrip_blocks: true
trim_blocks: true
mode: '0755'
delegate_to: localhost
- name: Set back ansible_host to target terminal server if needed - name: Set back ansible_host to target terminal server if needed
when: when:
subscription.router.router_access_via_ts | ansible.builtin.bool subscription.router.router_access_via_ts | ansible.builtin.bool
......
...@@ -39,6 +39,21 @@ ...@@ -39,6 +39,21 @@
diff: true diff: true
register: output register: output
check_mode: true check_mode: true
- name: Delete default routes on "{{ inventory_hostname }}" [CHECK ONLY][NOKIA]
when: >-
dry_run | ansible.builtin.bool
and verb == "delete_default_routes"
geant.gap_ansible.nokia_netconf_config:
format: xml
default_operation: merge
content: "{{ lookup('ansible.builtin.template', 'routers/{{ subscription.router.vendor }}/router/delete_default_static_routes.j2') }}"
commit: true
validate: true
diff: true
register: output
check_mode: true
# - name: Fail if there is any diff # - name: Fail if there is any diff
# ansible.builtin.fail: # ansible.builtin.fail:
# msg: Base config drift detected!!! # msg: Base config drift detected!!!
...@@ -85,3 +100,16 @@ ...@@ -85,3 +100,16 @@
commit_comment: "{{ commit_comment }}" commit_comment: "{{ commit_comment }}"
diff: true diff: true
check_mode: false check_mode: false
- name: Delete default routes on "{{ inventory_hostname }}" [AND COMMIT][NOKIA]
when: >-
not (dry_run | ansible.builtin.bool)
and verb == "delete_default_routes"
geant.gap_ansible.nokia_netconf_config:
format: xml
default_operation: merge
content: "{{ lookup('ansible.builtin.template', 'routers/{{ subscription.router.vendor }}/router/delete_default_static_routes.j2') }}"
commit: true
commit_comment: "{{ commit_comment }}"
diff: true
check_mode: false
...@@ -49,13 +49,20 @@ ...@@ -49,13 +49,20 @@
ansible.builtin.include_tasks: configure_isis_overload.yaml ansible.builtin.include_tasks: configure_isis_overload.yaml
- name: Include templates compilation - name: Include templates compilation
when: verb in [ 'deploy_pe_base_config', 'update_sdp_mesh' , 'deploy_routing_instances' ] when: verb in [ 'deploy_pe_base_config', 'update_sdp_mesh' , 'deploy_routing_instances', 'delete_default_routes' ]
ansible.builtin.include_tasks: compile_pe_base_config.yaml ansible.builtin.include_tasks: compile.yaml
- name: Include deploy if selected - name: Include deploy if selected
when: verb in [ 'deploy_pe_base_config', 'update_sdp_mesh', 'deploy_routing_instances' ] when: verb in [ 'deploy_pe_base_config', 'update_sdp_mesh', 'deploy_routing_instances', 'delete_default_routes' ]
ansible.builtin.include_tasks: deploy_pe_base_config.yaml ansible.builtin.include_tasks: deploy.yaml
- name: Include deletion of default static routes # - name: Include deletion of default static routes
when: verb == "delete_default_routes" # when: verb == "delete_default_routes"
ansible.builtin.include_tasks: delete_default_routes.yaml # ansible.builtin.include_tasks: delete_default_routes.yaml
#
- name: Check VPRNs
when: verb == "check_base_ris"
loop: "{{ pe_vprns }}"
loop_control:
loop_var: vprn
ansible.builtin.include_tasks: check_routing_instances.yaml
...@@ -24,3 +24,16 @@ ...@@ -24,3 +24,16 @@
- name: Select SDP params for l2ciruit-type - name: Select SDP params for l2ciruit-type
ansible.builtin.set_fact: ansible.builtin.set_fact:
sdp_type: "{{ (sdp_types | selectattr('id', 'equalto', '1'))[0] }}" sdp_type: "{{ (sdp_types | selectattr('id', 'equalto', '1'))[0] }}"
- name: Prepare PE-specific base config vars
when: verb == "deploy_routing_instances"
block:
- name: Combine P and PE prefix-lists
ansible.builtin.set_fact:
nokia_prefix_lists: "{{ [nokia_prefix_lists, nokia_pe_prefix_lists, nokia_pe_ias_prefix_lists] | community.general.lists_mergeby('name',
list_merge='append') }}"
- name: Select SDP params for l2ciruit (epipe) type
when: verb == "update_sdp_mesh"
ansible.builtin.set_fact:
sdp_type: "{{ (sdp_types | selectattr('id', 'equalto', '1'))[0] }}"
<filter 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 pe_filter_logs is defined %}
{% for log in pe_filter_logs %}
<log alu:operation="replace">
<log-id>{{ log.id }}</log-id>
<description>{{ log.description }}</description>
<destination>
{% if log.destination == 'syslog' %}
<syslog>
<name>1</name>
</syslog>
{% endif %}
</destination>
</log>
{% endfor %}
{% endif %}
</filter>
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:alu="urn:ietf:params:xml:ns:netconf:base:1.0"> <config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:alu="urn:ietf:params:xml:ns:netconf:base:1.0">
<configure xmlns="urn:nokia.com:sros:ns:yang:sr:conf"> <configure xmlns="urn:nokia.com:sros:ns:yang:sr:conf">
{% include 'filter_log.j2' %}
{% include 'ip_prefix_list.j2' %} {% include 'ip_prefix_list.j2' %}
{% include 'filters/cpm_filters.j2' %} {% include 'filters/cpm_filters.j2' %}
{% include 'policy_options/policy_options.j2' %} {% include 'policy_options/policy_options.j2' %}
......
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:alu="urn:ietf:params:xml:ns:netconf:base:1.0"> <config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:alu="urn:ietf:params:xml:ns:netconf:base:1.0">
<configure xmlns="urn:nokia.com:sros:ns:yang:sr:conf"> <configure xmlns="urn:nokia.com:sros:ns:yang:sr:conf">
{% include 'router/vprn.j2' %} {% include 'service_vprn.j2' %}
</configure> </configure>
</config> </config>
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
{% for route in nokia_static_routes %} {% for route in nokia_static_routes %}
<route alu:operation="delete"> <route alu:operation="delete">
<ip-prefix>{{ route.ip_prefix }}</ip-prefix> <ip-prefix>{{ route.ip_prefix }}</ip-prefix>
<route-type>{{ route.route_type }}</route-type>
</route> </route>
{% endfor %} {% endfor %}
</static-routes> </static-routes>
......
<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">
{% for vprn in pe_vprns %} {% for vprn in pe_vprns %}
<vprn alu:operation="replace"> <vprn alu:operation="replace">
<service-name>{{ vprn.name }}</service-name> <service-name>{{ vprn.name }}</service-name>
...@@ -56,5 +55,4 @@ ...@@ -56,5 +55,4 @@
{% endif %} {% endif %}
</vprn> </vprn>
{% endfor %} {% endfor %}
</service>
<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"> <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">
<sdp>
{% for pe_fqdn, pe_addr in pe_router_list.items() %} {% for pe_fqdn, pe_addr in pe_router_list.items() %}
{% set sdp_id = pe_addr.lo4 | replace(sdp_prefix_regex, '') | replace('.', '') + sdp_type.id %} {% set sdp_id = pe_addr.lo4 | replace(sdp_prefix_regex, '') | replace('.', '') + sdp_type.id %}
<sdp>
<sdp-id>{{ sdp_id }}</sdp-id> <sdp-id>{{ sdp_id }}</sdp-id>
<admin-state>enable</admin-state> <admin-state>enable</admin-state>
<description>SDP_{{ sdp_id }}</description> <description>SDP_{{ sdp_id }}</description>
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<far-end> <far-end>
<ip-address>{{ pe_addr.lo4 }}</ip-address> <ip-address>{{ pe_addr.lo4 }}</ip-address>
</far-end> </far-end>
{% endfor %}
</sdp> </sdp>
{% endfor %}
</service> </service>
<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">
<md-auto-id>
<service-id-range alu:operation="replace">
<start>{{ pe_service.md_auto_id.service_id_range.start | default('10001') }}</start>
<end>{{ pe_service.md_auto_id.service_id_range.end | default('19999') }}</end>
</service-id-range>
</md-auto-id>
{% include 'router/vprn.j2' %}
</service>
{% include 'ip_prefix_list.j2' %}
...@@ -8,6 +8,7 @@ verbs: ...@@ -8,6 +8,7 @@ verbs:
- delete_default_routes # Delete default static routes configured as part P base-config - delete_default_routes # Delete default static routes configured as part P base-config
- deploy_routing_instances # Deploy standard PE VPRNs - deploy_routing_instances # Deploy standard PE VPRNs
- update_sdp_mesh # Upadate SDP mesh on other Nokia PE routers with this promoted router - update_sdp_mesh # Upadate SDP mesh on other Nokia PE routers with this promoted router
- check_base_ris # Check BGP summary for base VPRNs
lo_ipv4_address: "{{ subscription.router.router_lo_ipv4_address }}" lo_ipv4_address: "{{ subscription.router.router_lo_ipv4_address }}"
lo_ipv6_address: "{{ subscription.router.router_lo_ipv6_address }}" lo_ipv6_address: "{{ subscription.router.router_lo_ipv6_address }}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment