Code Monkey home page Code Monkey logo

puppetlabs-lvm's Introduction

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 [email protected]

Daniel Kerwin [email protected]

Luke Kanies [email protected]

Matthaus Litteken [email protected]

Michael Stahnke [email protected]

Mikael Fridh [email protected]

Tim Hawes [email protected]

Yury V. Zaytsev [email protected]

csschwe [email protected]

windowsrefund [email protected]

Adam Gibbins [email protected]

Steffen Zieger [email protected]

Jason A. Smith [email protected]

Mathieu Bornoz [email protected]

Cédric Jeanneret [email protected]

Raphaël Pinson [email protected]

Garrett Honeycutt [email protected]

More Contributors

puppetlabs-lvm's People

Contributors

adrienthebo avatar bastelfreak avatar binford2k avatar bmjen avatar bmlit avatar chelnak avatar crayfishx avatar csschwe avatar cyberious avatar david22swan avatar davids avatar eputnam avatar frimik avatar genebean avatar ghoneycutt avatar haus avatar hunner avatar iankronquist avatar jordanbreen28 avatar kenyon avatar malikparvez avatar mcanevet avatar petems avatar phongdly avatar pmcmaw avatar ramesh7 avatar raphink avatar rtib avatar smithj4 avatar tphoney avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

puppetlabs-lvm's Issues

execute lvresize, if size of an lv changes

Use Case

if the size of the block device behind a PV is changed, the blk device size change is notices correctly by the os, but the pv will not notice the size change until something calls pvresize $PATH_TO_BLK_DEVICE.

this prevents lvresize from working.

Describe the Solution You Would Like

if the puppet module notices that the size of a lv needs to be changed, it should call pvresize on all physical volumes that are part of the volumegroup that is hosting the logical volume. with this the the puppet module can change the lv size without the need for human interaction.

Typo for ensure

Hi,

We've started using the latest version (2.0.1) and we are getting the following error.

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Lvm::Volume[reports]:
  parameter 'ensure' expects a match for Enum['absent', 'cleaned', 'presnet'], got 'present'
  parameter 'vg' expects a Stdlib::Absolutepath = Variant[Stdlib::Windowspath = Pattern[/\A(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+)).*\z/], Stdlib::Unixpath = Pattern[/\A\/([^\n\/\0]+\/*)*\z/]] value, got String (file: /etc/puppetlabs/code/environments/linux_puppet8/external/shared/modules/linux/manifests/init.pp

It looks like there is a typo of "presnet" instead of "present".

Please say if you require any more info.

Thanks
Ian

Catalog compilation fails with: no parameter named 'yes_flag'

Describe the Bug

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: no parameter named 'yes_flag' (file: /etc/puppetlabs/code/environments/SVCPLAN_3734_jsm_setup/modules/lvm/manifests/logical_volume.pp, line: 126) on Logical_volume[backups]

Expected Behavior

Puppet should compile the catalog and create the LV.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Heira data:
lvm::volume_groups:
  vg_backups:
    createonly: true
    physical_volumes:
      /dev/sdc:
        unless_vg: "vg_backups"
    logical_volumes:
      backups:
        fs_type: "xfs"
        mountpath: "/backups"
  1. Puppet module:
include ::lvm
  1. Run puppet

Environment

  • Version 2.0.3
  • Platform Red Hat Enterprise Linux 9.2 (Plow)
  • Puppet version 7.26.0

Additional Context

This is possible only after fixing #315, which I think I have a fix for (https://github.com/ncsa/puppet-lvm/tree/aloftus/fix_pvcreate), but now running into this issue.

Facts lvm_vg_* unavailable

Describe the Bug

Facts lvm_vg_* and lvm_vg_*_pvs aren't resolved since v2.0.0 release.

Expected Behavior

As those facts where not declared deprecated neither removed from the code, they are expected to be available.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Run sudo puppet facts | grep lvm_vg on a node having LVM volume groups configured with module version 2.0.x and earlier.

Environment

  • Puppet agent version 7.24.0 (others may also affected)
  • Platform Debian 11 (other may also affected)

Additional Context

With commit 8e1e8eb the setcode blocks of the affected facts here have been moved into the setcode block above. I assume, such an encapsulation of setcode blocks is not supported with Facter.

v2.0.3 is broken

Describe the Bug

Updating to v2.0.3 causes failures:

2023-07-11 13:55:15 +0000 Facter (err): error while resolving custom facts in /opt/puppetlabs/puppet/cache/lib/facter/lvm_support.rb undefined method `message' for #<String:0x00000000047ec120>

Agent is RHEL8, lvm is not installed

Custom facts causing errors on Windows and AWS RHEL7 servers

Describe the Bug

Two kinds of errors appear during puppet execution. In both cases LVM module is not referenced in the manifest for the server where the error occurs.

On Windows:

Unable to add resolve nil for fact lvm_vgs: Could not execute 'vgs -o name --noheadings 2>/dev/null': command not found
Unable to add resolve nil for fact lvm_pvs: Could not execute 'pvs -o name --noheadings 2>/dev/null': command not found

On Linux:
Error: Facter: error while resolving custom facts in /var/rnd_puppet_agent/lib/facter/lvm_support.rb undefined method message for #<String:0x0000000003d0eeb0>

Expected Behavior

No error message.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Direct download of LVM module via https://forge.puppet.com/modules/puppetlabs/lvm/readme
  2. Upload the module via IntelliJ IDEA, commit and push to master branch
  3. Run puppet

Environment

  • Windows Server 2019
  • Red Hat Enterprise Linux Server 7.9
  • LVM 2.0.3

Additional Context

No errors for VMs with OS Oracle Linux Server 7.9 and Oracle Linux Server 8.

Update for stdlib 9.x.x

Use Case

With stdlib 9 out, this module should be compatible with that library.

Describe the Solution You Would Like

Test with stdlib 9 and find a way to ensure compatibility for 8.x and 9.x

Describe Alternatives You've Considered

Dropping this module

Additional Context

Add any other context or screenshots about the feature request here.

Aix filesystem don't configure nodename parametre for nfs

Describe the Bug

In documentation for AIX we have nodename parametre, but this one is not save in filesystem file.

Steps to Reproduce

puppet exemple for AIX 7.1 and AIX 7.2

filesystem{'/exploit/test':
ensure => 'present',
mount_options => 'ro,bg,hard,intr,retry=5,rsize=65536,wsize=65536,vers=3,proto=tcp,nosuid',
nodename => 'my_nas.test.local',
device => '/exploit',
fs_type => 'nfs',
atboot => true,
perms => 'ro',
}

in /etc/filesystem we have:

/exploit/test:                                                                                                                                                                                                                                    
  dev          = /exploit
   vfs          = nfs
   mount    = true
   options   = ro,bg,hard,intr,retry=5,rsize=65536,wsize=65536,vers=3,proto=tcp,nosuid                                                                                                                                                
   account   = false

and not this:

/exploit/test:                                                                                                                                                                                                                                    
  dev          = /exploit
   vfs          = nfs
   mount    = true
   options   = ro,bg,hard,intr,retry=5,rsize=65536,wsize=65536,vers=3,proto=tcp,nosuid                                                                                                                                                
   account   = false
  nodename = my_nas.test.local

Environment

  • AIX 7.1
  • AIX 7.2

Additional Context

I have add ligne 36 in lib/puppet/provider/filesystem/aix.rb the parametre nodename and it's ok:

  def create
    args = []

    attributes = [
      :ag_size,
      :large_files,
      :compress,
      :frag,
      :nbpi,
      :logname,
      :size,
      :initial_size,
      :encrypted,
      :isnapshot,
      :logsize,
      :maxext,
      :mountguard,
      :agblksize,
      :extended_attributes,
      :mount_options,
      :vix,
      :nodename,
    ]

Best regards,
Nicolas Lurvois

VG as absolute path

Hi,

While submitting the other bug report I noticed that the data type for vg in lvm::volume is now Stdlib::Absolutepath. As far as I'm aware a volume group is just a string not a path? Below is an example of what we currently set for a test server and it will error out on vg.

Evaluation Error: Error while evaluating a Resource Statement, Lvm::Volume[reports]: parameter 'vg' expects a Stdlib::Absolutepath = Variant[Stdlib::Windowspath = Pattern[/\A(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+)).*\z/], Stdlib::Unixpath = Pattern[/\A\/([^\n\/\0]+\/*)*\z/]] value, got String

lvm::volume:
    reports:
        ensure: present
        vg: 'vg_reports'
        pv: '/dev/sdb'
        fstype: 'xfs'
        size: '200G'

The example in Puppet Forge (below) also shows it as a string.

lvm::volume { 'lv_example0': vg => 'vg_example0', pv => '/dev/sdd1', fstype => 'ext4', size => '100GB', }

Please say if you require any more info.

Thanks
Ian

volume.pp extents resource type unknown

Describe the Bug

A clear and concise description of what the bug is.

resource type for extents in parameter list for volume class is "Optional[Variant[String[1], Integert]]"
This causes an error:
Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Resource type not found: Integert (file: /etc/puppetlabs/code/environments/production/modules/lvm/manifests/volume.pp, line: 70, column: 31) on node ...

Source: Puppet

Expected Behavior

puppet agent runs not to fail catalog compilation

Steps to Reproduce

Steps to reproduce the behavior:

  1. Add an LVM definition to your node catalog, with a volume
  2. Try to compile a catalog

Environment

  • Version: 6.14.0
  • Platform: Centos 7

Additional Context

This looks like a typo, so I am surprised that the puppet parser passes this.
Interestingly, the parser does error out on the expand plan, but this looks OK to me ¯_(ツ)_/¯
Error: Could not parse for environment production: Syntax error at 'server' (file: /etc/puppetlabs/code/environments/production/modules/lvm/plans/expand.pp, line: 16, column: 17)

Wiping of signatures

Describe the Bug

A clear and concise description of what the bug is.
Currently the lvm2 is updated, as a result, lvcreate command required manual confirmation of signature wiping. But we dont have support to provide --yes option, during logical volume creation, as we dont have handle to provide options for lvcreate.

Expected Behavior

Either provide a options, for --yes, or make yes option as default for prompting.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Create a logical volume for first time.
  2. Remove/Delete the volume
  3. Try to create logical volume again and mount it, will throw error.

Environment

lvm2-2.03.14-3.el8.x86_64.rpm
in rocky linux 8.6

Additional Context

vgcreate fails if physical_volumes is a hash

Describe the Bug

If the PV and VG don't exist yet and physical_volumes is a hash, throws this error:

Error: Execution of '/usr/sbin/vgcreate vg_backups {"/dev/sdc"=>{"unless_vg"=>"vg_backups"}}' returned 5: No device found for {"/dev/sdc"=>{"unless_vg"=>"vg_backups"}}.

Expected Behavior

Expect PV and VG creation to succeed.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Hiera data:
lvm::volume_groups:
  vg_backups:
    createonly: true
    physical_volumes:
      /dev/sdc:
        unless_vg: "vg_backups"
    logical_volumes:
      backups:
        fs_type: "xfs"
        mountpath: "/backups"
  1. Puppet module:
include ::lvm
  1. Run puppet

Environment

  • Version 2.0.3
  • Platform Red Hat Enterprise Linux 9.2 (Plow)
  • Puppet version 7.26.0

Additional Context

Add any other context about the problem here.

poolmetadatasize parameter appears to have invalid type set

Describe the Bug

I believe the poolmetadatasize parameter should be allowed to be a string such as '10M'
If it must be an integer and not a string, the rspec test should be updated.
Our own rspec tests fail if we set the poolmetadatasize, with
'parameter 'poolmetadatasize' expects a value of type Undef or Integer, got String'

Expected Behavior

Parameter documentation, rspec tests and parameter types are consistent.

Steps to Reproduce

poolmetadatasize parameter is set to be an integer:
https://github.com/puppetlabs/puppetlabs-lvm/blob/v2.1.0/manifests/logical_volume.pp#L77

but in rspec test, a poolmetadatasize of '10M' is used:
https://github.com/puppetlabs/puppetlabs-lvm/blob/v2.1.0/spec/unit/puppet/type/logical_volume_spec.rb#L18

Environment

  • Version 2.1.0
  • Platform RHEL 8

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.