summaryrefslogtreecommitdiffstats
path: root/tools/cicdansible/roles/setup_openstack_infrastructure/tasks/configure/volume.yml
blob: 568b720266c01418316faddf280ef430af46a7a9 (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
#Configure a single openstack volume.
- name: "Set volume path"
  set_fact:
    volume_path: "/dev/disk/by-id/virtio-{{ volume_id | truncate(20, True, '') }}"
- name: "Set partition path"
  set_fact:
    partition_path: "{{ volume_path }}-part1"
- name: "Wait for volume"
  #We do not do it normally, because we want to trigger udev (workaround for some bugs).
  shell: "udevadm trigger && udevadm settle && [ -b {{ volume_path }} ]"
  register: result
  retries: 30
  delay: 10
  until: result.rc == 0
- name: "Partition volume"
  parted:
    device: "{{ volume_path }}"
    number: 1
    label: msdos
    flags: boot
    part_type: primary
    state: present
- name: "Wait for partition to appear"
  stat:
    path: "{{ partition_path }}"
    follow: true
  register: part_stat
  delay: 1
  retries: 5
  until: part_stat.stat.isblk is defined and part_stat.stat.isblk
- name: "Create xfs filesystem on volume"
  filesystem:
    dev: "{{ partition_path }}"
    type: xfs
- name: "Ensure that the mountpoint exists"
  file:
    path: "{{ mountpoint }}"
    owner: root
    group: root
    mode: 0755
    state: directory
- name: "Mount filesystem"
  mount:
    src: "{{ partition_path }}"
    path: "{{ mountpoint }}"
    fstype: xfs
    state: mounted