Commit 9a80bf60 authored by ∞'s avatar 💻

Docker stack support

parent b7fa6c0a
......@@ -4,12 +4,17 @@
include_role: name=yourlabs.docker
when: ansible_facts['ansible_local']['yourlabs_docker']['state']|default('') != 'success'
- name: Initialize a docker swarm so that compose can be deployed as stacks
shell: docker swarm init
when: stack|default(false)
failed_when: false
- name: We need docker-compose on localhost because we'll use the config command
delegate_to: localhost
pip:
name: docker-compose
state: latest
executable: pip3
delegate_to: localhost
- name: Make home directory
when: home is defined
......@@ -87,7 +92,7 @@
config_path: '{{ home if home is defined else ansible_user_dir + "/" + project }}/.docker/config.json'
- name: Restart docker-compose services in home
when: home is defined
when: home is defined and stack is not defined
environment:
DOCKER_CONFIG: '{{ home }}/.docker'
docker_compose:
......@@ -97,7 +102,7 @@
#build: '{{ build|default("no") }}'
- name: Restart project docker-compose services
when: project is defined
when: project is defined and stack is not defined
environment:
DOCKER_CONFIG: '{{ ansible_user_dir + "/" + project }}/.docker'
docker_compose:
......@@ -107,6 +112,17 @@
build: '{{ build|default("no") }}'
state: '{{ state|default("present") }}'
- name: Restart stack
when: stack is defined
environment:
DOCKER_CONFIG: '{{ ansible_user_dir + "/" + project }}/.docker'
docker_stack:
state: present
name: '{{ stack }}'
prune: yes
compose:
- '{{ compose_content|yaml_load if project is defined else None }}'
- name: Show logs
shell: docker-compose {% if project is defined %}-f - -p {{ project }}{% endif %} logs
args:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment