kayobe/ansible/roles/docker-devicemapper/tasks/main.yml
Mark Goddard efb8b8bd27 Use docker_custom_config variable
In the Train cycle, Kolla Ansible added support for
docker_custom_config, and writes out configuration to
/etc/docker/daemon.json. This will conflict with Kayobe's configuration
of that file, and changes made by kayobe will be reversed when
kolla-ansible bootstrap-servers is run.

This change uses the new variable to pass daemon.json configuration
through to kolla ansible. Because the ordering has changed, we also need
to separate out the devicemapper setup and run this prior to starting
docker.

Change-Id: Idc3fa9fefd8242ef9db76d4d773885e3594b453a
Depends-On: https://review.opendev.org/691001
Story: 2006764
Task: 37277
2019-10-25 17:08:56 +01:00

59 lines
2.0 KiB
YAML

---
- name: Query docker daemon information
command: "docker info"
register: docker_info
changed_when: False
failed_when: False
- name: Fail when non-devicemapper containers or images exist
fail:
msg: >
Not configuring docker storage in {{ docker_storage_driver }} mode as
non-devicemapper containers or images exist.
when:
- docker_info.rc == 0
- "'Data loop file' in docker_info.stdout or 'devicemapper' not in docker_info.stdout"
- "'Images: 0' not in docker_info.stdout or 'Containers: 0' not in docker_info.stdout"
- name: Ensure the docker storage metadata profile exists
template:
src: docker-thinpool.profile.j2
dest: /etc/lvm/profile/docker-thinpool.profile
become: True
- name: Query LVM thinpool volume
command: "lvs {{ docker_storage_volume_group }}/{{ docker_storage_volume_thinpool }}"
register: lvs_result
changed_when: false
failed_when: false
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 metadata profile is applied
command: >
lvchange --metadataprofile docker-thinpool
{{ docker_storage_volume_group }}/{{ docker_storage_volume_thinpool }}
become: True
when: lvs_result.rc != 0