summaryrefslogtreecommitdiffstats
path: root/roles/ands_storage
diff options
context:
space:
mode:
Diffstat (limited to 'roles/ands_storage')
-rw-r--r--roles/ands_storage/README25
-rw-r--r--roles/ands_storage/defaults/main.yml13
-rw-r--r--roles/ands_storage/handlers/main.yml5
-rw-r--r--roles/ands_storage/tasks/detect_device.yml10
-rw-r--r--roles/ands_storage/tasks/main.yml45
5 files changed, 98 insertions, 0 deletions
diff --git a/roles/ands_storage/README b/roles/ands_storage/README
new file mode 100644
index 0000000..d17a6cd
--- /dev/null
+++ b/roles/ands_storage/README
@@ -0,0 +1,25 @@
+Dependencies:
+ - Executed on the fat storage nodes
+ - Ands data VG and mount-point should be configured or they will default to 'ands' and /mnt/ands
+
+Parameters:
+ - ands_data_path: Mount point of Ands Data Volume, defaults to '/mnt/ands'
+ - ands_data_vg / ands_data_lv / ands_data_device / ands_data_volume_size: Configures the LV for Ands Data Volume, VG defaults to 'ands'
+ - The Katrin VG will be created if not existing. The first non-partitioned device with at least 'ands_data_device_threshold' GB of space
+ will be used unless device is directlys specified with 'ands_data_device'. If ands_data_vg already exists, the 'ands_data_deivce'
+ will be ignored.
+ - Unless 'ands_data_volume_size' is specified, all available space on VG will be used (after creating heketi volume if it
+ resides on the same VG)
+ - ands_heketi_vg / ands_heketi_lv / ands_heketi_device / ands_heketi_volume_size: Configures the LV for Heketi volume manager
+ - The heketi LV is only created if 'ands_heketi_volume_size' is specified in the inventory
+ - By default, the 'ands_data_vg' will be used to create heketi volumes.
+ - If ands_heketi_device is specified, the VG will be created if not existing.
+
+Facts:
+ - ands_data_path:
+ - ands_data_vg:
+
+Actions:
+ - Configures Ands VG & LV on the storage nodes (and detects appropriate devices unless set in inventory)
+ - Mounts Ands data volume
+ \ No newline at end of file
diff --git a/roles/ands_storage/defaults/main.yml b/roles/ands_storage/defaults/main.yml
new file mode 100644
index 0000000..3eb68b5
--- /dev/null
+++ b/roles/ands_storage/defaults/main.yml
@@ -0,0 +1,13 @@
+---
+ands_data_vg: "ands"
+#ands_data_vg: "katrin"
+ands_data_path: "/mnt/{{ ands_data_vg }}"
+ands_data_lv: "{{ ands_data_vg }}_data"
+ands_data_volume_size: "100%FREE"
+ands_data_fs: "xfs"
+
+ands_data_device_threshold: 8192
+
+ands_heketi_vg: "{{ ands_data_vg }}"
+ands_heketi_lv: "{{ ands_data_vg }}_heketi"
+#ands_heketi_volume_size: "1024G"
diff --git a/roles/ands_storage/handlers/main.yml b/roles/ands_storage/handlers/main.yml
new file mode 100644
index 0000000..9f55771
--- /dev/null
+++ b/roles/ands_storage/handlers/main.yml
@@ -0,0 +1,5 @@
+---
+- name: ands_heketi_change
+ command: pvresize "/dev/{{ ands_heketi_vg }}/{{ ands_heketi_lv }}"
+ when: heketi_stat_result.stat.exists
+
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