--- # Set state status for network device - name: Set state status for network device {{ item.name }} ansible.builtin.set_fact: network_device_state: "{{ item.state | default('present') }}" # Delete network device - name: Delete network device {{ item.name }} when: "'absent' in network_device_state" uci: command: "absent" config: "network" type: "device" find: name: "{{ item.name | mandatory }}" # Create and configure network device - name: Create and configure network device when: "'present' in network_device_state" uci: command: "section" config: "network" type: "device" find: name: "{{ item.name | default(omit) }}" value: 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) }}" replace: "yes"