From a68be104dc173fb5717d1fdbba7a01dffdd81bb4 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Tue, 26 Nov 2019 15:17:24 +0100 Subject: [PATCH] Add docker-wrapper method for docker-compose Signed-off-by: Knut Ahlers --- defaults/main.yml | 1 + tasks/docker-wrapper.yml | 21 +++++++++++++++++++++ tasks/main.yml | 5 +++++ 3 files changed, 27 insertions(+) create mode 100644 tasks/docker-wrapper.yml diff --git a/defaults/main.yml b/defaults/main.yml index b395fe3..538e15a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -5,6 +5,7 @@ docker_compose_stop_action: down docker_compose_validate: true docker_compose_reload_max_delay: 0 # Have no delay, should be less than docker_compose_reload_minutes +docker_compose_use_docker_image: false docker_compose_add_cleanjob: false docker_compose_config: diff --git a/tasks/docker-wrapper.yml b/tasks/docker-wrapper.yml new file mode 100644 index 0000000..30a7347 --- /dev/null +++ b/tasks/docker-wrapper.yml @@ -0,0 +1,21 @@ +--- + +- name: Install wrapper script + copy: + content: | + #!/bin/bash + set -euo pipefail + + exec docker run --rm -ti \ + -v "/var/run/docker.sock:/var/run/docker.sock" \ + -v "/etc/docker-compose:/etc/docker-compose:ro" \ + luzifer/docker-compose \ + "$@" + dest: /usr/local/bin/docker-compose + group: root + mode: '0755' + owner: root + +- set_fact: docker_compose_binary_path="/usr/local/bin/docker-compose" + +... diff --git a/tasks/main.yml b/tasks/main.yml index 101cc9d..2870432 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -4,6 +4,11 @@ - name: "Loading distribution specific instructions for {{ ansible_distribution }}" include: "{{ ansible_distribution }}.yml" + when: not docker_compose_use_docker_image + +- name: Install shell wrapper for docker-compose image + include: "docker-wrapper.yml" + when: docker_compose_use_docker_image # Configure docker-compose