2019-08-24 10:55:56 +00:00
|
|
|
|
---
|
|
|
|
|
- name: manage networks
|
|
|
|
|
docker_network:
|
|
|
|
|
name: '{{ item.name }}'
|
|
|
|
|
driver: '{{ item.driver|default("bridge") }}'
|
|
|
|
|
ipam_config: '{{ item.config|default([]) }}'
|
|
|
|
|
scope: swarm
|
|
|
|
|
state: '{{ item.state|default("present") }}'
|
|
|
|
|
loop: '{{ docker_networks }}'
|
|
|
|
|
tags: docker
|
|
|
|
|
|
|
|
|
|
- name: manage services
|
|
|
|
|
docker_swarm_service:
|
|
|
|
|
name: '{{ item.name }}'
|
|
|
|
|
image: '{{ item.image }}'
|
2020-02-01 08:01:55 +00:00
|
|
|
|
command: '{{ item.command|default([]) }}'
|
2019-08-24 10:55:56 +00:00
|
|
|
|
args: '{{ item.args|default([]) }}'
|
|
|
|
|
mounts: '{{ item.mounts|default([]) }}'
|
|
|
|
|
networks: '{{ item.networks|default([]) }}'
|
|
|
|
|
publish: '{{ item.publish|default([]) }}'
|
|
|
|
|
replicas: '{{ item.replicas|default(1) }}'
|
|
|
|
|
limits: '{{ item.limits|default({}) }}'
|
|
|
|
|
env: '{{ item.env|default({}) }}'
|
|
|
|
|
container_labels: '{{ item.labels|default({}) }}'
|
|
|
|
|
state: present
|
|
|
|
|
loop: '{{ docker_services }}'
|
|
|
|
|
when: '"state" not in item or item.state != "absent"'
|
|
|
|
|
no_log: false
|
|
|
|
|
tags: docker
|
|
|
|
|
|
|
|
|
|
- name: remove services
|
|
|
|
|
docker_swarm_service:
|
|
|
|
|
name: '{{ item.name }}'
|
|
|
|
|
state: absent
|
|
|
|
|
loop: '{{ docker_services }}'
|
|
|
|
|
when: '"state" in item and item.state == "absent"'
|
|
|
|
|
no_log: true
|
|
|
|
|
tags: docker
|