Commit 165cdb07 authored by ∞'s avatar 💻

Add postdeploy command support and refactor

parent 60877381
......@@ -72,8 +72,12 @@
name: '{{ item }}'
loop: '{{ external_networks }}'
- name: Set home for project
when: project is defined
set_fact:
home: '{{ ansible_user_dir + "/.yourlabs.compose/" + project }}'
- name: Upload compose file
when: home is defined
copy:
content: '{{ compose_content }}'
dest: '{{ home }}/docker-compose.yml'
......@@ -87,7 +91,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: project is not defined
environment:
DOCKER_CONFIG: '{{ home }}/.docker'
docker_compose:
......@@ -107,17 +111,11 @@
build: '{{ build|default("no") }}'
state: '{{ state|default("present") }}'
- name: Create docker-compose definition backup directory
when: project is defined
file:
path: '{{ ansible_user_dir + "/.yourlabs.compose/" + project }}'
state: directory
- name: Create docker-compose definition backup
when: project is defined
copy:
dest: '{{ ansible_user_dir + "/.yourlabs.compose/" + project + "/docker-compose.yml" }}'
content: '{{ compose_content }}'
- name: Execute post-deploy commands
when: postdeploy is defined
shell: '{{ postdeploy }}'
args:
chdir: '{{ home }}'
- name: Show logs
shell: docker-compose {% if project is defined %}-f - -p {{ project }}{% endif %} logs
......
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