blob: a129d02c8f6bf9e127e2d1b6891264a5d365626d [file] [log] [blame]
---
- hosts: {{ swarm_manager_address }}
become: true
tasks:
{% if delete -%}
- name: delete swarm service '{{ swarm_service_name }}'
shell: docker service rm {{ swarm_service_name }}
- name: remove the directory {{ host_volume_path }}
file:
path={{ host_volume_path }}
state=absent
{% elif update -%}
- name: Create host volume directory to share to docker container
file:
path={{ host_volume_path }}
state=directory
- name: update swarm service '{{ swarm_service_name }}'
shell: docker service update --force {{ volume }} {{ swarm_service_name }}
- name: get status of '{{ swarm_service_name }}' service
shell: docker service ps {{ swarm_service_name }}
{% else -%}
- name: remove the directory {{ host_volume_path }}
file:
path={{ host_volume_path }}
state=absent
- name: Create host volume directory to share to docker container
file:
path={{ host_volume_path }}
state=directory
- name: start swarm service '{{ swarm_service_name }}'
shell: docker service create {{ network_name }} --name {{ swarm_service_name }} {{ replica }} {{ restart_condition }} {{ volume }} {{ swarm_manager_address }}:{{ docker_registry_port }}/{{ image_name }}:{{ image_tag }}
{% endif %}
{% if not delete -%}
- name: inspect '{{ swarm_service_name }}' service of swarm mode
shell: docker service inspect {{ swarm_service_name }}
{% endif %}