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

Merge branch 'tr_migr2' into 'develop'

deactivate_trunk_side: module update

See merge request !111
parents f74b6ff2 00c72cf0
No related branches found
No related tags found
1 merge request!111deactivate_trunk_side: module update
Pipeline #85849 passed
Showing
with 187 additions and 117 deletions
......@@ -4,13 +4,6 @@
vars:
query: "iptrunk.iptrunk_sides[?iptrunk_side_node.router_fqdn == '{{ inventory_hostname }}'] | [0]"
# - name: Show local info
# debug:
# msg: "{{ local_side }}"
#
# - name: Stop
# meta: end_play
- name: Load netconf connection config
ansible.builtin.set_fact:
ansible_connection: "{{ netconf_access[local_side.iptrunk_side_node.vendor].ansible_connection }}"
......
......@@ -20,7 +20,17 @@
mode: '0755'
delegate_to: localhost
- name: Print the template in "/var/tmp/ansible_run_{{ opid }}/{{ config_object }}.conf"
- name: Print template for the old node "{{ old_node.fqdn }}" in "/var/tmp/ansible_run_{{ opid }}/{{ config_object }}.conf"
ansible.builtin.template:
src: "{{ old_node.vendor }}/{{ config_object }}.j2"
dest: "/var/tmp/ansible_run_{{ opid }}/{{ config_object }}.conf"
lstrip_blocks: true
trim_blocks: true
mode: '0755'
delegate_to: localhost
when: (verb == "delete" or verb == "deactivate") and inventory_hostname != new_node.router.router_fqdn
- name: Print template for the new node in "/var/tmp/ansible_run_{{ opid }}/{{ config_object }}.conf"
ansible.builtin.template:
src: "{{ new_node.router.vendor }}/{{ config_object }}.j2"
dest: "/var/tmp/ansible_run_{{ opid }}/{{ config_object }}.conf"
......@@ -28,6 +38,7 @@
trim_blocks: true
mode: '0755'
delegate_to: localhost
when: (verb == "deploy") and inventory_hostname == new_node.router.router_fqdn
- name: Set netconf connection for trunk nodes
ansible.builtin.include_tasks: set_netconf_connection.yaml
......
---
- name: Deactivate Trunk interface on "{{ inventory_hostname }}" [CHECK ONLY][JUNIPER]
juniper_junos_config:
load: 'replace'
junipernetworks.junos.junos_config:
update: 'replace'
src: "/var/tmp/ansible_run_{{ opid }}/{{ config_object }}.conf"
format: set
config_mode: "private"
check: true
commit: false
register: response
src_format: set
check_commit: true
diff: true
when: >
verb == "deactivate" and
local_side.iptrunk_side_node.vendor == "juniper" and
dry_run | ansible.builtin.bool
- name: Show DRY diff of "{{ config_object }}"
ansible.builtin.debug:
msg: "{{ response }}"
when: >
verb == "deactivate"
and dry_run | ansible.builtin.bool and
local_side.iptrunk_side_node.vendor == "juniper"
- name: Deactivate Trunk interface on "{{ inventory_hostname }}" [AND COMMIT][JUNIPER]
juniper_junos_config:
load: 'replace'
junipernetworks.junos.junos_config:
update: 'replace'
src: "/var/tmp/ansible_run_{{ opid }}/{{ config_object }}.conf"
format: set
config_mode: "private"
commit: true
src_format: set
comment: "{{ commit_comment }}"
register: response
when: >
verb == "deactivate" and
local_side.iptrunk_side_node.vendor == "juniper" and
not (dry_run | ansible.builtin.bool)
- name: Show real diff of "{{ config_object }}"
ansible.builtin.debug:
msg: "{{ response }}"
diff: true
when: >
verb == "deactivate" and
local_side.iptrunk_side_node.vendor == "juniper" and
......
---
- name: Delete Trunk interface on "{{ inventory_hostname }}" [CHECK ONLY][JUNIPER]
juniper_junos_config:
load: 'replace'
junipernetworks.junos.junos_config:
update: 'replace'
src: "/var/tmp/ansible_run_{{ opid }}/{{ config_object }}.conf"
format: set
config_mode: "private"
check: true
commit: false
register: response
src_format: set
check_commit: true
diff: true
when: >
verb == "delete" and
local_side.iptrunk_side_node.vendor == "juniper" and
dry_run | ansible.builtin.bool
- name: Show DRY diff of "{{ config_object }}"
ansible.builtin.debug:
msg: "{{ response }}"
when: >
verb == "delete"
and dry_run | ansible.builtin.bool and
local_side.iptrunk_side_node.vendor == "juniper"
- name: Delete Trunk interface on "{{ inventory_hostname }}" [AND COMMIT][JUNIPER]
juniper_junos_config:
load: 'replace'
junipernetworks.junos.junos_config:
update: 'replace'
src: "/var/tmp/ansible_run_{{ opid }}/{{ config_object }}.conf"
format: set
config_mode: "private"
commit: true
src_format: set
comment: "{{ commit_comment }}"
register: response
when: >
verb == "delete" and
local_side.iptrunk_side_node.vendor == "juniper" and
not (dry_run | ansible.builtin.bool)
- name: Show real diff of "{{ config_object }}"
ansible.builtin.debug:
msg: "{{ response }}"
diff: true
when: >
verb == "delete" and
local_side.iptrunk_side_node.vendor == "juniper" and
......
---
- name: Deploy "{{ config_object }}" on "{{ inventory_hostname }}" [CHECK ONLY][JUNIPER]
juniper_junos_config:
load: 'replace'
junipernetworks.junos.junos_config:
update: 'replace'
src: "/var/tmp/ansible_run_{{ opid }}/{{ config_object }}.conf"
format: text
config_mode: "private"
check: true
commit: false
register: response
src_format: set
check_commit: true
diff: true
when: >
verb == "deploy" and
new_node.router.vendor == "juniper" and
dry_run | ansible.builtin.bool
- name: Show DRY diff of "{{ config_object }}"
ansible.builtin.debug:
msg: "{{ response }}"
when: >
verb == "deploy"
and dry_run | ansible.builtin.bool and
new_node.router.vendor == "juniper"
- name: Deploy "{{ config_object }}" on "{{ inventory_hostname }}" [AND COMMIT][JUNIPER]
juniper_junos_config:
load: 'replace'
junipernetworks.junos.junos_config:
update: 'replace'
src: "/var/tmp/ansible_run_{{ opid }}/{{ config_object }}.conf"
format: text
config_mode: "private"
commit: true
src_format: set
comment: "{{ commit_comment }}"
register: response
diff: true
when: >
verb == "deploy" and
new_node.router.vendor == "juniper" and
not (dry_run | ansible.builtin.bool)
- name: Show real diff of "{{ config_object }}"
ansible.builtin.debug:
msg: "{{ response }}"
- name: Deploy "{{ config_object }}" on "{{ inventory_hostname }}" [CHECK ONLY][NOKIA]
ansible.netcommon.netconf_config:
format: xml
default_operation: merge
content: "{{ lookup('ansible.builtin.template', '{{ new_node.router.vendor }}/{{ config_object }}.j2') }}"
commit: true
diff: true
check_mode: true
when: >
verb == "deploy" and
new_node.router.vendor == "juniper" and
not (dry_run | ansible.builtin.bool)
( dry_run | ansible.builtin.bool ) is true and
new_node.router.vendor == "nokia"
- name: Deploy base_config on "{{ inventory_hostname }}" [AND COMMIT][NOKIA]
ansible.netcommon.netconf_config:
format: xml
default_operation: merge
content: "{{ lookup('ansible.builtin.template', '{{ new_node.router.vendor }}/{{ config_object }}.j2') }}"
commit: true
diff: true
check_mode: false
when: >
verb == "deploy" and
( dry_run | ansible.builtin.bool ) is false and
new_node.router.vendor == "nokia"
......@@ -21,17 +21,9 @@
opid: "{{ lookup('community.general.random_string', length=18, special=false) }}"
config_is_different: "False"
- name: Lets take a look at trunk
ansible.builtin.debug:
msg: "{{ wfo_trunk }}"
# - name: Lets take a look at trunk
# ansible.builtin.debug:
# msg: "{{ trunks[0] }}"
- name: The old node is
ansible.builtin.debug:
msg: "{{ old_node }}"
msg: "{{ old_node.fqdn }}"
- name: The new node is
ansible.builtin.debug:
......@@ -62,26 +54,23 @@
ansible.builtin.debug:
msg: "{{ opid }}"
- name: Include compiling the template
- name: Include compiling the template for the old node
ansible.builtin.include_tasks: compile_template.yaml
when: verb == "deactivate" and inventory_hostname == old_node
- name: Include compiling the template
ansible.builtin.include_tasks: compile_template.yaml
when: verb == "delete" and inventory_hostname == old_node
when: (verb == "deactivate" or verb == "delete")
and inventory_hostname == old_node
- name: Include compiling the template
ansible.builtin.include_tasks: compile_template.yaml
when: verb == "deploy" and inventory_hostname == new_node.router.router_fqdn
- name: Include the modification tasks if specified
- name: Include deactivation tasks for the old node
ansible.builtin.include_tasks: deactivate_trunk_side.yaml
when: verb == "deactivate" and inventory_hostname == old_node
- name: Include the removal tasks if specified
- name: Include removal tasks for the old node
ansible.builtin.include_tasks: delete_trunk_side.yaml
when: verb == "delete" and inventory_hostname == old_node
- name: Include compiling the template for the new node
ansible.builtin.include_tasks: compile_template.yaml
when: verb == "deploy" and inventory_hostname == new_node.router.router_fqdn
- name: Include the deployment tasks if specified
ansible.builtin.include_tasks: deploy_object.yaml
when: verb == "deploy" and inventory_hostname == new_node.router.router_fqdn
deactivate protocols isis interface {{ local_side.iptrunk_side_ae_iface }}.0
deactivate interfaces {{ local_side.iptrunk_side_ae_iface }}
{% for iface in local_side.iptrunk_side_ae_members %}
deactivate interfaces {{ iface }}
deactivate protocols lldp interface {{ iface }}
deactivate interfaces {{ iface.interface_name }}
deactivate protocols lldp interface {{ iface.interface_name }}
{% endfor %}
<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">
<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>
<isis 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">
<isis-instance>0</isis-instance>
<interface 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" alu:operation="replace">
<interface-name>{{ new_side.ae_name | lower }}.0</interface-name>
<admin-state>enable</admin-state>
<interface-type>point-to-point</interface-type>
<level-capability>2</level-capability>
<level>
<level-number>2</level-number>
<metric>{{ new_side.isis_metric }}</metric>
</level>
</interface>
</isis>
</router>
</configure>
</config>
<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">
{##}
{% for member in new_side.members %}
<port 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" alu:operation="replace">
<port-id>{{ member.interface_name }}</port-id>
<admin-state>enable</admin-state>
<description>PHY INFRASTRUCTURE BACKBONE P_{{ new_side.ae_name }} | {{ new_side.description }} | {{ member.interface_description }}</description>
<ethernet>
<mode>network</mode>
<mtu>9212</mtu>
<lldp>
<dest-mac>
<mac-type>nearest-bridge</mac-type>
<receive>true</receive>
<transmit>true</transmit>
<tx-tlvs>
<port-desc>true</port-desc>
<sys-name>true</sys-name>
<sys-cap>true</sys-cap>
</tx-tlvs>
</dest-mac>
</lldp>
</ethernet>
</port>
{% endfor %}
<lag 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" alu:operation="replace">
<lag-name>{{ new_side.ae_name | lower }}</lag-name>
<admin-state>enable</admin-state>
<description>LAG INFRASTRUCTURE BACKBONE ${{ new_side.port_sid }} | {{ new_side.description }}</description>
<mode>network</mode>
<lacp>
<mode>active</mode>
<administrative-key>{{ (new_side.ae_name|split("-"))[1] }}</administrative-key>
</lacp>
{% for member in new_side.members %}
<port>
<port-id>{{ member.interface_name }}</port-id>
</port>
{% endfor %}
</lag>
<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>
<interface alu:operation="replace">
<interface-name>{{ new_side.ae_name | lower }}.0</interface-name>
<admin-state>enable</admin-state>
<description>SRV_GLOBAL INFRASTRUCTURE BACKBONE #{{ new_side.description }}-IPTRUNK ${{ new_side.id }}| </description>
<ip-mtu>9000</ip-mtu>
<port>{{ new_side.ae_name | lower }}</port>
<ipv4>
<primary>
<address>{{(new_ipv4_address| split('/'))[0]}}</address>
<prefix-length>{{(new_ipv4_address| split('/'))[1]}}</prefix-length>
</primary>
</ipv4>
<ipv6>
<address>
<ipv6-address>{{(new_ipv6_address| split('/'))[0]}}</ipv6-address>
<prefix-length>{{(new_ipv6_address| split('/'))[1]}}</prefix-length>
</address>
</ipv6>
<qos>
<network-policy>GEANT_BASIC</network-policy>
</qos>
</interface>
{# Add new LAG trunk into standard protocols #}
<mpls 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>{{ new_side.ae_name | lower }}.0</interface-name>
</interface>
</mpls>
<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>{{ new_side.ae_name | lower }}.0</interface-name>
</interface>
</pim>
<rsvp 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>{{ new_side.ae_name | lower }}.0</interface-name>
{# <refresh-reduction> #}
{# <reliable-delivery>true</reliable-delivery> #}
{# </refresh-reduction> #}
</interface>
</rsvp>
</router>
</configure>
</config>
......@@ -21,7 +21,9 @@ side_a_ipv6_address: "{{ wfo_trunk.iptrunk.iptrunk_ipv6_network | ansible.utils.
side_b_ipv4_address: "{{ wfo_trunk.iptrunk.iptrunk_ipv4_network | ansible.utils.ipaddr('net') | ansible.utils.ipaddr('1') | ansible.utils.ipaddr('address') }}/31"
side_b_ipv6_address: "{{ wfo_trunk.iptrunk.iptrunk_ipv6_network | ansible.utils.ipaddr('net') | ansible.utils.ipaddr('2') | ansible.utils.ipaddr('address') }}/126"
old_node: "{{ wfo_trunk.iptrunk.iptrunk_sides[replace_index | int].iptrunk_side_node.router_fqdn }}"
old_node:
fqdn: "{{ wfo_trunk.iptrunk.iptrunk_sides[replace_index | int].iptrunk_side_node.router_fqdn }}"
vendor: "{{ wfo_trunk.iptrunk.iptrunk_sides[replace_index | int].iptrunk_side_node.vendor }}"
new_side:
id: "{{ wfo_trunk.iptrunk.geant_s_sid }}"
......@@ -35,5 +37,5 @@ new_side:
loopback: "{{ wfo_trunk.iptrunk.iptrunk_sides[replace_index | int].iptrunk_side_node.router_lo_ipv4_address }}"
ae_name: "{{ new_lag_interface }}"
members: "{{ new_lag_member_interfaces }}"
members_descriptions: "{{ wfo_trunk.iptrunk.iptrunk_sides[replace_index | int].iptrunk_side_ae_members_description }}"
# members_descriptions: "{{ wfo_trunk.iptrunk.iptrunk_sides[replace_index | int].iptrunk_side_ae_members_description }}"
port_sid: "{{ wfo_trunk.iptrunk.iptrunk_sides[replace_index | int].iptrunk_side_ae_geant_a_sid }}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment