Defined Type: lvm::logical_volume

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

Summary

Manage a logical volume.

Overview

This will automatically set this volume group as a dependency, but it must be defined elsewhere using the volume_group resource type.

the partition size.

(if the LV found is larger then the size requests this is just logged not causing a FAIL)

are in sync. Cannot be changed on already mirrored volume. Take your mirror size in terabytes and round up that number to the next power of 2, using that number as the -R argument

Parameters:

  • volume_group (String[1]) —

    The volume group name associated with this logical volume.

  • size (Optional[String[1]]) (defaults to: undef) —

    Configures the size of the filesystem. Supports filesystem resizing. The size will be rounded up to the nearest multiple of

  • initial_size (Optional[String[1]]) (defaults to: undef) —

    The initial size of the logical volume. This will only apply to newly-created volumes

  • ensure (Enum['absent', 'present']) (defaults to: present)
  • options (String[1]) (defaults to: 'defaults') —

    Params for the mkfs command

  • pass (Variant[String[1], Integer]) (defaults to: '2')
  • dump (Variant[String[1], Integer]) (defaults to: '0')
  • fs_type (String[1]) (defaults to: 'ext4') —

    The file system type. eg. ext3.

  • mkfs_options (Optional[String[1]]) (defaults to: undef)
  • mountpath (Stdlib::Absolutepath) (defaults to: "/${name}")
  • mountpath_require (Boolean) (defaults to: false)
  • mounted (Boolean) (defaults to: true) —

    If puppet should mount the volume. This only affects what puppet will do, and not what will be mounted at boot-time.

  • createfs (Boolean) (defaults to: true)
  • extents (Optional[String[1]]) (defaults to: undef) —

    The number of logical extents to allocate for the new logical volume. Set to undef to use all available space

  • stripes (Optional[Variant[String[1], Integer]]) (defaults to: undef) —

    The number of stripes to allocate for the new logical volume.

  • stripesize (Optional[Variant[String[1], Integer]]) (defaults to: undef) —

    The stripesize to use for the new logical volume.

  • readahead (Optional[Variant[String[1], Integer]]) (defaults to: undef) —

    The readahead count to use for the new logical volume.

  • range (Optional[Enum['maximum', 'minimum']]) (defaults to: undef) —
    • Set to true if the ‘size’ parameter specified, is just the minimum size you need
  • size_is_minsize (Optional[Boolean]) (defaults to: undef) —

    Lists strings for access control for connection method, users, databases, IPv4 addresses;

  • type (Optional[String[1]]) (defaults to: undef) —

    Configures the logical volume type. AIX only

  • thinpool (Variant[Boolean, String]) (defaults to: false) —
    • Set to true to create a thin pool or to pool name to create thin volume
  • poolmetadatasize (Optional[Integer[0, 4]]) (defaults to: undef) —

    Set the initial size of the logical volume pool metadata on creation

  • mirror (Optional[String[1]]) (defaults to: undef) —

    The number of mirrors of the volume.

  • mirrorlog (Optional[Enum['core', 'disk', 'mirrored']]) (defaults to: undef) —

    How to store the mirror log (Allowed values: core, disk, mirrored).

  • no_sync (Optional[Boolean]) (defaults to: undef) —

    An optimization in lvcreate, at least on Linux.

  • region_size (Optional[Variant[String[1], Integer]]) (defaults to: undef) —

    A mirror is divided into regions of this size (in MB), the mirror log uses this granularity to track which regions

  • alloc (Optional[Enum['anywhere', 'contiguous', 'cling', 'inherit', 'normal']]) (defaults to: undef) —

    The allocation policy when a command needs to allocate Physical Extents from the Volume Group.

  • yes_flag (Boolean) (defaults to: false) —

    If set to true, do not prompt for confirmation interactively but always assume the answer yes.



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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'vendor_modules/lvm/manifests/logical_volume.pp', line 65

define lvm::logical_volume (
  String[1] $volume_group,
  Optional[String[1]] $size                                                     = undef,
  Optional[String[1]] $initial_size                                             = undef,
  Enum['absent', 'present'] $ensure                                             = present,
  String[1] $options                                                            = 'defaults',
  Variant[String[1], Integer] $pass                                             = '2',
  Variant[String[1], Integer] $dump                                             = '0',
  String[1] $fs_type                                                            = 'ext4',
  Optional[String[1]] $mkfs_options                                             = undef,
  Stdlib::Absolutepath $mountpath                                               = "/${name}",
  Boolean $mountpath_require                                                    = false,
  Boolean $mounted                                                              = true,
  Boolean $createfs                                                             = true,
  Optional[String[1]] $extents                                                  = undef,
  Optional[Variant[String[1], Integer]] $stripes                                = undef,
  Optional[Variant[String[1], Integer]] $stripesize                             = undef,
  Optional[Variant[String[1], Integer]] $readahead                              = undef,
  Optional[Enum['maximum', 'minimum']] $range                                   = undef,
  Optional[Boolean] $size_is_minsize                                            = undef,
  Optional[String[1]] $type                                                     = undef,
  Variant[Boolean, String] $thinpool                                            = false,
  Optional[Integer[0, 4]] $poolmetadatasize                                     = undef,
  Optional[String[1]] $mirror                                                   = undef,
  Optional[Enum['core', 'disk', 'mirrored']] $mirrorlog                         = undef,
  Optional[Boolean] $no_sync                                                    = undef,
  Optional[Variant[String[1], Integer]] $region_size                            = undef,
  Optional[Enum['anywhere', 'contiguous', 'cling', 'inherit', 'normal']] $alloc = undef,
  Boolean $yes_flag                                                             = false,
) {
  $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,
    yes_flag         => $yes_flag,
  }

  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', '/sbin'],
        command => "mkdir -p ${fixed_mountpath}",
        unless  => "test -d ${fixed_mountpath}",
        onlyif  => "lvs /dev/${volume_group}/${name} > /dev/null 2>&1",
        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,
    }
  }
}