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.
|
# Name of the docker storage LVM volume group.
|
||||||
docker_storage_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
|
- 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 }}"
|
||||||
|
@ -16,35 +16,37 @@
|
|||||||
- "/var/lib/docker/containers"
|
- "/var/lib/docker/containers"
|
||||||
become: True
|
become: True
|
||||||
|
|
||||||
- name: Ensure the docker storage data and metadata volumes exist
|
- block:
|
||||||
lvol:
|
- name: Ensure the docker storage data and metadata volumes exist
|
||||||
vg: "{{ docker_storage_volume_group }}"
|
lvol:
|
||||||
lv: "{{ item.name }}"
|
vg: "{{ docker_storage_volume_group }}"
|
||||||
size: "{{ item.size }}"
|
lv: "{{ item.name }}"
|
||||||
shrink: no
|
size: "{{ item.size }}"
|
||||||
state: present
|
shrink: no
|
||||||
with_items:
|
state: present
|
||||||
- name: "{{ docker_storage_volume_thinpool }}"
|
with_items:
|
||||||
size: "{{ docker_storage_volume_thinpool_size }}"
|
- name: "{{ docker_storage_volume_thinpool }}"
|
||||||
- name: "{{ docker_storage_volume_thinpool_meta }}"
|
size: "{{ docker_storage_volume_thinpool_size }}"
|
||||||
size: "{{ docker_storage_volume_thinpool_meta_size }}"
|
- name: "{{ docker_storage_volume_thinpool_meta }}"
|
||||||
become: True
|
size: "{{ docker_storage_volume_thinpool_meta_size }}"
|
||||||
|
become: True
|
||||||
|
|
||||||
- name: Ensure the docker storage volume is converted to a thinpool
|
- name: Ensure the docker storage volume is converted to a thinpool
|
||||||
command: >
|
command: >
|
||||||
lvconvert -y --zero n -c 512K
|
lvconvert -y --zero n -c 512K
|
||||||
--thinpool {{ docker_storage_volume_group }}/{{ docker_storage_volume_thinpool }}
|
--thinpool {{ docker_storage_volume_group }}/{{ docker_storage_volume_thinpool }}
|
||||||
--poolmetadata {{ docker_storage_volume_group }}/{{ docker_storage_volume_thinpool_meta }}
|
--poolmetadata {{ docker_storage_volume_group }}/{{ docker_storage_volume_thinpool_meta }}
|
||||||
become: True
|
become: True
|
||||||
|
|
||||||
- name: Ensure the docker storage metadata profile exists
|
- name: Ensure the docker storage metadata profile exists
|
||||||
template:
|
template:
|
||||||
src: docker-thinpool.profile.j2
|
src: docker-thinpool.profile.j2
|
||||||
dest: /etc/lvm/profile/docker-thinpool.profile
|
dest: /etc/lvm/profile/docker-thinpool.profile
|
||||||
become: True
|
become: True
|
||||||
|
|
||||||
- name: Ensure the docker storage metadata profile is applied
|
- name: Ensure the docker storage metadata profile is applied
|
||||||
command: >
|
command: >
|
||||||
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'
|
||||||
|
@ -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 %}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -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:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user