diff --git a/roles/backend_setup/tasks/main.yml b/roles/backend_setup/tasks/main.yml index a916205..cea41cd 100644 --- a/roles/backend_setup/tasks/main.yml +++ b/roles/backend_setup/tasks/main.yml @@ -59,6 +59,13 @@ tags: - thickvol +# Run pre-requisites check before creating thinpools +- name: Run pre-requisites tests to create thinpools + import_tasks: thin_pool_prereqs.yml + when: gluster_infra_thinpools is defined + tags: + - thinprereq + # Create a thinpool for the given volume group - name: Create thin pool import_tasks: thin_pool_create.yml diff --git a/roles/backend_setup/tasks/thin_pool_create.yml b/roles/backend_setup/tasks/thin_pool_create.yml index 0bbb3e3..1255be8 100644 --- a/roles/backend_setup/tasks/thin_pool_create.yml +++ b/roles/backend_setup/tasks/thin_pool_create.yml @@ -30,7 +30,7 @@ thinpool: "{{ item.thinpoolname }}" size: "{{ item.thinpoolsize | default('100%FREE') }}" opts: " --chunksize {{ lv_chunksize }} - --poolmetadatasize {{ item.poolmetadatasize }} + --poolmetadatasize {{ item.poolmetadatasize | default('16G') }} --zero n" with_items: "{{ gluster_infra_thinpools }}" when: gluster_infra_thinpools is defined diff --git a/roles/backend_setup/tasks/thin_pool_prereqs.yml b/roles/backend_setup/tasks/thin_pool_prereqs.yml new file mode 100644 index 0000000..9fd2280 --- /dev/null +++ b/roles/backend_setup/tasks/thin_pool_prereqs.yml @@ -0,0 +1,45 @@ +--- +# POOLMETADATASIZE: +# The maximum possible size for a metadata LV is *16 GiB*. Gluster *recommends* +# creating the metadata device of the maximum supported size. You can allocate +# less than the maximum if space is a concern, but in this case you should +# allocate a minimum of 0.5% of the pool size. + +# Gather the volume group size for the thinpools +- name: Check the volume-group size of the remote host + setup: + filter: 'ansible_lvm' + +# Build a new list with the vgsize for the given thinpools. There could be +# cases where thinpoolsize might not be provided. In such cases we compare +# against the vg size +- set_fact: + g_thinpools: "{{ g_thinpools|default([]) + [item|combine({'vgsize': + ansible_facts['lvm']['vgs'][item.vgname] + ['size_g']|int})] }}" + loop: "{{ gluster_infra_thinpools }}" + loop_control: + label: "{{item.vgname}}" + +# If user provides the POOLMETADATASIZE then validate if it is greater than 0.5% +# of the thinpool size. If the user does not provide POOLMETADATASIZE we default +# to 16G +- name: Fail if the given poolmetadatasize is < 0.05% of poolsize + set_fact: + is_lesser: "{{ item.poolmetadatasize[:-1]|float < 0.005 * + item.thinpoolsize[:-1]|float }}" + with_items: "{{ g_thinpools }}" + when: item.poolmetadatasize is defined and + item.thinpoolsize is defined + failed_when: is_lesser + +# If thinpoolsize is not defined, we use the entire vg. Thus, we compare if +# poolmetadatasize is less than 0.5% vg size +- name: Fail if the given poolmetadatasize is < 0.05% of vg size + set_fact: + is_lesser: "{{ item.poolmetadatasize[:-1]|float < 0.005 * + item.vgsize|float }}" + with_items: "{{ g_thinpools }}" + when: item.poolmetadatasize is defined and + item.thinpoolsize is not defined + failed_when: is_lesser