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

Merge branch 'feature/nat-133-edge-port' into 'develop'

Updates to the edge_port role

See merge request !184
parents 52b40c6b d7bb3675
No related branches found
No related tags found
1 merge request!184Updates to the edge_port role
Pipeline #89892 passed
Showing
with 369 additions and 0 deletions
- name: Create Edge Port
hosts: all
gather_facts: false
roles:
- ../roles/edge_port
Role Name
=========
A role for configuring Edge (access) ports on Nokia SR routers.
Requirements
------------
GEANT custom netconf module with Nokia "commit_comment" and "config_mode" features.
Role Variables
--------------
- vars/main.yaml
- external inventory (group_vars)
- orchestrator (GSO)
Dependencies
------------
n/a
Example Playbook
----------------
Role is supposed to be driven by GSO.
License
-------
MIT
Author Information
------------------
A. Kurbatov, S. Spinelli. GEANT Orchestration and Automation Team (GOAT).
---
# defaults file for edge_port
---
# handlers file for edge_port
galaxy_info:
author: A. Kurbatov, S. Spinelli
description: GEANT Orchestration and Automation Team
company: GEANT
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: MIT
min_ansible_version: '2.10'
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
galaxy_tags:
- network
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
collections:
- geant.gap_ansible
---
- name: Set ansible host to localhost to compile config when router is offline
when:
router.router_access_via_ts | ansible.builtin.bool
ansible.builtin.set_fact:
ansible_host: "localhost"
ansible_connection: local
- name: Create a folder for all the things
ansible.builtin.file:
path: "/var/tmp/ansible_run_{{ opid }}"
state: directory
mode: '0755'
delegate_to: localhost
- name: Print the template in "/var/tmp/ansible_run_{{ opid }}/edge_port_{{ verb }}.conf"
when: verb == "create"
ansible.builtin.template:
src: "{{ router.vendor }}/edge_port_{{ verb }}.j2"
dest: "/var/tmp/ansible_run_{{ opid }}/edge_port_{{ verb }}.conf"
lstrip_blocks: true
trim_blocks: true
mode: '0755'
delegate_to: localhost
---
- name: Set ansible_host to terminal server when router is offline
when: router.router_access_via_ts | ansible.builtin.bool
ansible.builtin.set_fact:
ansible_host: "{{ router.router_site.site_ts_address }}"
ansible_port: "{{ router.router_ts_port }}"
- name: Load netconf connection config
ansible.builtin.set_fact:
ansible_connection: "{{ netconf_access[router.vendor].ansible_connection }}"
ansible_network_os: "{{ netconf_access[router.vendor].ansible_network_os }}"
---
- name: Perform "{{ verb }}" Edge port on "{{ inventory_hostname }}" [CHECK ONLY][NOKIA]
when: >-
dry_run | ansible.builtin.bool
geant.gap_ansible.nokia_netconf_config:
format: xml
default_operation: merge
content: "{{ lookup('ansible.builtin.template', '{{ router.vendor }}/edge_port_{{ verb }}.j2') }}"
commit: true
validate: true
config_mode: private
diff: true
register: output
check_mode: true
- name: Fail if there is any diff
ansible.builtin.fail:
msg: Base config drift detected!!!
when: >
output.changed | ansible.builtin.bool
and
is_verification_workflow | ansible.builtin.bool
- name: Perform "{{ verb }}" Edge port on "{{ inventory_hostname }}" [FOR REAL][NOKIA]
when: >-
not (dry_run | ansible.builtin.bool)
geant.gap_ansible.nokia_netconf_config:
format: xml
default_operation: merge
content: "{{ lookup('ansible.builtin.template', '{{ router.vendor }}/edge_port_{{ verb }}.j2') }}"
commit: true
commit_comment: "{{ commit_comment }}"
config_mode: private
diff: true
register: output
check_mode: false
---
# tasks file for edge_port
- name: Include Standard role tasks
ansible.builtin.include_tasks: standard_tasks.yaml
- name: Include templates compilation
when: verb in verbs
ansible.builtin.include_tasks: compile.yaml
- name: Include set connection tasks
ansible.builtin.include_tasks: connection_tasks.yaml
- name: Include deploy tasks
when: verb in verbs
ansible.builtin.include_tasks: deploy.yaml
---
- name: Print the usage
when: (verb is not defined) or (verb not in verbs)
ansible.builtin.debug:
msg:
- "'verb' keyword is mandatory. Usage: -e verb=$verb"
- name: Print defined verbs
when: (verb is not defined) or (verb not in verbs)
ansible.builtin.debug:
msg:
- "Allowed verb: {{ item }}"
loop: "{{ verbs }}"
- name: Stop if arguments are incorrect
when: (verb is not defined) or (verb not in verbs)
ansible.builtin.meta: end_play
- name: Import routers variables
ansible.builtin.include_vars:
dir: /opt/ansible_inventory/group_vars/routers
- name: Import variables from 'all'
ansible.builtin.include_vars:
dir: /opt/ansible_inventory/group_vars/all
- name: Generate an ID for this run
ansible.builtin.set_fact:
opid: "{{ lookup('community.general.random_string', length=18, special=false) }}"
- name: Print the ID
ansible.builtin.debug:
msg: "{{ opid }}"
<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 ep.edge_port_ae_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 {{ ep.edge_port_type }} {{ partner_name }} P_{{ ep.edge_port_name }} | {{ member.interface_description }}</description>
<ethernet>
<mode>access</mode>
<mtu>{{ mtu_phy | default(9192) }}</mtu>
{% if edge_port_lldp_enable_map[ep.edge_port_type] is true %}
<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>
{% endif %}
</ethernet>
</port>
{% endfor %}
{% if edge_port_removed_ae_members is defined %}
{% for member in edge_port_removed_ae_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>disable</admin-state>
<description>''</description>
</port>
{% endfor %}
{% endif %}
<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>{{ ep.edge_port_name | lower }}</lag-name>
<admin-state>enable</admin-state>
{% if ep.edge_port_geant_ga_id is string %}
<description>LAG {{ ep.edge_port_type }} {{ partner_name }} ${{ ep.edge_port_geant_ga_id }} | </description>
{% else %}
<description>LAG {{ ep.edge_port_type }} {{ partner_name }} | </description>
{% endif %}
<mode>access</mode>
{% if ep.edge_port_enable_lacp is true %}
<lacp>
<mode>active</mode>
<administrative-key>{{ (ep.edge_port_name|split("-"))[1] }}</administrative-key>
</lacp>
{% endif %}
{% for member in ep.edge_port_ae_members %}
<port>
<port-id>{{ member.interface_name }}</port-id>
</port>
{% endfor %}
{% if ( ep.edge_port_minimum_links | int) > 1 %}
<port-threshold>
<value>{{ ( ep.edge_port_minimum_links | int) - 1 }}</value>
<action>down</action>
</port-threshold>
{% endif %}
</lag>
</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 ep.edge_port_ae_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 {{ ep.edge_port_type }} {{ partner_name }} P_{{ ep.edge_port_name }} | {{ member.interface_description }}</description>
<ethernet>
<mode>access</mode>
<mtu>{{ mtu_phy | default(9192) }}</mtu>
{% if edge_port_lldp_enable_map[ep.edge_port_type] is true %}
<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>
{% endif %}
</ethernet>
</port>
{% endfor %}
{% if removed_ae_members is defined and removed_ae_members|length > 0 %}
{% for member in removed_ae_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>disable</admin-state>
</port>
{% endfor %}
{% endif %}
<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>{{ ep.edge_port_name | lower }}</lag-name>
<admin-state>enable</admin-state>
{% if ep.geant_ga_id is string %}
<description>LAG {{ ep.edge_port_type }} {{ partner_name }} ${{ ep.geant_ga_id }} |</description>
{% else %}
<description>LAG {{ ep.edge_port_type }} {{ partner_name }} |</description>
{% endif %}
<mode>access</mode>
{% if ep.enable_lacp is true %}
<lacp>
<mode>active</mode>
<administrative-key>{{ (ep.edge_port_name|split("-"))[1] }}</administrative-key>
</lacp>
{% endif %}
{% for member in ep.edge_port_ae_members %}
<port>
<port-id>{{ member.interface_name }}</port-id>
</port>
{% endfor %}
{% if ( ep.minimum_links | int) > 1 %}
<port-threshold>
<value>{{ ( ep.minimum_links | int) - 1 }}</value>
<action>down</action>
</port-threshold>
{% endif %}
</lag>
</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 ep.edge_port_ae_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>disable</admin-state>
</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="delete">
<lag-name>{{ ep.edge_port_name | lower }}</lag-name>
</lag>
</configure>
</config>
edge_port_create.j2
\ No newline at end of file
---
# vars file for edge_port
dry_run: true
is_verification_workflow: false
verbs:
- create
- update
- terminate
ep: "{{ subscription.edge_port }}"
router: "{{ ep.node }}"
edge_port_lldp_enable_map:
INFRASTRUCTURE: true
CUSTOMER: true
PUBLIC: false
RE_INTERCONNECT: false
PRIVATE: false
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment