Files
apLukov/roles/network/tasks/switch_swconfig.yml
2024-10-30 01:50:38 +01:00

40 lines
1.3 KiB
YAML

---
# Set state status for switch vlan
- name: Set state status for switch vlan {{ item.id | default('@switch_vlan[-1]') }}
ansible.builtin.set_fact:
switch_vlan_state: "{{ item.state | default('present') }}"
# Delete switch vlan
- name: Delete switch vlan {{ item.id }}
when: "'absent' in switch_vlan_state"
uci:
command: "absent"
config: "network"
section: "{{ item.id }}"
type: "switch_vlan"
# Create and configure switch vlan
- name: Create and configure switch vlan
when: "'present' in switch_vlan_state"
block:
# Create switch vlan
- name: Create switch vlan {{ item.id | default('@switch_vlan[-1]') }}
uci:
command: "add"
config: "network"
section: "{{ item.id | default('@switch_vlan[-1]') }}"
type: "switch_vlan"
# Configure switch vlan
- name: Configure switch vlan {{ item.id | default('@switch_vlan[-1]') }}
uci:
command: "set"
config: "network"
section: "{{ item.id | default('@switch_vlan[-1]') }}"
type: "switch_vlan"
value:
device: "{{ item.device | default('switch0') }}"
vlan: "{{ item.vlan | mandatory }}"
vid: "{{ item.vid | default(item.vlan | default(omit)) }}"
ports: "{{ item.ports | default([]) }}"
description: "{{ item.description | default(omit) }}"