Skip to content

Commit

Permalink
Apply changes from ansible-network#74
Browse files Browse the repository at this point in the history
  • Loading branch information
DanNiESh committed Apr 20, 2023
1 parent 0275128 commit b6fecac
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions etc/ansible/roles/network-runner/providers/nos/defaults.yaml
Original file line number Diff line number Diff line change
@@ -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 }}'
10 changes: 10 additions & 0 deletions etc/ansible/roles/network-runner/providers/nos/delete_port.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: "nos: delete vlan"
community.network.nos_config:
lines:
- "no interface vlan {{ _vlan_id }}"
match: none
connection: network_cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- fail:
msg: Get Port Conf is not implemented for nos
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- fail:
msg: List VLANs is not implemented for nos

0 comments on commit b6fecac

Please sign in to comment.