feat: swarm_services and swarm_networks are now hashs

This commit is contained in:
Adrien Waksberg 2021-11-22 11:56:01 +01:00
parent 8450009836
commit 62b98a3770
3 changed files with 25 additions and 23 deletions

View file

@ -1,5 +1,5 @@
--- ---
swarm_manager: false swarm_manager: false
swarm_advertise_addr: 127.0.0.1 swarm_advertise_addr: 127.0.0.1
swarm_services: [] swarm_services: {}
swarm_networks: [] swarm_networks: {}

View file

@ -6,9 +6,9 @@
vars: vars:
swarm_manager: true swarm_manager: true
swarm_networks: swarm_networks:
- name: proxy proxy:
swarm_services: swarm_services:
- name: traefik traefik:
image: traefik:1.7 image: traefik:1.7
networks: networks:
- proxy - proxy
@ -22,7 +22,7 @@
mounts: mounts:
- source: /var/run/docker.sock - source: /var/run/docker.sock
target: /var/run/docker.sock target: /var/run/docker.sock
- name: whoami whoami:
image: jwilder/whoami image: jwilder/whoami
networks: networks:
- proxy - proxy

View file

@ -1,28 +1,30 @@
--- ---
- name: manage networks - name: manage networks
community.docker.docker_network: community.docker.docker_network:
name: '{{ item.name }}' name: '{{ item.key }}'
driver: '{{ item.driver|default("bridge") }}' driver: '{{ item.value.driver|default("bridge") }}'
scope: swarm scope: swarm
state: '{{ item.state|default("present") }}' state: '{{ item.value.state|default("present") }}'
loop: '{{ swarm_networks }}' loop: '{{ swarm_networks|dict2items() }}'
loop_control:
label: '{{ item.key }}'
tags: swarm tags: swarm
- name: manage services - name: manage services
community.docker.docker_swarm_service: community.docker.docker_swarm_service:
name: '{{ item.name }}' name: '{{ item.key }}'
image: '{{ item.image }}' image: '{{ item.value.image }}'
command: '{{ item.command|default([]) }}' command: '{{ item.value.command|default([]) }}'
args: '{{ item.args|default([]) }}' args: '{{ item.value.args|default([]) }}'
mounts: '{{ item.mounts|default([]) }}' mounts: '{{ item.value.mounts|default([]) }}'
networks: '{{ item.networks|default([]) }}' networks: '{{ item.value.networks|default([]) }}'
publish: '{{ item.publish|default([]) }}' publish: '{{ item.value.publish|default([]) }}'
replicas: '{{ item.replicas|default(1) }}' replicas: '{{ item.value.replicas|default(1) }}'
limits: '{{ item.limits|default({}) }}' limits: '{{ item.value.limits|default({}) }}'
env: '{{ item.env|default({}) }}' env: '{{ item.value.env|default({}) }}'
container_labels: '{{ item.labels|default({}) }}' container_labels: '{{ item.value.labels|default({}) }}'
state: '{{ item.state|default("present") }}' state: '{{ item.value.state|default("present") }}'
loop: '{{ swarm_services }}' loop: '{{ swarm_services|dict2items() }}'
loop_control: loop_control:
label: '{{ item.name }}' label: '{{ item.key }}'
tags: swarm tags: swarm