--- # 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) }}"