31 lines
920 B
YAML
31 lines
920 B
YAML
---
|
|
# Set state status for switch vlan
|
|
- name: Set state status for switch vlan {{ item.vlan }}
|
|
ansible.builtin.set_fact:
|
|
switch_vlan_state: "{{ item.state | default('present') }}"
|
|
|
|
# Delete switch vlan
|
|
- name: Delete switch vlan {{ item.vlan }}
|
|
when: "'absent' in switch_vlan_state"
|
|
uci:
|
|
command: "absent"
|
|
config: "network"
|
|
type: "switch_vlan"
|
|
find:
|
|
vlan: "{{ item.vlan | mandatory }}"
|
|
|
|
# Create and configure switch vlan
|
|
- name: Create and configure switch vlan
|
|
when: "'present' in switch_vlan_state"
|
|
uci:
|
|
command: "section"
|
|
config: "network"
|
|
type: "switch_vlan"
|
|
find:
|
|
vlan: "{{ item.vlan | mandatory }}"
|
|
value:
|
|
device: "{{ item.device | default('switch0') }}"
|
|
vid: "{{ item.vid | default(item.vlan | default(omit)) }}"
|
|
ports: "{{ item.ports | default([]) }}"
|
|
description: "{{ item.description | default(omit) }}"
|
|
replace: "yes" |