Defined Type: lvm::logical_volume

Defined in:
vendor_modules/lvm/manifests/logical_volume.pp

Overview

Define: lvm::logical_volume

Parameters:

  • volume_group (Any)
  • size (Any) (defaults to: undef)
  • initial_size (Any) (defaults to: undef)
  • ensure (Enum['absent', 'present']) (defaults to: present)
  • options (Any) (defaults to: 'defaults')
  • pass (Any) (defaults to: '2')
  • dump (Any) (defaults to: '0')
  • fs_type (Any) (defaults to: 'ext4')
  • mkfs_options (Any) (defaults to: undef)
  • mountpath (Stdlib::Absolutepath) (defaults to: "/${name}")
  • mountpath_require (Boolean) (defaults to: false)
  • mounted (Boolean) (defaults to: true)
  • createfs (Boolean) (defaults to: true)
  • extents (Any) (defaults to: undef)
  • stripes (Any) (defaults to: undef)
  • stripesize (Any) (defaults to: undef)
  • readahead (Any) (defaults to: undef)
  • range (Any) (defaults to: undef)
  • size_is_minsize (Any) (defaults to: undef)
  • type (Any) (defaults to: undef)
  • thinpool (Variant[Boolean, String]) (defaults to: false)
  • poolmetadatasize (Any) (defaults to: undef)
  • mirror (Any) (defaults to: undef)
  • mirrorlog (Any) (defaults to: undef)
  • no_sync (Any) (defaults to: undef)
  • region_size (Any) (defaults to: undef)
  • alloc (Any) (defaults to: undef)


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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'vendor_modules/lvm/manifests/logical_volume.pp', line 3

define lvm::logical_volume (
  $volume_group,
  $size                              = undef,
  $initial_size                      = undef,
  Enum['absent', 'present'] $ensure  = present,
  $options                           = 'defaults',
  $pass                              = '2',
  $dump                              = '0',
  $fs_type                           = 'ext4',
  $mkfs_options                      = undef,
  Stdlib::Absolutepath $mountpath    = "/${name}",
  Boolean $mountpath_require         = false,
  Boolean $mounted                   = true,
  Boolean $createfs                  = true,
  $extents                           = undef,
  $stripes                           = undef,
  $stripesize                        = undef,
  $readahead                         = undef,
  $range                             = undef,
  $size_is_minsize                   = undef,
  $type                              = undef,
  Variant[Boolean, String] $thinpool = false,
  $poolmetadatasize                  = undef,
  $mirror                            = undef,
  $mirrorlog                         = undef,
  $no_sync                           = undef,
  $region_size                       = undef,
  $alloc                             = undef,
) {

  $lvm_device_path = "/dev/${volume_group}/${name}"

  if $mountpath_require and $fs_type != 'swap' {
    Mount {
      require => File[$mountpath],
    }
  }

  if $fs_type == 'swap' {
    $mount_title     = $lvm_device_path
    $fixed_mountpath = "swap_${lvm_device_path}"
    $fixed_pass      = 0
    $fixed_dump      = 0
    $mount_ensure    = $ensure ? {
      'absent' => absent,
      default  => present,
    }
  } else {
    $mount_title     = $mountpath
    $fixed_mountpath = $mountpath
    $fixed_pass      = $pass
    $fixed_dump      = $dump
    $mount_ensure    = $ensure ? {
      'absent' => absent,
      default  => $mounted ? {
        true      => mounted,
        false     => present,
      }
    }
  }

  if $ensure == 'present' and $createfs {
    Logical_volume[$name]
    -> Filesystem[$lvm_device_path]
    -> Mount[$mount_title]
  } elsif $ensure != 'present' and $createfs {
    Mount[$mount_title]
    -> Filesystem[$lvm_device_path]
    -> Logical_volume[$name]
  }

  logical_volume { $name:
    ensure           => $ensure,
    volume_group     => $volume_group,
    size             => $size,
    initial_size     => $initial_size,
    stripes          => $stripes,
    stripesize       => $stripesize,
    readahead        => $readahead,
    extents          => $extents,
    range            => $range,
    size_is_minsize  => $size_is_minsize,
    type             => $type,
    thinpool         => $thinpool,
    poolmetadatasize => $poolmetadatasize,
    mirror           => $mirror,
    mirrorlog        => $mirrorlog,
    no_sync          => $no_sync,
    region_size      => $region_size,
    alloc            => $alloc,
  }

  if $createfs {
    filesystem { $lvm_device_path:
      ensure  => $ensure,
      fs_type => $fs_type,
      options => $mkfs_options,
    }
  }

  if $createfs or $ensure != 'present' {
    if $fs_type != 'swap' {
      exec { "ensure mountpoint '${fixed_mountpath}' exists":
        path    => [ '/bin', '/usr/bin' ],
        command => "mkdir -p ${fixed_mountpath}",
        unless  => "test -d ${fixed_mountpath}",
        before  => Mount[$mount_title],
      }
    }

    mount { $mount_title:
      ensure  => $mount_ensure,
      name    => $fixed_mountpath,
      device  => $lvm_device_path,
      fstype  => $fs_type,
      options => $options,
      pass    => $fixed_pass,
      dump    => $fixed_dump,
      atboot  => true,
    }
  }
}