ansible-role-swarm/tasks/config.yml

38 lines
1.1 KiB
YAML
Raw Normal View History

2019-08-24 10:55:56 +00:00
---
- name: manage networks
2021-11-22 10:28:13 +00:00
community.docker.docker_network:
2019-08-24 10:55:56 +00:00
name: '{{ item.name }}'
driver: '{{ item.driver|default("bridge") }}'
scope: swarm
state: '{{ item.state|default("present") }}'
2021-11-22 10:43:06 +00:00
loop: '{{ swarm_networks }}'
tags: swarm
2019-08-24 10:55:56 +00:00
- name: manage services
2021-11-22 10:28:13 +00:00
community.docker.docker_swarm_service:
name: '{{ item.name }}'
2019-08-24 10:55:56 +00:00
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
2021-11-22 10:43:06 +00:00
loop: '{{ swarm_services }}'
2019-08-24 10:55:56 +00:00
when: '"state" not in item or item.state != "absent"'
no_log: false
2021-11-22 10:43:06 +00:00
tags: swarm
2019-08-24 10:55:56 +00:00
- name: remove services
2021-11-22 10:28:13 +00:00
community.docker.docker_swarm_service:
name: '{{ item.name }}'
2019-08-24 10:55:56 +00:00
state: absent
2021-11-22 10:43:06 +00:00
loop: '{{ swarm_services }}'
2019-08-24 10:55:56 +00:00
when: '"state" in item and item.state == "absent"'
no_log: true
2021-11-22 10:43:06 +00:00
tags: swarm