Support docker overlay storage driver
This is configured via docker_storage_driver.
This commit is contained in:
parent
d20118a9c5
commit
fe6c6a3ac6
@ -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.
|
||||
docker_storage_volume_group:
|
||||
|
||||
|
@ -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
|
||||
user:
|
||||
name: "{{ ansible_user_id }}"
|
||||
@ -40,8 +47,8 @@
|
||||
- name: Fail when loopback-mode containers or images exist
|
||||
fail:
|
||||
msg: >
|
||||
Not configuring docker storage in direct-lvm mode as loopback-backed
|
||||
containers or images exist.
|
||||
Not configuring docker storage in {{ docker_storage_driver }} mode as
|
||||
loopback-backed containers or images exist.
|
||||
when:
|
||||
- "{{ 'Data loop file' in docker_info.stdout }}"
|
||||
- "{{ 'Images: 0' not in docker_info.stdout }}"
|
||||
|
@ -16,35 +16,37 @@
|
||||
- "/var/lib/docker/containers"
|
||||
become: True
|
||||
|
||||
- name: Ensure the docker storage data and metadata volumes exist
|
||||
lvol:
|
||||
vg: "{{ docker_storage_volume_group }}"
|
||||
lv: "{{ item.name }}"
|
||||
size: "{{ item.size }}"
|
||||
shrink: no
|
||||
state: present
|
||||
with_items:
|
||||
- name: "{{ docker_storage_volume_thinpool }}"
|
||||
size: "{{ docker_storage_volume_thinpool_size }}"
|
||||
- name: "{{ docker_storage_volume_thinpool_meta }}"
|
||||
size: "{{ docker_storage_volume_thinpool_meta_size }}"
|
||||
become: True
|
||||
- block:
|
||||
- name: Ensure the docker storage data and metadata volumes exist
|
||||
lvol:
|
||||
vg: "{{ docker_storage_volume_group }}"
|
||||
lv: "{{ item.name }}"
|
||||
size: "{{ item.size }}"
|
||||
shrink: no
|
||||
state: present
|
||||
with_items:
|
||||
- name: "{{ docker_storage_volume_thinpool }}"
|
||||
size: "{{ docker_storage_volume_thinpool_size }}"
|
||||
- name: "{{ docker_storage_volume_thinpool_meta }}"
|
||||
size: "{{ docker_storage_volume_thinpool_meta_size }}"
|
||||
become: True
|
||||
|
||||
- name: Ensure the docker storage volume is converted to a thinpool
|
||||
command: >
|
||||
lvconvert -y --zero n -c 512K
|
||||
--thinpool {{ docker_storage_volume_group }}/{{ docker_storage_volume_thinpool }}
|
||||
--poolmetadata {{ docker_storage_volume_group }}/{{ docker_storage_volume_thinpool_meta }}
|
||||
become: True
|
||||
- name: Ensure the docker storage volume is converted to a thinpool
|
||||
command: >
|
||||
lvconvert -y --zero n -c 512K
|
||||
--thinpool {{ docker_storage_volume_group }}/{{ docker_storage_volume_thinpool }}
|
||||
--poolmetadata {{ docker_storage_volume_group }}/{{ docker_storage_volume_thinpool_meta }}
|
||||
become: True
|
||||
|
||||
- name: Ensure the docker storage metadata profile exists
|
||||
template:
|
||||
src: docker-thinpool.profile.j2
|
||||
dest: /etc/lvm/profile/docker-thinpool.profile
|
||||
become: True
|
||||
- name: Ensure the docker storage metadata profile exists
|
||||
template:
|
||||
src: docker-thinpool.profile.j2
|
||||
dest: /etc/lvm/profile/docker-thinpool.profile
|
||||
become: True
|
||||
|
||||
- name: Ensure the docker storage metadata profile is applied
|
||||
command: >
|
||||
lvchange --metadataprofile docker-thinpool
|
||||
{{ docker_storage_volume_group }}/{{ docker_storage_volume_thinpool }}
|
||||
become: True
|
||||
- name: Ensure the docker storage metadata profile is applied
|
||||
command: >
|
||||
lvchange --metadataprofile docker-thinpool
|
||||
{{ docker_storage_volume_group }}/{{ docker_storage_volume_thinpool }}
|
||||
become: True
|
||||
when: docker_storage_driver == 'devicemapper'
|
||||
|
@ -1,11 +1,13 @@
|
||||
{
|
||||
"storage-driver": "devicemapper",
|
||||
"storage-driver": "{% if docker_storage_driver == 'devicemapper' %}devicemapper{% else %}overlay{% endif %}",
|
||||
{% if docker_daemon_mtu %}
|
||||
"mtu": {{ docker_daemon_mtu }},
|
||||
{% endif %}
|
||||
"storage-opts": [
|
||||
{% if docker_storage_driver == 'devicemapper' %}
|
||||
"dm.thinpooldev=/dev/mapper/{{ docker_storage_volume_group | replace('-', '--') }}-{{ docker_storage_volume_thinpool | replace('-', '--') }}",
|
||||
"dm.use_deferred_removal=true",
|
||||
"dm.use_deferred_deletion=true"
|
||||
{% endif %}
|
||||
]
|
||||
}
|
||||
|
@ -2,6 +2,10 @@
|
||||
###############################################################################
|
||||
# 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.
|
||||
#docker_storage_volume_group:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user