From 839a17904823196c2759ac704bb0e75a6713dcf2 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Fri, 14 Feb 2020 21:27:30 +0100 Subject: [PATCH] install-docker: option to install docker-compose The install-docker role currently takes care of setting up Docker however it lacks the ability to install docker-compose at the moment which is quite useful. This adds a variable which defaults to false that allows you to use the role to install docker-compose. It was decided to be put within the install-docker role because that role already manages the repository configuration and therefore provide consistency with the repository that is used to install docker-compose. Change-Id: Ia6f4ed88b4baf53bd671c7a7b48a1564ff2c866d --- roles/install-docker/README.rst | 6 ++++++ roles/install-docker/defaults/main.yaml | 1 + roles/install-docker/tasks/main.yaml | 7 +++++++ 3 files changed, 14 insertions(+) diff --git a/roles/install-docker/README.rst b/roles/install-docker/README.rst index a83e3ad74..2791490ec 100644 --- a/roles/install-docker/README.rst +++ b/roles/install-docker/README.rst @@ -18,6 +18,12 @@ An ansible role to install docker and configure it to use mirrors if available. By default this role adds repositories to install docker from upstream docker. Set this to False to use the docker that comes with the distro. +.. zuul:rolevar:: docker_compose_install + :default: False + + This role does not install docker-compose by default but you can use + this setting to install docker-compose as well. + .. zuul:rolevar:: docker_update_channel :default: stable diff --git a/roles/install-docker/defaults/main.yaml b/roles/install-docker/defaults/main.yaml index ab0d0743d..3e73d4bf0 100644 --- a/roles/install-docker/defaults/main.yaml +++ b/roles/install-docker/defaults/main.yaml @@ -4,6 +4,7 @@ docker_group: docker # The default option will return an empty list which # allows folks to override these lists as they see fit. docker_distro_packages: "{{ _docker_distro_packages | default([]) }}" +docker_compose_install: false docker_upstream_distro_packages: "{{ _docker_upstream_distro_packages | default([]) }}" docker_upstream_distro_required_packages: "{{ _docker_upstream_distro_required_packages | default([]) }}" docker_update_channel: stable diff --git a/roles/install-docker/tasks/main.yaml b/roles/install-docker/tasks/main.yaml index d5f401f5b..be1ff7e28 100644 --- a/roles/install-docker/tasks/main.yaml +++ b/roles/install-docker/tasks/main.yaml @@ -57,6 +57,13 @@ - include_tasks: "docker-{{ (use_upstream_docker | bool) | ternary('upstream', 'distro') }}.yaml" +- name: Install docker-compose + become: true + package: + name: docker-compose + state: present + when: docker_compose_install | bool + - name: Flush handlers before role exit meta: flush_handlers