From c969394a52c311f1ff5cc2fc669276bc8e2b4e4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20M=C3=ADnguez?= Date: Wed, 4 Oct 2017 03:31:56 +0200 Subject: Required variables to create dedicated lv (#766) * Required variables to create dedicated lv https://bugzilla.redhat.com/show_bug.cgi?id=1490910#c11 * Fixed lint and added distribution to checks --- roles/docker-storage-setup/defaults/main.yaml | 2 ++ roles/docker-storage-setup/tasks/main.yaml | 35 +++++++++++++++++----- .../templates/docker-storage-setup-dm.j2 | 4 +++ .../templates/docker-storage-setup-overlayfs.j2 | 6 ++++ .../templates/docker-storage-setup.j2 | 4 --- 5 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 roles/docker-storage-setup/templates/docker-storage-setup-dm.j2 create mode 100644 roles/docker-storage-setup/templates/docker-storage-setup-overlayfs.j2 delete mode 100644 roles/docker-storage-setup/templates/docker-storage-setup.j2 (limited to 'roles/docker-storage-setup') diff --git a/roles/docker-storage-setup/defaults/main.yaml b/roles/docker-storage-setup/defaults/main.yaml index e36f1b85a..062f543ad 100644 --- a/roles/docker-storage-setup/defaults/main.yaml +++ b/roles/docker-storage-setup/defaults/main.yaml @@ -3,3 +3,5 @@ docker_dev: "/dev/sdb" docker_vg: "docker-vol" docker_data_size: "95%VG" docker_dm_basesize: "3G" +container_root_lv_name: "dockerlv" +container_root_lv_mount_path: "/var/lib/docker" diff --git a/roles/docker-storage-setup/tasks/main.yaml b/roles/docker-storage-setup/tasks/main.yaml index 7202bc46b..209062ca7 100644 --- a/roles/docker-storage-setup/tasks/main.yaml +++ b/roles/docker-storage-setup/tasks/main.yaml @@ -1,8 +1,29 @@ --- -- name: create the docker-storage-setup config file - template: - src: "{{ role_path }}/templates/docker-storage-setup.j2" - dest: /etc/sysconfig/docker-storage-setup - owner: root - group: root - mode: 0644 +- block: + - name: create the docker-storage config file + template: + src: "{{ role_path }}/templates/docker-storage-setup-overlayfs.j2" + dest: /etc/sysconfig/docker-storage-setup + owner: root + group: root + mode: 0644 + + when: + - ansible_distribution_version | version_compare('7.4', '>=') + - ansible_distribution == "RedHat" + +- block: + - name: create the docker-storage-setup config file + template: + src: "{{ role_path }}/templates/docker-storage-setup-dm.j2" + dest: /etc/sysconfig/docker-storage-setup + owner: root + group: root + mode: 0644 + + when: + - ansible_distribution_version | version_compare('7.4', '<') + - ansible_distribution == "RedHat" + +- name: start docker + service: name=docker state=started enabled=true diff --git a/roles/docker-storage-setup/templates/docker-storage-setup-dm.j2 b/roles/docker-storage-setup/templates/docker-storage-setup-dm.j2 new file mode 100644 index 000000000..b5869feff --- /dev/null +++ b/roles/docker-storage-setup/templates/docker-storage-setup-dm.j2 @@ -0,0 +1,4 @@ +DEVS="{{ docker_dev }}" +VG="{{ docker_vg }}" +DATA_SIZE="{{ docker_data_size }}" +EXTRA_DOCKER_STORAGE_OPTIONS="--storage-opt dm.basesize={{ docker_dm_basesize }}" diff --git a/roles/docker-storage-setup/templates/docker-storage-setup-overlayfs.j2 b/roles/docker-storage-setup/templates/docker-storage-setup-overlayfs.j2 new file mode 100644 index 000000000..4bef865c8 --- /dev/null +++ b/roles/docker-storage-setup/templates/docker-storage-setup-overlayfs.j2 @@ -0,0 +1,6 @@ +DEVS="{{ docker_dev }}" +VG="{{ docker_vg }}" +DATA_SIZE="{{ docker_data_size }}" +STORAGE_DRIVER=overlay2 +CONTAINER_ROOT_LV_NAME="{{ container_root_lv_name }}" +CONTAINER_ROOT_LV_MOUNT_PATH="{{ container_root_lv_mount_path }}" diff --git a/roles/docker-storage-setup/templates/docker-storage-setup.j2 b/roles/docker-storage-setup/templates/docker-storage-setup.j2 deleted file mode 100644 index b5869feff..000000000 --- a/roles/docker-storage-setup/templates/docker-storage-setup.j2 +++ /dev/null @@ -1,4 +0,0 @@ -DEVS="{{ docker_dev }}" -VG="{{ docker_vg }}" -DATA_SIZE="{{ docker_data_size }}" -EXTRA_DOCKER_STORAGE_OPTIONS="--storage-opt dm.basesize={{ docker_dm_basesize }}" -- cgit v1.2.3