--- - name: Configure tagged vlans switch_config: username: "{{ switch_vars.username }}" password: "{{ switch_vars.password }}" port: "{{ switch_vars.port }}" host: "{{ switch_vars.host }}" use_proxy: "{{ switch.use_proxy }}" version: v1 config: path: vlans-ports create_method: POST subpath: - path: "{{ item.0.id }}-{{ item.1 }}" data: vlan_id: "{{ item.0.id }}" port_id: "{{ item.1 | string }}" port_mode: POM_TAGGED_STATIC loop: "{{ switch_vars.vlans | subelements('tagged', skip_missing=True) }}" - name: Configure untagged vlans switch_config: username: "{{ switch_vars.username }}" password: "{{ switch_vars.password }}" port: "{{ switch_vars.port }}" host: "{{ switch_vars.host }}" use_proxy: "{{ switch.use_proxy }}" config: path: vlans-ports create_method: POST subpath: - path: "{{ item.0.id }}-{{ item.1 }}" data: vlan_id: "{{ item.0.id }}" port_id: "{{ item.1 | string }}" port_mode: POM_UNTAGGED loop: "{{ switch_vars.vlans | subelements('untagged', skip_missing=True) }}" - name: Remove vlans-ports switch_config: username: "{{ switch_vars.username }}" password: "{{ switch_vars.password }}" port: "{{ switch_vars.port }}" host: "{{ switch_vars.host }}" use_proxy: "{{ switch.use_proxy }}" config: path: vlans-ports subpath: - path: "{{ item.0.id }}-{{ item.1 }}" delete: true loop: "{{ switch_vars.vlans | subelements('remove_ports', skip_missing=True) }}" ...