summaryrefslogtreecommitdiffstats
path: root/scripts/clvm-vg/main.yml
blob: 846c70be64059c7354304abd2f2cafd98040145e (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Copyright (C) 2015 Kristoffer Gronlund
#
# License: GNU General Public License (GPL)
version: 2.2
category: File System
shortdesc: Cluster-aware LVM (auto activation)
longdesc: |
  Configures a resource to manage the activation of a volume
  group. Before adding this resource, you need to proceed as below
  to create new VG and LVs. Refer to manpage lvmlockd(8) for more
  detailed steps.

  - create VG on shared devices:
    vgcreate --shared <vgname> <devices>

  - create an LV:
    lvcreate -an -L <size> -n <lvname> <vgname>

  For LVs in shared VG, there are two activation modes: "exclusive"
  and "shared". With the "exclusive" mode, a LV activated on one
  host cannot be activated on another, which is the default option.
  With the "shared" mode, a LV can be activated concurrently on
  multiple hosts, and cluster filesystem like OCFS2 can use it.

  If the resource is created with activation_mode="shared", it will
  be added to the cLVM group resource. The cLVM group resource is
  assumed to be named g-clvm. This is the name of the resource created
  by the clvm wizard.

parameters:
  - name: id
    shortdesc: Volume group instance ID
    longdesc: Unique ID for the volume group instance in the cluster.
    required: true
    unique: true
    type: resource
    value: vg1

  - name: vgname
    shortdesc: Volume Group Name
    longdesc: LVM volume group name.
    required: true
    type: string
    value: vg1

  - name: activation_mode
    shortdesc: LVM activation mode
    longdesc: |
      How a VG/LV is activated in cluster, either "exclusive" (default) or "shared".
      It depends on the filesystem you need to create on the LV to choose the
      activation mode. For local filesystem like ext4, you need "exclusive" activation.
      For cluster filesystem like OCFS2, you need "shared" activation.
    required: false
    type: string
    value: exclusive

  - name: clvm-group
    shortdesc: cLVM Resource Group ID
    longdesc: ID of the cLVM resource group.
    type: resource
    required: false
    value: g-clvm

actions:
  - cib: |
      primitive {{id}} ocf:heartbeat:LVM-activate
        params vgname="{{vgname}}" vg_access_mode="lvmlockd" activation_mode="{{activation_mode}}"
        op start timeout=60s
        op stop timeout=60s
        op monitor interval=30s timeout=90s

  - crm: configure modgroup {{clvm-group}} add {{id}}
    shortdesc: Add volume group to the cLVM group resource
    when: activation_mode == "shared"