From b6fecac2c06310bfcdf36cc165efc7d6518a860e Mon Sep 17 00:00:00 2001 From: Danni Shi Date: Thu, 20 Apr 2023 13:16:38 -0400 Subject: [PATCH] Apply changes from https://github.com/ansible-network/network-runner/pull/74 --- .../providers/nos/add_trunk_vlan.yaml | 9 ++++++ .../providers/nos/conf_access_port.yaml | 15 ++++++++++ .../providers/nos/conf_trunk_port.yaml | 29 +++++++++++++++++++ .../providers/nos/create_vlan.yaml | 9 ++++++ .../providers/nos/defaults.yaml | 3 ++ .../providers/nos/delete_port.yaml | 10 +++++++ .../providers/nos/delete_trunk_vlan.yaml | 9 ++++++ .../providers/nos/delete_vlan.yaml | 7 +++++ .../providers/nos/get_port_conf.yaml | 3 ++ .../providers/nos/list_vlans.yaml | 3 ++ 10 files changed, 97 insertions(+) create mode 100644 etc/ansible/roles/network-runner/providers/nos/add_trunk_vlan.yaml create mode 100644 etc/ansible/roles/network-runner/providers/nos/conf_access_port.yaml create mode 100644 etc/ansible/roles/network-runner/providers/nos/conf_trunk_port.yaml create mode 100644 etc/ansible/roles/network-runner/providers/nos/create_vlan.yaml create mode 100644 etc/ansible/roles/network-runner/providers/nos/defaults.yaml create mode 100644 etc/ansible/roles/network-runner/providers/nos/delete_port.yaml create mode 100644 etc/ansible/roles/network-runner/providers/nos/delete_trunk_vlan.yaml create mode 100644 etc/ansible/roles/network-runner/providers/nos/delete_vlan.yaml create mode 100644 etc/ansible/roles/network-runner/providers/nos/get_port_conf.yaml create mode 100644 etc/ansible/roles/network-runner/providers/nos/list_vlans.yaml diff --git a/etc/ansible/roles/network-runner/providers/nos/add_trunk_vlan.yaml b/etc/ansible/roles/network-runner/providers/nos/add_trunk_vlan.yaml new file mode 100644 index 0000000..77ff9e3 --- /dev/null +++ b/etc/ansible/roles/network-runner/providers/nos/add_trunk_vlan.yaml @@ -0,0 +1,9 @@ +--- +- name: "nos: Add a vlan to a trunk port" + community.network.nos_config: + lines: + - "switchport trunk allowed vlan add {{ _vlan_id }}" + parents: + - "interface {{ port_name }}" + match: none + connection: network_cli diff --git a/etc/ansible/roles/network-runner/providers/nos/conf_access_port.yaml b/etc/ansible/roles/network-runner/providers/nos/conf_access_port.yaml new file mode 100644 index 0000000..5a681f6 --- /dev/null +++ b/etc/ansible/roles/network-runner/providers/nos/conf_access_port.yaml @@ -0,0 +1,15 @@ +--- +- name: "nos: restore config and then configure access port" + community.network.nos_config: + lines: + - "no switchport" + - "shutdown" + - "switchport" + - "switchport mode access" + - "no shutdown" + - "no spanning-tree shutdown" + - "switchport access vlan {{ _vlan_id }}" + parents: + - "interface {{ port_name }}" + match: none + connection: network_cli diff --git a/etc/ansible/roles/network-runner/providers/nos/conf_trunk_port.yaml b/etc/ansible/roles/network-runner/providers/nos/conf_trunk_port.yaml new file mode 100644 index 0000000..3130998 --- /dev/null +++ b/etc/ansible/roles/network-runner/providers/nos/conf_trunk_port.yaml @@ -0,0 +1,29 @@ +--- +- name: "nos: reset interface to default and then configure it in trunk mode with native-vlan" + community.network.nos_config: + lines: + - "no switchport" + - "shutdown" + - "switchport" + - "switchport mode trunk" + - "no switchport trunk tag native-vlan" + - "no shutdown" + - "no spanning-tree shutdown" + - "switchport trunk allowed vlan add {{ _vlan_id }}" + - "switchport trunk native-vlan {{ _vlan_id }}" + parents: + - "interface {{ port_name }}" + match: none + connection: network_cli + +- name: "nos: add the remainder of trunk vlan(s)" + community.network.nos_config: + lines: + - "switchport trunk allowed vlan add {{ t_vlan }}" + parents: + - "interface {{ port_name }}" + match: none + loop: "{{ trunked_vlans }}" + loop_control: + loop_var: t_vlan + connection: network_cli diff --git a/etc/ansible/roles/network-runner/providers/nos/create_vlan.yaml b/etc/ansible/roles/network-runner/providers/nos/create_vlan.yaml new file mode 100644 index 0000000..2a84ba9 --- /dev/null +++ b/etc/ansible/roles/network-runner/providers/nos/create_vlan.yaml @@ -0,0 +1,9 @@ +--- +- name: "nos: create vlan" + community.network.nos_config: + lines: + - "name {{ _vlan_name }}" + parents: + - "interface vlan {{ _vlan_id }}" + match: none + connection: network_cli diff --git a/etc/ansible/roles/network-runner/providers/nos/defaults.yaml b/etc/ansible/roles/network-runner/providers/nos/defaults.yaml new file mode 100644 index 0000000..599142c --- /dev/null +++ b/etc/ansible/roles/network-runner/providers/nos/defaults.yaml @@ -0,0 +1,3 @@ +--- +_vlan_id: "{{ vlan_id | default(1, True)}}" +_vlan_name: '{{ vlan_name if vlan_name else "default" if vlan_id|string == "1" else "vlan"+vlan_id|string }}' diff --git a/etc/ansible/roles/network-runner/providers/nos/delete_port.yaml b/etc/ansible/roles/network-runner/providers/nos/delete_port.yaml new file mode 100644 index 0000000..215d81c --- /dev/null +++ b/etc/ansible/roles/network-runner/providers/nos/delete_port.yaml @@ -0,0 +1,10 @@ +--- +- name: "nos: reset interface to default (no switchport and shutdown)" + community.network.nos_config: + lines: + - "no switchport" + - "shutdown" + parents: + - "interface {{ port_name }}" + match: none + connection: network_cli diff --git a/etc/ansible/roles/network-runner/providers/nos/delete_trunk_vlan.yaml b/etc/ansible/roles/network-runner/providers/nos/delete_trunk_vlan.yaml new file mode 100644 index 0000000..38d3a33 --- /dev/null +++ b/etc/ansible/roles/network-runner/providers/nos/delete_trunk_vlan.yaml @@ -0,0 +1,9 @@ +--- +- name: "nos: Remove vlan from a trunk port" + community.network.nos_config: + lines: + - "switchport trunk allowed vlan remove {{ _vlan_id }}" + parents: + - "interface {{ port_name }}" + match: none + connection: network_cli diff --git a/etc/ansible/roles/network-runner/providers/nos/delete_vlan.yaml b/etc/ansible/roles/network-runner/providers/nos/delete_vlan.yaml new file mode 100644 index 0000000..3c1ed6d --- /dev/null +++ b/etc/ansible/roles/network-runner/providers/nos/delete_vlan.yaml @@ -0,0 +1,7 @@ +--- +- name: "nos: delete vlan" + community.network.nos_config: + lines: + - "no interface vlan {{ _vlan_id }}" + match: none + connection: network_cli diff --git a/etc/ansible/roles/network-runner/providers/nos/get_port_conf.yaml b/etc/ansible/roles/network-runner/providers/nos/get_port_conf.yaml new file mode 100644 index 0000000..578dc37 --- /dev/null +++ b/etc/ansible/roles/network-runner/providers/nos/get_port_conf.yaml @@ -0,0 +1,3 @@ +--- +- fail: + msg: Get Port Conf is not implemented for nos diff --git a/etc/ansible/roles/network-runner/providers/nos/list_vlans.yaml b/etc/ansible/roles/network-runner/providers/nos/list_vlans.yaml new file mode 100644 index 0000000..09cd7de --- /dev/null +++ b/etc/ansible/roles/network-runner/providers/nos/list_vlans.yaml @@ -0,0 +1,3 @@ +--- +- fail: + msg: List VLANs is not implemented for nos