summaryrefslogtreecommitdiffstats
path: root/roles/ands_storage/tasks/main.yml
blob: 7146da05c0aca5f86af7a70db13f1d3f11776ce2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
- name: Publish some facts
  set_fact:
    ands_data_vg: "{{ ands_data_vg }}"
    ands_data_path: "{{ ands_data_path }}"

- name: Analyze storage devices
  include_tasks: 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
    - ansible_lvm.vgs[ands_data_vg] is not defined

- name: Create Heketi VG
  lvg: vg="{{ ands_heketi_vg }}" pvs="{{ ands_heketi_device }}"
  when: 
    - ands_heketi_device is defined
    - ansible_lvm.vgs[ands_heketi_vg] is not 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: 
    - ands_configure_heketi
    - ands_heketi_domain is defined
    - (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" 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"

# System complains if we try to resize unmounted file system
- 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: Provision Ands local storage domains  
  include_tasks: hostmount.yml
  with_items: "{{ ands_local_storage_domains | default([]) }}"
  when: domain.servers in group_names
  loop_control:
    loop_var: domain