summaryrefslogtreecommitdiff
path: root/tasks/create-data-volume.yml
blob: 74f43172fbed8fa860a8d076cfd8318dc17e48c6 (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
# Format a volume for data storage
#
# The pattern is to create an LVM volume group on the volume, with
# one logical volume set up. Snapshots can be taken of the data LV
# very quickly, allowing us to take backup copies without requiring
# long periods of downtime for the relevant services.
---

- name: ensure LVM monitor service is running
  service:
    name: lvm2-monitor.service
    enabled: yes
    state: started

- name: LVM logical volume group on /dev/vdb
  lvg:
    vg: vg0
    pvs: /dev/vdb

- name: logical volume for {{ lv_name }}
  lvol:
    vg: vg0
    lv: "{{ lv_name }}"
    size: "{{ lv_size }}"

# This will NEVER overwrite an existing filesystem. Unless you add
# 'force=yes' to the arguments. So don't do that. See:
# http://docs.ansible.com/filesystem_module.html.
- name: ext4 filesystem on /dev/vg0/{{ lv_name }}
  filesystem:
    fstype: ext4
    dev: "/dev/vg0/{{ lv_name }}"

- name: mount {{ lv_name }} logical volume
  mount:
    src: "/dev/vg0/{{ lv_name }}"
    name: "{{ mountpoint }}"
    fstype: ext4
    state: mounted
    opts: defaults,nofail