Switch default docker storage driver to overlay2

To avoid switching existing deployments from devicemapper to overlay2,
we check the existing storage driver configuration directly with the
Docker daemon, or if unreachable by reading the /etc/docker/daemon.json
configuration file.

Co-Authored-By: Pierre Riteau <pierre@stackhpc.com>
Story: 2005667
Task: 30972

Change-Id: Iaf2ee8c9f302f4684ae039bb00b2e2e5969cf1fc
This commit is contained in:
Mark Goddard 2020-04-23 12:03:45 +01:00 committed by Pierre Riteau
parent 1f155b5582
commit 869185ea7b
7 changed files with 49 additions and 9 deletions

View File

@ -1,11 +1,44 @@
---
- name: Ensure docker devicemapper storage is configured
- name: Verify and configure Docker storage driver
hosts: docker
tags:
- docker
- docker-devicemapper
tasks:
- name: Ensure docker devicemapper storage is configured
- name: Check for existing Docker configuration using devicemapper
block:
- name: Query Docker daemon for storage driver
docker_host_info:
failed_when: false
register: docker
- block:
- name: Check for a Docker configuration file
become: True
stat:
path: /etc/docker/daemon.json
register: docker_config_file
- name: Check whether devicemapper is used in configuration file
lineinfile:
path: /etc/docker/daemon.json
regexp: 'storage-driver.*devicemapper'
state: absent
become: True
changed_when: False
# `check_mode: True` ensures that we don't modify daemon.json
check_mode: True
register: devicemapper_docker
when: docker_config_file.stat.exists
when: not docker.can_talk_to_docker
- name: Fail if devicemapper is in use while another storage driver was requested
fail:
msg: "Docker storage driver {{ docker_storage_driver }} was requested, but devicemapper is in use"
when: (docker.can_talk_to_docker and docker.host_info.Driver == 'devicemapper') or (devicemapper_docker.found | default(0) == 1)
when: docker_storage_driver != 'devicemapper'
- name: Ensure Docker devicemapper storage is configured
include_role:
name: docker-devicemapper
when: docker_storage_driver == 'devicemapper'

View File

@ -2,8 +2,8 @@
###############################################################################
# Docker configuration.
# Name of the docker storage driver. Default is 'devicemapper'.
docker_storage_driver: devicemapper
# Name of the docker storage driver. Default is 'overlay2'.
docker_storage_driver: overlay2
# Name of the docker storage LVM volume group.
docker_storage_volume_group: data

View File

@ -1,6 +1,6 @@
---
# Name of the docker storage driver.
docker_storage_driver: devicemapper
docker_storage_driver: overlay2
# Name of the docker storage LVM volume group.
docker_storage_volume_group:

View File

@ -262,7 +262,7 @@ kolla_enable_host_ntp:
# Docker configuration.
# Name of the docker storage driver.
docker_storage_driver: devicemapper
docker_storage_driver: overlay2
# Name of the docker storage LVM volume group.
docker_storage_volume_group:

View File

@ -690,8 +690,8 @@ Docker engine configuration is applied by both Kayobe and Kolla Ansible (during
bootstrap-servers).
The ``docker_storage_driver`` variable sets the Docker storage driver, and by
default the ``devicemapper`` driver is used. If using this driver, see
:ref:`configuration-hosts-lvm` for information about configuring LVM for
default the ``overlay2`` driver is used. If using the ``devicemapper`` driver,
see :ref:`configuration-hosts-lvm` for information about configuring LVM for
Docker.
Various options are defined in ``${KAYOBE_CONFIG_PATH}/docker.yml``

View File

@ -2,7 +2,7 @@
###############################################################################
# Docker configuration.
# Name of the docker storage driver. Default is 'devicemapper'.
# Name of the docker storage driver. Default is 'overlay2'.
#docker_storage_driver:
# Name of the docker storage LVM volume group.

View File

@ -0,0 +1,7 @@
---
upgrade:
- |
The default Docker storage driver has been changed from ``devicemapper`` to
``overlay2``, which is the storage driver preferred by Docker. Environments
using ``devicemapper`` should set ``docker_storage_driver`` to
``devicemapper`` in ``${KAYOBE_CONFIG_PATH}/docker.yml``.