Giter VIP home page Giter VIP logo

lvm's Introduction

lvm Cookbook

Build Status

Installs lvm2 package and includes resources for managing LVM. The default recipe simply installs LVM and the supporting Ruby gem. The cookbook includes providers for managing LVMs.

Requirements

  • Chef 10 or higher

Resources/Providers

lvm_physical_volume

Manages LVM physical volumes.

Actions
Action Description
:create (default) Creates a new physical volume
:resize Resize an existing physical volume
Parameters
Parameter Description Example Default
name (required) The device to create the new physical volume on '/dev/sda'
Examples
lvm_physical_volume '/dev/sda'

lvm_logical_volume

Manages LVM logical volumes.

Actions
Action Description
:create (default) Creates a new logical volume
:resize Resize an existing logical volume
Parameters
Attribute Description Example Default
name (name attribute) Name of the logical volume bacon
group (required) Volume group in which to create the new volume (not required if the volume is declared inside of an `lvm_volume_group` block) bits
size (required) Size of the volume.
  • It can be the size of the volume with units (k, K, m, M, g, G, t, T)
  • It can be specified as the percentage of the size of the volume group
  • 10G
  • 25%VG
filesystem The format for the file system 'ext4'
mount_point Either a String containing the path to the mount point, or a Hash with the following keys:
  • location - (required) the directory to mount the volume on
  • options - the mount options for the volume
  • dump - the dump field for the fstab entry
  • pass - the pass field for the fstab entry
'/var/my/mount'
physical_volumes Array of physical volumes that the volume will be restricted to ['/dev/sda', '/dev/sdb']
stripes Number of stripes for the volume 5
stripe_size Number of kilobytes per stripe segment (must be a power of 2 less than or equal to the physical extent size for the volume group) 24
mirrors Number of mirrors for the volume 5
contiguous Whether or not volume should use the contiguous allocation policy true false
readahead The readahead sector count for the volume (can be a value between 2 and 120, 'auto', or 'none') 'auto'
take_up_free_space whether to have the LV take up the remainder of free space on the VG. Only valid for resize action true false
Examples
lvm_logical_volume 'home' do
  group       'vg00'
  size        '25%VG'
  filesystem  'ext4'
  mount_point '/home'
  stripes     3
  mirrors     2
end

lvm_volume_group

Manages LVM volume groups.

Actions
Action Description
:create (default) Creates a new volume group
:extend Extend an existing volume group to include new physical volumes
Parameters
Attribute Description Example Default
name (required) Name of the volume group 'bacon'
physical_volumes (required) The device or list of devices to use as physical volumes (if they haven't already been initialized as physical volumes, they will be initialized automatically) ['/dev/sda', '/dev/sdb']
physical_extent_size The physical extent size for the volume group
logical_volume Shortcut for creating a new `lvm_logical_volume` definition (the logical volumes will be created in the order they are declared)
Examples
lvm_volume_group 'vg00' do
  physical_volumes ['/dev/sda', '/dev/sdb', '/dev/sdc']

  logical_volume 'logs' do
    size        '1G'
    filesystem  'xfs'
    mount_point location: '/var/log', options: 'noatime,nodiratime'
    stripes     3
  end

  logical_volume 'home' do
    size        '25%VG'
    filesystem  'ext4'
    mount_point '/home'
    stripes     3
    mirrors     2
  end
end

Usage

If you're using Berkshelf, just add this cookbook to your Berksfile:

cookbook 'lvm'

You can also install it from the community site:

knife cookbook site install lvm

Include the default recipe in your run list on a node, in a role, or in another recipe:

run_list(
  'recipe[lvm::default]'
)

Depend on lvm in any cookbook that uses its Resources/Providers:

# other_cookbook/metadata.rb
depends 'lvm'

Caveats

This cookbook depends on the di-ruby-lvm and di-ruby-lvm-attrib gems. The di-ruby-lvm-attrib gem in particular is a common cause of failures when using the providers. If you get a failure with an error message similar to

No such file or directory - /opt/chef/.../di-ruby-lvm-attrib-0.0.3/lib/lvm/attributes/2.02.86(2)/lvs.yaml

then you are running a version of lvm that the gems do not support. However, getting support added is usually pretty easy. Just follow the instructions on "Adding Attributes" in the di-ruby-lvm-attrib README.

Development

This section details "quick development" steps. For a detailed explanation, see [[Contributing.md]].

  1. Clone this repository from GitHub:

     $ git clone [email protected]:opscode-cookbooks/lvm.git
    
  2. Create a git branch

     $ git checkout -b my_bug_fix
    
  3. Install dependencies:

     $ bundle install
    
  4. Make your changes/patches/fixes, committing appropiately

  5. Write tests

  6. Run the tests:

    • bundle exec foodcritic -f any .
    • bundle exec rspec
    • bundle exec rubocop
    • bundle exec kitchen test

In detail: - Foodcritic will catch any Chef-specific style errors - RSpec will run the unit tests - Rubocop will check for Ruby-specific style errors - Test Kitchen will run and converge the recipes

License and Authors

Copyright:: 2011, Opscode, Inc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

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.