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
This commit is contained in:
Mohammed Naser
2020-02-14 21:27:30 +01:00
parent 211e92ec40
commit 839a179048
3 changed files with 14 additions and 0 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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