From 1e97bb71db317900c13f45e253741c453e441b1a Mon Sep 17 00:00:00 2001 From: Raoul Scarazzini Date: Thu, 30 Jan 2020 15:59:04 +0100 Subject: [PATCH] Make possible to not start containers on compose When upgrading from releases it could happen that you need to do some manual steps (i.e. upgrading from postgres 9.6 to 10). In these cases you'd want to check the docker-compose.yml and then launch it by yourself. Today we don't have any method to get just the files that will be used while installing via compose, without starting the containers. This commit adds a variable named "compose_start_containers" (true by default) that, if false, will make the playbook just generate the files in the compose directory and not start the containers. --- .../roles/local_docker/defaults/main.yml | 2 ++ .../roles/local_docker/tasks/compose.yml | 24 ++++++++++--------- installer/roles/local_docker/tasks/main.yml | 1 + 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/installer/roles/local_docker/defaults/main.yml b/installer/roles/local_docker/defaults/main.yml index 9f308ea734..22f74d47ee 100644 --- a/installer/roles/local_docker/defaults/main.yml +++ b/installer/roles/local_docker/defaults/main.yml @@ -18,3 +18,5 @@ memcached_image: "memcached" memcached_version: "alpine" memcached_hostname: "memcached" memcached_port: "11211" + +compose_start_containers: true diff --git a/installer/roles/local_docker/tasks/compose.yml b/installer/roles/local_docker/tasks/compose.yml index f6dab2589e..949e30c8d6 100644 --- a/installer/roles/local_docker/tasks/compose.yml +++ b/installer/roles/local_docker/tasks/compose.yml @@ -23,16 +23,18 @@ mode: 0600 register: awx_secret_key -- name: Start the containers - docker_compose: - project_src: "{{ docker_compose_dir }}" - restarted: "{{ awx_compose_config is changed or awx_secret_key is changed }}" - register: awx_compose_start +- block: + - name: Start the containers + docker_compose: + project_src: "{{ docker_compose_dir }}" + restarted: "{{ awx_compose_config is changed or awx_secret_key is changed }}" + register: awx_compose_start -- name: Update CA trust in awx_web container - command: docker exec awx_web '/usr/bin/update-ca-trust' - when: awx_compose_config.changed or awx_compose_start.changed + - name: Update CA trust in awx_web container + command: docker exec awx_web '/usr/bin/update-ca-trust' + when: awx_compose_config.changed or awx_compose_start.changed -- name: Update CA trust in awx_task container - command: docker exec awx_task '/usr/bin/update-ca-trust' - when: awx_compose_config.changed or awx_compose_start.changed + - name: Update CA trust in awx_task container + command: docker exec awx_task '/usr/bin/update-ca-trust' + when: awx_compose_config.changed or awx_compose_start.changed + when: compose_start_containers|bool diff --git a/installer/roles/local_docker/tasks/main.yml b/installer/roles/local_docker/tasks/main.yml index e90ee30ca7..446f110f83 100644 --- a/installer/roles/local_docker/tasks/main.yml +++ b/installer/roles/local_docker/tasks/main.yml @@ -47,6 +47,7 @@ file: path: "{{ postgres_data_dir + '/pgdata' }}" state: absent + when: compose_start_containers|bool - import_tasks: set_image.yml - import_tasks: compose.yml