From 860ff2bb12bcab76559e3cf536505d79f278b21c Mon Sep 17 00:00:00 2001 From: Simone Spinelli <simone.spinelli@geant.org> Date: Mon, 8 Jan 2024 14:33:04 +0100 Subject: [PATCH] Fix IPtrunk to use iptrunk sides members in the last format --- geant/gap_ansible/playbooks/iptrunks.yaml | 2 +- .../iptrunk/templates/juniper/trunk_deprovision.j2 | 6 +++--- .../iptrunk/templates/juniper/trunk_interface.j2 | 12 ++++++------ .../iptrunk/templates/nokia/trunk_deprovision.j2 | 6 +++--- .../roles/iptrunk/templates/nokia/trunk_interface.j2 | 10 +++++----- geant/gap_ansible/roles/iptrunk/vars/main.yml | 2 -- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/geant/gap_ansible/playbooks/iptrunks.yaml b/geant/gap_ansible/playbooks/iptrunks.yaml index 325bacc2..7a4bee41 100644 --- a/geant/gap_ansible/playbooks/iptrunks.yaml +++ b/geant/gap_ansible/playbooks/iptrunks.yaml @@ -1,6 +1,6 @@ - name: Manage iptrunks playbook hosts: all - remote_user: admin + remote_user: {{ automation_user }} gather_facts: false roles: - Juniper.junos diff --git a/geant/gap_ansible/roles/iptrunk/templates/juniper/trunk_deprovision.j2 b/geant/gap_ansible/roles/iptrunk/templates/juniper/trunk_deprovision.j2 index 06bc6d4b..721c632f 100644 --- a/geant/gap_ansible/roles/iptrunk/templates/juniper/trunk_deprovision.j2 +++ b/geant/gap_ansible/roles/iptrunk/templates/juniper/trunk_deprovision.j2 @@ -8,9 +8,9 @@ {% if local is defined %} delete protocols isis interface {{ local.ae_name }} delete interfaces {{ local.ae_name }} - {% for iface in local.members %} -delete interfaces {{ iface }} -delete protocols lldp interface {{ iface }} + {% for member in local.members %} +delete interfaces {{ member.interface_name }} +delete protocols lldp interface {{ member.interface_name }} {% endfor %} {% endif %} {% endfor %} diff --git a/geant/gap_ansible/roles/iptrunk/templates/juniper/trunk_interface.j2 b/geant/gap_ansible/roles/iptrunk/templates/juniper/trunk_interface.j2 index 871efb41..6b4dc11e 100644 --- a/geant/gap_ansible/roles/iptrunk/templates/juniper/trunk_interface.j2 +++ b/geant/gap_ansible/roles/iptrunk/templates/juniper/trunk_interface.j2 @@ -16,7 +16,7 @@ {% if local is defined %} {##} - {# I need to sort the source and the destination alfabetically #} + {# I need to sort the source and the destination alfabetically #} {% set trunk_direction_name = [ local.name.split(".")[1] | upper, remote.name.split(".")[1] | upper ] %} {% set trunk_direction_name_sorted = trunk_direction_name|sort %} {##} @@ -49,7 +49,7 @@ } mtu 9000; filter { - input bone-in; + input bone-in; output bone-out; } address {{local.ipv4_address}}; @@ -67,10 +67,10 @@ maximum-labels 5; } } - } + } {% for member in local.members %} - replace: {{member}} { - description "PHY INFRASTRUCTURE BACKBONE P_{{local.ae_name}} | {{ trunk_direction_name_sorted[0] }}-{{ trunk_direction_name_sorted[1] }} | {{local.members_descriptions[loop.index0]}}"; + replace: {{ member.interface_name }} { + description "PHY INFRASTRUCTURE BACKBONE P_{{local.ae_name}} | {{ trunk_direction_name_sorted[0] }}-{{ trunk_direction_name_sorted[1] }} | {{ member.interface_description }}"; gigether-options { 802.3ad {{local.ae_name}}; } @@ -82,7 +82,7 @@ {% for member in local.members %} replace: interface {{member}} ; {% endfor %} - + } } {% endif %} diff --git a/geant/gap_ansible/roles/iptrunk/templates/nokia/trunk_deprovision.j2 b/geant/gap_ansible/roles/iptrunk/templates/nokia/trunk_deprovision.j2 index 76565e69..0ceb1122 100644 --- a/geant/gap_ansible/roles/iptrunk/templates/nokia/trunk_deprovision.j2 +++ b/geant/gap_ansible/roles/iptrunk/templates/nokia/trunk_deprovision.j2 @@ -23,9 +23,9 @@ {% for member in local.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="delete"> - <port-id>{{ member }}</port-id> + <port-id>{{ member.interface_name }}</port-id> <admin-state>enable</admin-state> - <description>PHY INFRASTRUCTURE BACKBONE P_{{local.ae_name}} | {{ trunk_direction_name_sorted[0] }}-{{ trunk_direction_name_sorted[1] }} | {{local.members_descriptions[loop.index0]}}</description> + <description>PHY INFRASTRUCTURE BACKBONE P_{{local.ae_name}} | {{ trunk_direction_name_sorted[0] }}-{{ trunk_direction_name_sorted[1] }} | {{ member.interface_description }}</description> <ethernet> <mode>network</mode> <mtu>9212</mtu> @@ -55,7 +55,7 @@ </lacp> {% for member in local.members %} <port> - <port-id>{{member}}</port-id> + <port-id>{{ member.interface_name }}</port-id> </port> {% endfor %} </lag> diff --git a/geant/gap_ansible/roles/iptrunk/templates/nokia/trunk_interface.j2 b/geant/gap_ansible/roles/iptrunk/templates/nokia/trunk_interface.j2 index 646bca6f..1736f783 100644 --- a/geant/gap_ansible/roles/iptrunk/templates/nokia/trunk_interface.j2 +++ b/geant/gap_ansible/roles/iptrunk/templates/nokia/trunk_interface.j2 @@ -23,9 +23,9 @@ {% for member in local.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 }}</port-id> + <port-id>{{ member.interface_name }}</port-id> <admin-state>enable</admin-state> - <description>PHY INFRASTRUCTURE BACKBONE P_{{local.ae_name}} | {{ trunk_direction_name_sorted[0] }}-{{ trunk_direction_name_sorted[1] }} | {{local.members_descriptions[loop.index0]}}</description> + <description>PHY INFRASTRUCTURE BACKBONE P_{{ local.ae_name }} | {{ trunk_direction_name_sorted[0] }}-{{ trunk_direction_name_sorted[1] }} | {{ member.interface_description }}</description> <ethernet> <mode>network</mode> <mtu>9212</mtu> @@ -45,17 +45,17 @@ </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>{{local.ae_name}}</lag-name> + <lag-name>{{ local.ae_name }}</lag-name> <admin-state>enable</admin-state> <description>LAG INFRASTRUCTURE BACKBONE ${{ local.port_sid }} | {{ trunk_direction_name_sorted[0] }}-{{ trunk_direction_name_sorted[1] }}</description> <mode>network</mode> <lacp> <mode>active</mode> - <administrative-key>{{(local.ae_name|split("-"))[1]}}</administrative-key> + <administrative-key>{{ (local.ae_name|split("-"))[1] }}</administrative-key> </lacp> {% for member in local.members %} <port> - <port-id>{{member}}</port-id> + <port-id>{{ member.interface_description }}</port-id> </port> {% endfor %} </lag> diff --git a/geant/gap_ansible/roles/iptrunk/vars/main.yml b/geant/gap_ansible/roles/iptrunk/vars/main.yml index 85c13987..8160e437 100644 --- a/geant/gap_ansible/roles/iptrunk/vars/main.yml +++ b/geant/gap_ansible/roles/iptrunk/vars/main.yml @@ -45,7 +45,6 @@ trunks: ipv4_address: "{{ side_a_ipv4_address }}" ipv6_address: "{{ side_a_ipv6_address }}" members: "{{ wfo_trunk.iptrunk.iptrunk_sides[0].iptrunk_side_ae_members }}" - members_descriptions: "{{ wfo_trunk.iptrunk.iptrunk_sides[0].iptrunk_side_ae_members_description }}" port_sid: "{{ wfo_trunk.iptrunk.iptrunk_sides[0].iptrunk_side_ae_geant_a_sid }}" nodeB: name: "{{ wfo_trunk.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn }}" @@ -55,5 +54,4 @@ trunks: ipv4_address: "{{ side_b_ipv4_address }}" ipv6_address: "{{ side_b_ipv6_address }}" members: "{{ wfo_trunk.iptrunk.iptrunk_sides[1].iptrunk_side_ae_members }}" - members_descriptions: "{{ wfo_trunk.iptrunk.iptrunk_sides[1].iptrunk_side_ae_members_description }}" port_sid: "{{ wfo_trunk.iptrunk.iptrunk_sides[1].iptrunk_side_ae_geant_a_sid }}" -- GitLab