diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2017-04-01 04:53:28 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2017-04-01 04:53:28 +0200 |
commit | e7ed329bd81c2273c03e94c93c9ce9c1d01cdc86 (patch) | |
tree | 444778102e4f73b83ef9462235b7f614b004b264 /roles/ands_storage/tasks | |
download | ands-e7ed329bd81c2273c03e94c93c9ce9c1d01cdc86.tar.gz ands-e7ed329bd81c2273c03e94c93c9ce9c1d01cdc86.tar.bz2 ands-e7ed329bd81c2273c03e94c93c9ce9c1d01cdc86.tar.xz ands-e7ed329bd81c2273c03e94c93c9ce9c1d01cdc86.zip |
Initial import
Diffstat (limited to 'roles/ands_storage/tasks')
-rw-r--r-- | roles/ands_storage/tasks/detect_device.yml | 10 | ||||
-rw-r--r-- | roles/ands_storage/tasks/main.yml | 45 |
2 files changed, 55 insertions, 0 deletions
diff --git a/roles/ands_storage/tasks/detect_device.yml b/roles/ands_storage/tasks/detect_device.yml new file mode 100644 index 0000000..0fb9764 --- /dev/null +++ b/roles/ands_storage/tasks/detect_device.yml @@ -0,0 +1,10 @@ +- name: find large block devices + set_fact: ands_data_device="/dev/{{ item.key }}" +# debug: msg="{{ item.key }} - {{ (item.value.sectors | int) * (item.value.sectorsize | int) / 1024 / 1024 / 1024 }} GB" + with_dict: "{{ ansible_devices }}" + when: + - not ands_data_device is defined + - not item.value.partitions + - not item.value.holders + - item.value.sectors is defined + - ( (item.value.sectors | int) * (item.value.sectorsize | int) / 1024 / 1024 / 1024 ) > ands_data_device_threshold diff --git a/roles/ands_storage/tasks/main.yml b/roles/ands_storage/tasks/main.yml new file mode 100644 index 0000000..a86babe --- /dev/null +++ b/roles/ands_storage/tasks/main.yml @@ -0,0 +1,45 @@ +--- +- name: Publish some facts + set_fact: + ands_data_vg: "{{ ands_data_vg }}" + ands_data_path: "{{ ands_data_path }}" + +- name: Analyze storage devices + include: detect_device.yml + when: not ands_data_device is defined + +- name: Create Ands VG + lvg: vg="{{ ands_data_vg }}" pvs="{{ ands_data_device }}" + when: ands_data_device is defined + +- name: Create Heketi VG + lvg: vg="{{ ands_heketi_vg }}" pvs="{{ ands_heketi_device }}" + when: ands_heketi_device is defined + +- name: Check if Heketi Volume already exists + stat: path="/dev/{{ ands_heketi_vg }}/{{ ands_heketi_lv }}" + register: heketi_stat_result + changed_when: false + when: ands_heketi_volume_size is defined + +- name: Create Heketi Volume + lvol: vg="{{ ands_heketi_vg }}" lv="{{ ands_heketi_lv }}" size="{{ ands_heketi_volume_size }}" + notify: ands_heketi_change + when: ands_heketi_volume_size is defined + +- name: Add Heketi to Storage Domains + set_fact: ands_storage_domains="{{ ands_storage_domains | union([ands_heketi_domain]) }}" + when: + - (ansible_lvm.lvs[ands_heketi_lv] is defined) or (ands_heketi_volume_size is defined) + - heketi_stat_result.stat.exists == False + +- name: Create Ands Data Volume + lvol: vg="{{ ands_data_vg }}" lv="{{ ands_data_lv }}" size="{{ ands_data_volume_size }}" + +- name: Ensure Ands Data Volume is formatted and resize if necessary + filesystem: fstype="xfs" resizefs="yes" dev="/dev/{{ ands_data_vg }}/{{ ands_data_lv }}" + +- name: Mount Ands Data Volume + mount: name="{{ ands_data_path }}" src="/dev/{{ ands_data_vg }}/{{ ands_data_lv }}" fstype="{{ ands_data_fs }}" opts="defaults" state="mounted" + +
\ No newline at end of file |