--- - name: Copy registry login community.general.docker_login: registry_url: '{{ item.value.registry_url }}' username: '{{ item.value.registry_username }}' password: '{{ item.value.registry_password }}' become: true become_user: '{{ item.value.user | default(ansible_user_id) }}' loop: '{{ swarm_registry_logins | dict2items }}' loop_control: label: '{{ item.key }}' tags: swarm - name: Manage networks community.docker.docker_network: name: '{{ item.key }}' driver: '{{ item.value.driver | default("overlay") }}' scope: swarm state: '{{ item.value.state | default("present") }}' loop: '{{ swarm_networks | dict2items }}' loop_control: label: '{{ item.key }}' when: swarm_manager run_once: true tags: swarm - name: Manage services community.docker.docker_swarm_service: name: '{{ item.key }}' image: '{{ item.value.image }}' command: '{{ item.value.command | default([]) }}' hostname: '{{ item.value.hostname | default(omit) }}' args: '{{ item.value.args | default([]) }}' mounts: '{{ item.value.mounts | default([]) }}' networks: '{{ item.value.networks | default([]) }}' publish: '{{ item.value.publish | default([]) }}' replicas: '{{ item.value.replicas | default(1) }}' limits: '{{ item.value.limits | default({}) }}' env: '{{ item.value.env | default({}) }}' container_labels: '{{ item.value.labels | default({}) }}' state: '{{ item.value.state | default("present") }}' loop: '{{ swarm_services | dict2items }}' loop_control: label: '{{ item.key }}' when: swarm_manager run_once: true tags: swarm