data.coop-ansible/roles/docker/tasks/services.yml

44 lines
1.6 KiB
YAML
Raw Normal View History

# vim: ft=yaml.ansible
---
2018-06-24 13:16:56 +00:00
- name: setup external services network
docker_network:
name: external_services
2018-06-24 13:17:35 +00:00
2023-10-03 20:00:51 +00:00
- name: Service block for all services
include_tasks:
file: loop.yml
vars:
service: "{{ item }}"
loop: "{{ services | dict2items(key_name='name', value_name='vars') }}"
when: single_service is not defined and
(item.vars.disabled_in_vagrant is not defined or
not (item.vars.disabled_in_vagrant and vagrant))
2023-10-03 20:00:51 +00:00
- name: Service block for a single service
2023-10-03 20:13:30 +00:00
when: single_service is defined and single_service in services and
2023-03-05 22:10:53 +00:00
(services[single_service].disabled_in_vagrant is not defined or
not (services[single_service].disabled_in_vagrant and vagrant))
2023-10-03 20:00:51 +00:00
block:
- name: Create volume folder
file:
name: "{{ services[single_service].volume_folder }}"
state: directory
- name: Upload Compose file
template:
src: compose-files/{{ single_service }}.yml.j2
dest: "{{ services[single_service].volume_folder }}/docker-compose.yml"
- name: Run pre-deployment tasks
include_tasks: pre_deploy/{{ single_service }}.yml
when: services[single_service].pre_deploy_tasks is defined and services[single_service].pre_deploy_tasks
- name: Deploy Compose stack
command: docker compose up -d --remove-orphans --pull always
args:
chdir: "{{ services[single_service].volume_folder }}"
- name: Run post-deployment tasks
include_tasks: post_deploy/{{ single_service }}.yml
when: services[single_service].post_deploy_tasks is defined and services[single_service].post_deploy_tasks