From 3ac2d839716bf6c8c91c8cbbe36ff24c31976672 Mon Sep 17 00:00:00 2001 From: Sam Al-Sapti Date: Wed, 4 Oct 2023 19:43:11 +0200 Subject: [PATCH] Magic --- roles/docker/tasks/{loop.yml => block.yml} | 0 roles/docker/tasks/services.yml | 35 +++++----------------- 2 files changed, 8 insertions(+), 27 deletions(-) rename roles/docker/tasks/{loop.yml => block.yml} (100%) diff --git a/roles/docker/tasks/loop.yml b/roles/docker/tasks/block.yml similarity index 100% rename from roles/docker/tasks/loop.yml rename to roles/docker/tasks/block.yml diff --git a/roles/docker/tasks/services.yml b/roles/docker/tasks/services.yml index 6943c51..488b1de 100644 --- a/roles/docker/tasks/services.yml +++ b/roles/docker/tasks/services.yml @@ -1,12 +1,12 @@ # vim: ft=yaml.ansible --- -- name: setup external services network +- name: Set up external services network docker_network: name: external_services -- name: Service block for all services +- name: Deploy all services include_tasks: - file: loop.yml + file: block.yml vars: service: "{{ item }}" loop: "{{ services | dict2items(key_name='name', value_name='vars') }}" @@ -14,30 +14,11 @@ (item.vars.disabled_in_vagrant is not defined or not (item.vars.disabled_in_vagrant and vagrant)) -- name: Service block for a single service +- name: Deploy single service + include_tasks: + file: block.yml + vars: + service: "{{ {single_service: services[single_service]} | dict2items(key_name='name', value_name='vars') }}" when: single_service is defined and single_service in services and (services[single_service].disabled_in_vagrant is not defined or not (services[single_service].disabled_in_vagrant and vagrant)) - 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