Forge Home

lvm

Provides Puppet types and providers to manage Logical Volume Manager (LVM) features.

3,428,517 downloads

172 latest version

5.0 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 3.0.0 (latest)
  • 2.3.0
  • 2.2.0
  • 2.1.0
  • 2.0.3
  • 2.0.2
  • 2.0.1
  • 2.0.0
  • 1.4.0
  • 1.3.0
  • 1.2.0
  • 1.1.0
  • 1.0.1
  • 1.0.0
  • 0.9.0
  • 0.8.0
  • 0.7.0
  • 0.6.0
  • 0.5.0
  • 0.4.0
  • 0.3.3
  • 0.3.2
  • 0.3.1
  • 0.3.0
  • 0.2.0
  • 0.1.2
  • 0.1.1
  • 0.1.0
  • 0.0.1
released Dec 16th 2024
This version is compatible with:
  • Puppet Enterprise 2023.8.x, 2023.7.x, 2023.6.x, 2023.5.x, 2023.4.x, 2023.3.x, 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x
  • Puppet >= 7.0.0 < 9.0.0
  • , , , ,
Tasks:
  • ensure_fs
  • ensure_lv
  • ensure_pv
  • ensure_vg
  • extend_lv
  • extend_vg
  • mount_lv
Plans:
  • expand

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'puppetlabs-lvm', '3.0.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add puppetlabs-lvm
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install puppetlabs-lvm --version 3.0.0

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

puppetlabs/lvm — version 3.0.0 Dec 16th 2024

Puppet LVM Module

Provides Logical Volume Manager (LVM) types and providers for Puppet.

Usage Examples

This module provides four resource types (and associated providers): volume_group, logical_volume, physical_volume, and filesystem.

The basic dependency graph needed to define a working logical volume looks something like:

filesystem -> logical_volume -> volume_group -> physical_volume(s)

Here's a simple working example:

physical_volume { '/dev/hdc':
  ensure => present,
}

volume_group { 'myvg':
  ensure           => present,
  physical_volumes => '/dev/hdc',
}

logical_volume { 'mylv':
  ensure       => present,
  volume_group => 'myvg',
  size         => '20G',
}

filesystem { '/dev/myvg/mylv':
  ensure  => present,
  fs_type => 'ext3',
  options => '-b 4096 -E stride=32,stripe-width=64',
}

This simple 1 physical volume, 1 volume group, 1 logical volume case is provided as a simple volume definition, as well. The above could be shortened to be:

lvm::volume { 'mylv':
  ensure => present,
  vg     => 'myvg',
  pv     => '/dev/hdc',
  fstype => 'ext3',
  size   => '20G',
}

You can also describe your Volume Group like this:

class { 'lvm':
  volume_groups    => {
    'myvg' => {
      physical_volumes => [ '/dev/sda2', '/dev/sda3', ],
      logical_volumes  => {
        'opt'    => {'size' => '20G'},
        'tmp'    => {'size' => '1G' },
        'usr'    => {'size' => '3G' },
        'var'    => {'size' => '15G'},
        'home'   => {'size' => '5G' },
        'backup' => {
          'size'              => '5G',
          'mountpath'         => '/var/backups',
          'mountpath_require' => true,
        },
      },
    },
  },
}

This could be really convenient when used with hiera:

include lvm

and

---
lvm::volume_groups:
  myvg:
    physical_volumes:
      - /dev/sda2
      - /dev/sda3
    logical_volumes:
      opt:
        size: 20G
      tmp:
        size: 1G
      usr:
        size: 3G
      var:
        size: 15G
      home:
        size: 5G
      backup:
        size: 5G
        mountpath: /var/backups
        mountpath_require: true

or to just build the VG if it does not exist

---
lvm::volume_groups:
  myvg:
    createonly: true
    physical_volumes:
      /dev/sda2:
        unless_vg: 'myvg'
      /dev/sda3:
        unless_vg: 'myvg'
    logical_volumes:
      opt:
        size: 20G
      tmp:
        size: 1G
      usr:
        size: 3G
      var:
        size: 15G
      home:
        size: 5G
      backup:
        size: 5G
        mountpath: /var/backups
        mountpath_require: true

Except that in the latter case you cannot specify create options. If you want to omit the file system type, but still specify the size of the logical volume, i.e. in the case if you are planning on using this logical volume as a swap partition or a block device for a virtual machine image, you need to use a hash to pass the parameters to the definition.

If you need a more complex configuration, you'll need to build the resources out yourself.

Optional Values

The unless_vg (physical_volume) and createonly (volume_group) will check to see if "myvg" exists. If "myvg" does exist then they will not modify the physical volume or volume_group. This is useful if your environment is built with certain disks but they change while the server grows, shrinks or moves.

Example:

physical_volume { "/dev/hdc":
  ensure    => present,
  unless_vg => "myvg",
}

volume_group { "myvg":
  ensure           => present,
  physical_volumes => "/dev/hdc",
  createonly       => true,
}

Tasks

See tasks reference

Plans

See plans reference

Limitations

Namespacing

Due to puppet's lack of composite keys for resources, you currently cannot define two logical_volume resources with the same name but a different volume_group.

Removing Physical Volumes

You should not remove a physical_volume from a volume_group without ensuring the physical volume is no longer in use by a logical volume (and possibly doing a data migration with the pvmove executable).

Removing a physical_volume from a volume_group resource will cause the pvreduce to be executed -- no attempt is made to ensure pvreduce does not attempt to remove a physical volume in-use.

Resizing Logical Volumes

Logical volume size can be extended, but not reduced -- this is for safety, as manual intervention is probably required for data migration, etc.

Deprecation Notice

Some facts reported by this module are being deprecated in favor of upcoming structured facts. The following facts are being deprecated:

  • lvm_vg_*
  • lvm_vg_*_pvs
  • lvm_pv_*

License

This codebase is licensed under the GPL 2.0, however due to the nature of the codebase the open source dependencies may also use a combination of AGPL, BSD-2, BSD-3, GPL2.0, LGPL, MIT and MPL.

Contributors

Bruce Williams bruce@codefluency.com

Daniel Kerwin github@reductivelabs.com

Luke Kanies luke@reductivelabs.com

Matthaus Litteken matthaus@puppetlabs.com

Michael Stahnke stahnma@puppetlabs.com

Mikael Fridh frimik@gmail.com

Tim Hawes github@reductivelabs.com

Yury V. Zaytsev yury@shurup.com

csschwe csschwe@gmail.com

windowsrefund windowsrefund@gmail.com

Adam Gibbins github@adamgibbins.com

Steffen Zieger github@saz.sh

Jason A. Smith smithj4@bnl.gov

Mathieu Bornoz mathieu.bornoz@camptocamp.com

Cédric Jeanneret cedric.jeanneret@camptocamp.com

Raphaël Pinson raphael.pinson@camptocamp.com

Garrett Honeycutt code@garretthoneycutt.com

More Contributors