Defined Type: labs_lvm::volume

Defined in:
modules/labs_lvm/manifests/volume.pp

Overview

Parameters:

  • volname (Any) (defaults to: $title)
  • mountat (Any) (defaults to: "/mnt/${volname}")
  • mountowner (Any) (defaults to: 'root')
  • mountgroup (Any) (defaults to: 'root')
  • mountmode (Any) (defaults to: '755')
  • size (Any) (defaults to: '100%FREE')
  • fstype (Any) (defaults to: 'ext4')
  • mkfs_opt (Any) (defaults to: '')
  • options (Any) (defaults to: 'defaults')


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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'modules/labs_lvm/manifests/volume.pp', line 29

define labs_lvm::volume(
    $volname    = $title,
    $mountat    = "/mnt/${volname}",
    $mountowner = 'root',
    $mountgroup = 'root',
    $mountmode  = '755',
    $size       = '100%FREE',
    $fstype     = 'ext4',
    $mkfs_opt   = '',
    $options    = 'defaults',
) {
    include ::labs_lvm

    # Make sure there's space available to partition before we start partitioning.
    # Only check if we haven't already created the volume.
    exec { "available-space-${volname}":
        command   => '/usr/local/sbin/pv-free',
        returns   => 0,
        unless    => "/bin/mountpoint -q '${mountat}'",
        logoutput => true,
    }

    exec { "create-vd-${volname}":
        creates   => "/dev/vd/${volname}",
        unless    => "/bin/mountpoint -q '${mountat}'",
        logoutput => 'on_failure',
        require   => [
            File['/usr/local/sbin/make-instance-vol'],
            Exec['create-volume-group'],
            Exec["available-space-${volname}"]
        ],
        command   => "/usr/local/sbin/make-instance-vol '${volname}' '${size}' '${fstype}' ${mkfs_opt}",
    }

    # (possible) creation of the mountpoint needs to happen
    # here before the mount, because a file{} stanza will
    # apply to the mountpoint rather than the mounted root
    # until at least the second puppet run.

    exec { "create-mountpoint-${volname}":
        creates   => $mountat,
        logoutput => 'on_failure',
        command   => "/bin/mkdir -p '${mountat}'",
        require   => [
            Exec["available-space-${volname}"]
        ],
    }

    mount { $mountat:
        ensure  => mounted,
        atboot  => true,
        device  => "/dev/vd/${volname}",
        options => $options,
        fstype  => $fstype,
        require => [
            Exec["create-vd-${volname}"],
            Exec["create-mountpoint-${volname}"],
        ],
    }

    file { $mountat:
        ensure  => directory,
        owner   => $mountowner,
        group   => $mountgroup,
        mode    => $mountmode,
        require => Mount[$mountat],
    }

    labs_lvm::extend { $mountat:
        size    => $size,
        require => [ Mount[$mountat] ],
    }

}