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