Support docker overlay storage driver

This is configured via docker_storage_driver.
This commit is contained in:
Mark Goddard 2017-08-07 20:07:50 +00:00
parent d20118a9c5
commit fe6c6a3ac6
5 changed files with 51 additions and 32 deletions

View File

@ -1,4 +1,8 @@
--- ---
# Name of the docker storage driver. Supported values include 'devicemapper'
# and 'overlay'.
docker_storage_driver: devicemapper
# Name of the docker storage LVM volume group. # Name of the docker storage LVM volume group.
docker_storage_volume_group: docker_storage_volume_group:

View File

@ -1,4 +1,11 @@
--- ---
- name: Fail when the storage driver is invalid
fail:
msg: >
Storage driver {{ docker_storage_driver }} is invalid. Valid drivers
include 'devicemapper' and 'overlay'.
when: docker_storage_driver not in ['devicemapper', 'overlay']
- name: Ensure user is in the docker group - name: Ensure user is in the docker group
user: user:
name: "{{ ansible_user_id }}" name: "{{ ansible_user_id }}"
@ -40,8 +47,8 @@
- name: Fail when loopback-mode containers or images exist - name: Fail when loopback-mode containers or images exist
fail: fail:
msg: > msg: >
Not configuring docker storage in direct-lvm mode as loopback-backed Not configuring docker storage in {{ docker_storage_driver }} mode as
containers or images exist. loopback-backed containers or images exist.
when: when:
- "{{ 'Data loop file' in docker_info.stdout }}" - "{{ 'Data loop file' in docker_info.stdout }}"
- "{{ 'Images: 0' not in docker_info.stdout }}" - "{{ 'Images: 0' not in docker_info.stdout }}"

View File

@ -16,6 +16,7 @@
- "/var/lib/docker/containers" - "/var/lib/docker/containers"
become: True become: True
- block:
- name: Ensure the docker storage data and metadata volumes exist - name: Ensure the docker storage data and metadata volumes exist
lvol: lvol:
vg: "{{ docker_storage_volume_group }}" vg: "{{ docker_storage_volume_group }}"
@ -48,3 +49,4 @@
lvchange --metadataprofile docker-thinpool lvchange --metadataprofile docker-thinpool
{{ docker_storage_volume_group }}/{{ docker_storage_volume_thinpool }} {{ docker_storage_volume_group }}/{{ docker_storage_volume_thinpool }}
become: True become: True
when: docker_storage_driver == 'devicemapper'

View File

@ -1,11 +1,13 @@
{ {
"storage-driver": "devicemapper", "storage-driver": "{% if docker_storage_driver == 'devicemapper' %}devicemapper{% else %}overlay{% endif %}",
{% if docker_daemon_mtu %} {% if docker_daemon_mtu %}
"mtu": {{ docker_daemon_mtu }}, "mtu": {{ docker_daemon_mtu }},
{% endif %} {% endif %}
"storage-opts": [ "storage-opts": [
{% if docker_storage_driver == 'devicemapper' %}
"dm.thinpooldev=/dev/mapper/{{ docker_storage_volume_group | replace('-', '--') }}-{{ docker_storage_volume_thinpool | replace('-', '--') }}", "dm.thinpooldev=/dev/mapper/{{ docker_storage_volume_group | replace('-', '--') }}-{{ docker_storage_volume_thinpool | replace('-', '--') }}",
"dm.use_deferred_removal=true", "dm.use_deferred_removal=true",
"dm.use_deferred_deletion=true" "dm.use_deferred_deletion=true"
{% endif %}
] ]
} }

View File

@ -2,6 +2,10 @@
############################################################################### ###############################################################################
# Docker configuration. # Docker configuration.
# Name of the docker storage driver. Supported values include 'devicemapper'
# and 'overlay'.
#docker_storage_driver:
# Name of the docker storage LVM volume group. # Name of the docker storage LVM volume group.
#docker_storage_volume_group: #docker_storage_volume_group: