Giter Site home page Giter Site logo

sous-chefs / lvm Goto Github PK

View Code? Open in Web Editor NEW
56.0 55.0 121.0 596 KB

Development repository for the lvm cookbook

Home Page: https://supermarket.chef.io/cookbooks/lvm

License: Apache License 2.0

Ruby 100.00%
chef hacktoberfest chef-cookbook lvm chef-resource managed-by-terraform

lvm's Introduction

lvm Cookbook

Cookbook Version CI State OpenCollective OpenCollective License

Installs lvm2 package and includes resources for managing LVM.

Note on LVM gems

This cookbook has used multiple variants of the ruby-lvm and ruby-lvm-attrib gems for interacting with LVM. Most recently we used di-ruby-lvm and di-ruby-lvm-attrib gems, which are no longer being maintained. As of the 4.0 release this cookbook uses new Chef maintained gems: chef-ruby-lvm and chef-ruby-lvm-attrib. Previous versions of this cookbook supported cleaning those gems up for approximetly 3 years. At this point you'll need to remove those gems yourself if they're still present as the namespaces will conflict. If you previously used attributes to control the version of the gems to install, you will need to update to the latest attribute names to maintain that functionality.

Maintainers

This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If you’d like to know more please visit sous-chefs.org or come chat with us on the Chef Community Slack in #sous-chefs.

Requirements

Platforms

  • Debian/Ubuntu
  • RHEL/CentOS/Scientific/Amazon/Oracle
  • SLES

Chef

  • Chef 12.15+

Cookbooks

  • none

Resources

The following resources are provided:

Usage

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 chef-ruby-lvm and chef-ruby-lvm-attrib gems. The chef-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/.../chef-ruby-lvm-attrib-0.0.3/lib/lvm/attributes/2.02.300(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 chef-ruby-lvm-attrib README.

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers!

https://opencollective.com/sous-chefs#backers

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

https://opencollective.com/sous-chefs/sponsor/0/website https://opencollective.com/sous-chefs/sponsor/1/website https://opencollective.com/sous-chefs/sponsor/2/website https://opencollective.com/sous-chefs/sponsor/3/website https://opencollective.com/sous-chefs/sponsor/4/website https://opencollective.com/sous-chefs/sponsor/5/website https://opencollective.com/sous-chefs/sponsor/6/website https://opencollective.com/sous-chefs/sponsor/7/website https://opencollective.com/sous-chefs/sponsor/8/website https://opencollective.com/sous-chefs/sponsor/9/website

lvm's People

Contributors

arangamani avatar bbaugher avatar damacus avatar eheydrick avatar gaelik avatar gregsymons avatar hulu1522 avatar iennae avatar jflemer-ndp avatar juliandunn avatar kitchen-porter avatar markgibbons avatar miscreantt avatar mlomnicki avatar mmatten avatar nathenharvey avatar ramereth avatar renovate[bot] avatar roeefabrikant avatar ryanwoodsmall avatar sethvargo avatar shortdudey123 avatar spion06 avatar stromweld avatar tas50 avatar tek avatar w0rldart avatar wheatevo avatar xorimabot avatar yeoldegrove 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

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

lvm's Issues

Various Issue with Group Extend and Volume Resize

There is a better description in the PR #35.

The two main issues that are happening include:

  • lvm_volume_group extend action didn't notify volumes to resize.
  • lvm_logical_volume resize action had a command issue where the path did not exist.

Amazon Linux 2015.09

When the 'lvm vgcreate' command is executed on Amazon Linux 2015.09 it waits for the user to confirm the action. This causes a chef run to never complete. I think all of the lvm commands should include "--yes" as to not prompt the user.

logical_volume provider hangs during resize action

I am having consistent performance issues with the resize action taking a long time, even when there is no resize to do. I don't know how to begin profiling the cookbook or finding the performance problem. I'm plenty willing to dive in there, just hoping someone can point me at somewhere to start, or share if they've had a similar problem.

I'm running on RHEL 6.6.

lvm_volume_group hangs forever reading [y/n] if signature detected on disk

Testing lvm on RHEL7, it has become pickier:

[root@ip-rh-backend1 ~]# vgcreate opscode  /dev/xvdb
WARNING: ext3 signature detected on /dev/xvdb at offset 1080. Wipe it? [y/n]

Unfortunately in chef-client runs this seems to just hang indefinitely waiting on the input. I hadn't experienced this previously in RHEL5 or 6, nor Ubuntu 12.04 or 14.04.

Some possible solutions:

  1. Add a "force" method which appends -y to vgcreate
  2. Attempt to detect a signature the same way lvm does, and bomb proactively
  3. the di-ruby-lvm gem uses passes raw along to Open4 without a timeout. Maybe use shell_out directly instead of lvm.raw?

Kitchen Verify does not run bats tests

I was going to try to fix an issue with notification, but wanted to first extend that tests to show that it does not work. But, after doing so, I see that kitchen verify does not run the tests. I made a change to .kitchen.yml to add a suite that runs the fake::create and run the tests under test/integration/create, some of which need to be associated with resize. I've not used bats before so I may be lost, but this look pretty broken to me. I think I could help bring the tests up to date and get them running in kitchen again, but I don't want to dive in as I feel like I might be missing something.

Can someone educate me as to what I am missing? Shall I try to chip in on this front? Perhaps, the tests were removed from .kitchen.yml on purpose for some reason?

problems with lvm cookbook when running under chefspec

Hi

I seem to have a problem running lvm cookbook under chefspec so the problem might not be directly related to lvm itself.
When I'm loading a recipe containing lvm resource "lvm_logical_volume" into chefspec I'm getting the following error:

================================================================================
Recipe Compile Error in /tmp/d20151104-32398-1ht9l5d/cookbooks/hc_lvm/recipes/update_ext_var.rb
================================================================================

TypeError
---------
no implicit conversion of Symbol into Integer

Cookbook Trace:
---------------
  /tmp/d20151104-32398-1ht9l5d/cookbooks/lvm/libraries/resource_lvm_logical_volume.rb:158:in `[]'
  /tmp/d20151104-32398-1ht9l5d/cookbooks/lvm/libraries/resource_lvm_logical_volume.rb:158:in `block in mount_point'
  /tmp/d20151104-32398-1ht9l5d/cookbooks/lvm/libraries/resource_lvm_logical_volume.rb:147:in `mount_point'
  /tmp/d20151104-32398-1ht9l5d/cookbooks/hc_lvm/recipes/update_ext_var.rb:82:in `block in from_file'
  /tmp/d20151104-32398-1ht9l5d/cookbooks/hc_lvm/recipes/update_ext_var.rb:78:in `from_file'

Relevant File Content:
----------------------
/tmp/d20151104-32398-1ht9l5d/cookbooks/lvm/libraries/resource_lvm_logical_volume.rb:

151:            :callbacks => {
152:              ': location is required!' => proc do |value|
153:                value.class == String || (value[:location] && !value[:location].empty?)
154:              end,
155:              ': location must be an absolute path!' => proc do |value|
156:                # this can be a string or a hash, so attempt to match either for
157:                # the regex
158>>               matches = value =~ %r{^/[^\0]*} || value[:location] =~ %r{^/[^\0]*}
159:                !matches.nil?
160:              end
161:            }
162:          )
163:        end
164:
165:        # Attribute: physical_volumes - list of physical volumes to be used for creation
166:        #
167:        # @param arg [String, Array] - list of physical devices

F

Failures:

  1) hc_lvm::update_ext_var runs ruby block populate_partition_var
     Failure/Error: end.converge(described_recipe) }
     TypeError:
       no implicit conversion of Symbol into Integer

I'm not even defining any tests yet for this resource - just loaded the recipe using 'describe' block.

Here is my problematic recipe (update_ext_var.rb):

  ruby_block 'populate_partition_var' do
      block do
        Chef::Log.info("for partition... #{node['test_lvm']['var_vol_name']}")
        # tricky way to load this Chef::Mixin::ShellOut utilities
        Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut)
        # Get Device path from mount point
        dpath_cmd = "df -Ph #{node['test_lvm']['var_vol_name']}|tail -1| cut -f 1 -d ' '"
        dpath = shell_out(dpath_cmd).stdout

        # Check if the device path is exist, then proceed further.
        unless dpath.nil?
          dpath = dpath.strip
          lvmpath_cmd = "lvdisplay -c #{dpath} | cut -d ':' -f 1"
          lvmpath = shell_out(lvmpath_cmd).stdout
          lvmgrp = ''
          lvname = ''
          unless lvmpath.nil?
            lvmpath = lvmpath.strip
            # Get volume group of the device path
            lvmgrp_cmd = "lvdisplay -c #{dpath}|cut -d ':' -f 2"
            lvmgrp = shell_out(lvmgrp_cmd).stdout

            # Get LV Name
            lvname_cmd = "lvs  --noheadings -o lv_name #{lvmpath}"
            lvname = shell_out(lvname_cmd).stdout
          end
          # Get FS Name
          lvfs_cmd = "df -T #{node['test_lvm']['var_vol_name']} | awk '{print $1}' | tail -n1"
          lvfs = shell_out(lvfs_cmd).stdout

          node.default['test_lvm']['var_dev_path'] = dpath
          node.default['test_lvm']['var_lvm_path'] = lvmpath
          node.default['test_lvm']['var_grp'] = lvmgrp.strip
          node.default['test_lvm']['var_logical_volume'] = lvname.strip
          node.default['test_lvm']['var_fs'] = lvfs.strip
        end
      end
      action :create
      only_if "mountpoint -q #{node['test_lvm']['var_vol_name']}"
  end.run_action(:create)

  ruby_block 'var_partitions_info' do
    block do
      Chef::Log.info("lvm_grp=#{node.default['test_lvm']['var_grp']}")
      Chef::Log.info("logical_volume=#{node.default['test_lvm']['var_logical_volume']}")
      Chef::Log.info("lvm_path=#{node.default['test_lvm']['var_lvm_path']}")
      Chef::Log.info("device_path=#{node.default['test_lvm']['var_dev_path']}")
      Chef::Log.info("fs=#{node.default['test_lvm']['var_fs']}")
      Chef::Log.info("options=#{node.default['test_lvm']['var_options']}")
      Chef::Log.info("dump=#{node.default['test_lvm']['var_dump']}")
      Chef::Log.info("pass=#{node.default['test_lvm']['var_pass']}")
    end
    action :run
  end

  # remount /var
  execute 'remount_var' do
    command "mount -o remount #{node['test_lvm']['var_vol_name']}"
    action :nothing
  end

  # Take off noexec from /var amd /tmp and remount
  Chef::Log.info('Take off noexec from /var and remount.')
  mount node['test_lvm']['var_vol_name'] do
    device node['test_lvm']['var_dev_path']
    fstype node['test_lvm']['var_fs']
    options node['test_lvm']['var_options']
    dump node['test_lvm']['var_dump'].to_i
    pass node['test_lvm']['var_pass'].to_i
    notifies :run, 'execute[remount_var]', :immediately
    action [:mount, :enable]
    only_if "mount|grep #{node['test_lvm']['var_dev_path']}|grep noexec"
  end

  if ENV['APP_DB'] != '1'
    Chef::Log.info('Assigning remaining disk space to  /var ....')

    lvm_logical_volume node['test_lvm']['var_logical_volume'] do
      group node['test_lvm']['var_grp']
      take_up_free_space true
      filesystem node['test_lvm']['var_fs']
      mount_point node['test_lvm']['var_vol_name']
      size '25%VG'
      action :resize
      only_if "mountpoint -q #{node['test_lvm']['var_vol_name']}"
    end
  end

Here is my chefspec test:

require 'spec_helper'

describe 'test_lvm::update_ext_var' do
  ENV['APP_DB'] = '1'
  let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'oracle', version: '6.5') do |node|
    node.set['test_lvm']['var_vol_name'] = 'var_vol_name'
    node.set['test_lvm']['var_logical_volume'] = 'var_logical_volume'
  end.converge(described_recipe) }

  before do
    stub_command("mountpoint -q var_vol_name").and_return(true)
    allow(chef_run).to receive(lvm_logical_volume).and_return(true)
  end

  it 'runs ruby block populate_partition_var' do
    expect(chef_run).to run_ruby_block('populate_partition_var')
  end
  ENV['APP_DB'] = ''
end

As you can see above I'm not even defined a test for that resource yet so I think the problem is with converging the recipe in memory so most probably this is only visible in chefspec.

LV Fails to create logical volumes with undefined method gsub

Cookbook version

4.0.5

Chef-client version

12.13.7

Platform Details

RHEL 7.2 AWS

Scenario:

Creating a VG Data with a Raw disk size of 10G. Calculating the remaining size of the disk from after 3 filesystems and creating a 4th with the remainder. The issue occurs long before that.

Steps to Reproduce:

The issue occurs during the first creation of an LV object.

      node['jmfe_elastic_cluster']['logical_volumes'].each do |key,lv|
        #log "KEY: #{key}:: #{node['jmfe_elastic_cluster']['logical_volumes'][key]['GBsize']}"
        size = node['jmfe_elastic_cluster']['logical_volumes'][key]['GBsize']
        path = node['jmfe_elastic_cluster']['logical_volumes'][key]['path']
        log "Size:#{size}G"
        log "Path:#{path}"

        lvm_logical_volume key do
           size "#{size}G"
           filesystem 'xfs'
           mount_point location: "#{path}, options: 'noatime,nodiratime'"
         end
      end

Expected Result:

4 Filesystems of the proper size to be created.

Actual Result:

       Recipe: jmfe_elastic_cluster::_configureLVM
         * lvm_physical_volume[/dev/xvdb] action create
           * chef_gem[/dev/xvdb_di-ruby-lvm-attrib_removal] action remove (up to date)
           * chef_gem[/dev/xvdb_di-ruby-lvm_removal] action remove (up to date)
            (up to date)
         * chef_gem[/dev/xvdb_di-ruby-lvm-attrib_removal] action remove (up to date)
         * chef_gem[/dev/xvdb_di-ruby-lvm_removal] action remove (up to date)
         * log[Size:1G] action write

         * log[Path:/var/log/elasticsearch] action write

         * lvm_logical_volume[elasticsearchlog] action create

           * chef_gem[elasticsearchlog_di-ruby-lvm-attrib_removal] action remove (up to date)
           * chef_gem[elasticsearchlog_di-ruby-lvm_removal] action remove (up to date)

           ================================================================================
           Error executing action `create` on resource 'lvm_logical_volume[elasticsearchlog]'
           ================================================================================

           NoMethodError
           -------------
           undefined method `gsub' for nil:NilClass

Cookbook Trace:
           ---------------
           /tmp/kitchen/cache/cookbooks/lvm/libraries/provider_lvm_logical_volume.rb:287:in `to_dm_name'
           /tmp/kitchen/cache/cookbooks/lvm/libraries/provider_lvm_logical_volume.rb:56:in `action_create'
           /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:78:in `run_action'
           /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `block (2 levels) in converge'
           /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `each'
           /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `block in converge'
           /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:105:in `converge'

           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/jmfe_elastic_cluster/recipes/_configureLVM.rb

            84:         lvm_logical_volume key do

            85:            size "#{size}G"
            86:            filesystem 'xfs'
            87:            mount_point location: "#{path}, options: 'noatime,nodiratime'"
            88:          end
            89:       end

           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cache/cookbooks/jmfe_elastic_cluster/recipes/_configureLVM.rb:84:in `block (2 levels) in from_file'

           lvm_logical_volume("elasticsearchlog") do
             provider Chef::Provider::LvmLogicalVolume
             action :create
             retries 0
             retry_delay 2
             default_guard_interpreter :default
             declared_type :lvm_logical_volume
             cookbook_name "jmfe_elastic_cluster"
             recipe_name "_configureLVM"
             size "1G"
             filesystem "xfs"
             mount_point {:location=>"/var/log/elasticsearch, options: 'noatime,nodiratime'"}
           end


           Platform:
           ---------
           x86_64-linux


       Running handlers:
       [2017-01-24T09:59:27-05:00] ERROR: Running exception handlers
       Running handlers complete
       [2017-01-24T09:59:27-05:00] ERROR: Exception handlers complete
       Chef Client failed. 2 resources updated in 04 seconds
       [2017-01-24T09:59:27-05:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       [2017-01-24T09:59:27-05:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
       [2017-01-24T09:59:27-05:00] ERROR: lvm_logical_volume[elasticsearchlog] (jmfe_elastic_cluster::_configureLVM line 84) had an error: NoMethodError: undefined method `gsub'
for nil:NilClass
       [2017-01-24T09:59:28-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

compile_time default wrong attribute

I think the compile_time attribute called out in lvm/recipes/default.rb is wrong:

compile_time node['lvm']['di-ruby-lvm']['version']['compile_time'] 

Should probably be:

compile_time node['lvm']['di-ruby-lvm']['compile_time'] 

No resource or method named `platform_family?`

Cookbook version

4.0.2

Chef-client version

12.6

Platform Details

N/A

Issue:

================================================================================
Error executing action `create` on resource 'lvm_logical_volume[volume]'
================================================================================

NoMethodError
-------------
No resource or method named `platform_family?' for `Chef::Provider::LvmLogicalVolume ""'

Cookbook Trace:
---------------
/tmp/kitchen/cache/cookbooks/lvm/libraries/provider_lvm_logical_volume.rb:221:in `install_filesystem_deps'
/tmp/kitchen/cache/cookbooks/lvm/libraries/provider_lvm_logical_volume.rb:47:in `action_create'`

Cloning resource attributes for mount[/mnt/data] from prior resource (CHEF-3694)

Pretty much the same as https://github.com/chef-cookbooks/apt/pull/214/files

- /tmp/kitchen/cache/cookbooks/lvm/libraries/provider_lvm_logical_volume.rb:97:in `action_create'
         Cloning resource attributes for mount[/mnt/data] from prior resource (CHEF-3694)
       Previous mount[/mnt/data]: /tmp/kitchen/cache/cookbooks/lvm/libraries/provider_lvm_logical_volume.rb:110:in `action_create'
       Current  mount[/mnt/data]: /tmp/kitchen/cache/cookbooks/lvm/libraries/provider_lvm_logical_volume.rb:110:in `action_create' at 1 location:
           - /tmp/kitchen/cache/cookbooks/lvm/libraries/provider_lvm_logical_volume.rb:110:in `action_create'

So it should be about https://github.com/chef-cookbooks/lvm/blob/master/libraries/provider_lvm_logical_volume.rb#L110 changed to

mount_resource = mount "cleanup_#{mount_spec[:location]}" do
            location mount_spec[:location]
            options mount_spec[:options]
            dump mount_spec[:dump]
            pass mount_spec[:pass]
            device device_name
            fstype fs_type
            action :nothing
          end

I can provide a PR if someone at least tells me i am going into the right direction

Deprecation CHEF-3694 in 4.0.1

4.0.1 introduced a deprecation notice

Deprecated features used!
  Cloning resource attributes for chef_gem[di-ruby-lvm-attrib] from prior resource (CHEF-3694)
Previous chef_gem[di-ruby-lvm-attrib]: /tmp/kitchen/cache/cookbooks/lvm/libraries/lvm.rb:23:in `require_lvm_gems'
Current  chef_gem[di-ruby-lvm-attrib]: /tmp/kitchen/cache/cookbooks/lvm/libraries/lvm.rb:23:in `require_lvm_gems' at 1 location:
    - /tmp/kitchen/cache/cookbooks/lvm/libraries/lvm.rb:23:in `require_lvm_gems'
  Cloning resource attributes for chef_gem[di-ruby-lvm] from prior resource (CHEF-3694)
Previous chef_gem[di-ruby-lvm]: /tmp/kitchen/cache/cookbooks/lvm/libraries/lvm.rb:28:in `require_lvm_gems'
Current  chef_gem[di-ruby-lvm]: /tmp/kitchen/cache/cookbooks/lvm/libraries/lvm.rb:28:in `require_lvm_gems' at 1 location:
    - /tmp/kitchen/cache/cookbooks/lvm/libraries/lvm.rb:28:in `require_lvm_gems'

Cookbook version

4.0.1

Chef-client version

12.16

Platform Details

Linux

Scenario:

chef-client execution.

undefined method `new_resource' for Chef::Resource::LvmLogicalVolume

Cookbook version

2.1.2 (also versions 1.4.1+)

Chef-client version

12.7.2-1 (also tested with 12.4.1-1 and 12.11.18-1)

Platform Details

CentOS Linux release 7.2.1511 (Core)

Scenario:

I've created a wrapper around the lvm resource in my own cookbook to create a volume group, with a single logical volume and mount it at a given mount point. However, I receive the following error:

       Recipe: my_cookbook::diskmnt
         * my_cookbook_diskmnt[Setup data disk] action create

           ================================================================================
           Error executing action `create` on resource 'my_cookbook_diskmnt[Setup data disk]'
           ================================================================================

           NoMethodError
           -------------
           No resource or method named `new_resource' for `Chef::Resource::LvmLogicalVolume "lv_data"'

           Cookbook Trace:
           ---------------
           /tmp/kitchen/cookbooks/my_cookbook/providers/diskmnt.rb:35:in `block (3 levels) in class_from_file'
           /tmp/kitchen/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_builder.rb:90:in `instance_eval'
           /tmp/kitchen/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_builder.rb:90:in `build'
           /tmp/kitchen/cookbooks/lvm/libraries/resource_lvm_volume_group.rb:110:in `logical_volume'
           /tmp/kitchen/cookbooks/my_cookbook/providers/diskmnt.rb:34:in `block (2 levels) in class_from_file'
           /tmp/kitchen/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_builder.rb:90:in `instance_eval'
           /tmp/kitchen/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_builder.rb:90:in `build'
           /tmp/kitchen/cookbooks/my_cookbook/providers/diskmnt.rb:29:in `block in class_from_file'
           /tmp/kitchen/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:41:in `run_action'

If I call the same code I use in the provider in the recipe (i.e. without wrapping it in a provider), it works fine? Something to do with nested resources?

Steps to Reproduce:

Create a resource and provider in a cookbook and call the lvm resource from that, e.g.

my_cookbook/resources/diskmnt.rb

actions :create
default_action :create

attribute :vol_group,       kind_of: String,  required: true
attribute :phys_vol,        kind_of: String,  required: true
attribute :log_vol,         kind_of: String,  required: true
attribute :vol_size,        kind_of: String,  default: '100%VG'
attribute :fs_type,         kind_of: String,  default: 'ext4'
attribute :mount_point,     kind_of: String,  required: true

my_cookbook/provider/diskmnt.rb

action :create do
  # only run if we're set to
  if node['my_cookbook']['diskmnt'] == true
    # install relevant packages and gems
    include_recipe 'lvm::default'

    vol_group = new_resource.vol_group
    phys_vol = new_resource.phys_vol
    log_vol = new_resource.log_vol
    vol_size = new_resource.vol_size
    fs_type = new_resource.fs_type
    mount_point = new_resource.mount_point

    # create volume group
    lvm_volume_group vol_group do
      # create physical volume
      physical_volumes [phys_vol]

      # create logical volume
      logical_volume log_vol do
        size vol_size
        filesystem fs_type
        mount_point mount_point
      end
  end
end

my_cookbook/recipes/diskmnt.rb

my_cookbook_diskmnt 'Setup data disk' do
  vol_group   'vg_data'
  phys_vol    '/dev/sdb'
  log_vol     'lv_data'
  vol_size    '100%VG'
  fs_type     'ext4'
  mount_point '/mnt/data'
end

Expected Result:

The custom resource/provider should pass the arguments through to the lvm provider and create the volume group with the logical volume and mount it at the mount point.

Actual Result:

I get the error No resource or method named 'new_resource' for 'Chef::Resource::LvmLogicalVolume "lv_data"'

mkfs does not work for btrfs

Cookbook version

latest

Chef-client version

latest

Platform Details

debian jessie latest

Scenario:

just using the LVM cookbook to create a lv

Steps to Reproduce:

use a debian jessie, and provision with chef while creating a lv with btrfs as filesystem

Expected Result:

should work

Actual Result:

During the execution it fails with:

Doing it on the shell manually it results int

10.1.7.154     Error executing action `create` on resource 'lvm_logical_volume[data]'
10.1.7.154     ================================================================================
10.1.7.154     
10.1.7.154     Mixlib::ShellOut::ShellCommandFailed
10.1.7.154     ------------------------------------
10.1.7.154     Expected process to exit with [0], but received '1'
10.1.7.154     ---- Begin output of yes | mkfs -t btrfs  /dev/mapper/system-data ----
10.1.7.154     STDOUT: 
10.1.7.154     STDERR: mkfs.btrfs: No such file or directory
10.1.7.154     ---- End output of yes | mkfs -t btrfs  /dev/mapper/system-data ----
10.1.7.154     Ran yes | mkfs -t btrfs  /dev/mapper/system-data returned 1
10.1.7.154     
10.1.7.154     Cookbook Trace:
10.1.7.154     ---------------
10.1.7.154     /var/chef/cache/cookbooks/lvm/libraries/provider_lvm_logical_volume.rb:87:in `action_create'
10.1.7.154     
10.1.7.154     Resource Declaration:
10.1.7.154     ---------------------
10.1.7.154     # In /var/chef/cache/cookbooks/kontextwork-base/recipes/filesystem_lvm_lv_data_extend.rb
10.1.7.154     
10.1.7.154      10:     lvm_logical_volume data_lv_name do
10.1.7.154      11:       group vg_name
10.1.7.154      12:       size '100%FREE'
10.1.7.154      13:       filesystem 'btrfs'
10.1.7.154      14:       mount_point location: data_mount_point, options: 'nodatacow noatime nodiratime'
10.1.7.154      15:       action :create
10.1.7.154      16:     end
10.1.7.154      17:   when 'ext2','ext3', 'ext4'
mkfs -t btrfs  /dev/mapper/system-data
mkfs.btrfs: No such file or directory

but doing

mkfs.btrfs /dev/mapper/system-data

works

lvm commands don't work on RHEL7 until you start the lvm2-lvmetad service

When you install the lvm2 package on RHEL7 and try to run a command, you get weird output like:

[root@ip-172-31-40-236 etc]# vgs
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad: No such file or directory. Falling back to internal scanning.
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  No volume groups found

which causes lvm providers to hang indefinitely. The fix, on RHEL7 platforms, is to start and enable the lvm2-lvmetad service:

# chkconfig lvm2-lvmetad on
# service lvm2-lvmetad start

Version bump requested

Hi there!

I'm using the lvm cookbook for my gluster cookbook, but the current frozen version of the cookbook in the supermarket is missing the latest lvm drivers. These are in master though, could a new version be released please?

Thanks in advance!

Andy

Proper way to unit test logical_volume nested in volume group

I have the following in a recipe:

lvm_volume_group 'jenkinsvg' do
  physical_volumes ['/dev/sdb']

  logical_volume 'jenkinslv' do
    size        '10G'
    filesystem  'ext4'
    mount_point location: '/apps/jenkins'
  end

  logical_volume 'buildlv' do
    size        '150G'
    filesystem  'ext4'
    mount_point location: '/build'
  end
end

And to unit test (rspec / chefspec)

it 'creates volume_group' do
  expect(chef_run).to create_lvm_volume_group('jenkinsvg').with(physical_volumes: ['/dev/sdb'])
end

it 'creates jenkins lv' do
  expect(chef_run).to create_lvm_logical_volume('jenkinslv').with(
    size: '20G',
    filesystem: 'ext4',
    mount_point: '/apps/jenkins'
  )
end

The volume group passes, but the logical volume comes back with this error:

 expected "lvm_logical_volume[jenkinslv]" actions [] to include :create

I then tried re-working the logical_volume as a property of the volume group test. I've tried various ways of formatting it, but I can't find the right one. The response I get is something like:

 expected "lvm_volume_group[jenkinsvg]" to have parameters:

         logical_volumes [{:name=>"jenkinslv", :size=>"20G", :filesystem=>"ext4", :mount_point=>"/apps/jenkins"}],
was [<lvm_logical_volume[jenkinslv] @performed_actions: {} @name: "jenkinslv" @noop: nil @before: nil @params: {} @provider: Chef::Provider::LvmLogicalVolume @allowed_actions: [:nothing, :create, :resize] @action: [:nothing] @updated: false @updated_by_last_action: false @supports: {} @ignore_failure: false @retries: 0 @retry_delay: 2 @source_line: "/home/cruhl/chef-cookbooks/lvm/libraries/resource_lvm_volume_group.rb:110:in `logical_volume'" @guard_interpreter: nil @default_guard_interpreter: :default @elapsed_time: 0 @sensitive: false @resource_name: :lvm_logical_volume @declared_type: :lvm_logical_volume @cookbook_name: :"cars-jenkins" @recipe_name: "master" @size: "20G" @filesystem: "ext4" @mount_point: {:location=>"/apps/jenkins"}>, <lvm_logical_volume[buildlv] @performed_actions: {} @name: "buildlv" @noop: nil @before: nil @params: {} @provider: Chef::Provider::LvmLogicalVolume @allowed_actions: [:nothing, :create, :resize] @action: [:nothing] @updated: false @updated_by_last_action: false @supports: {} @ignore_failure: false @retries: 0 @retry_delay: 2 @source_line: "/home/cruhl/chef-cookbooks/lvm/libraries/resource_lvm_volume_group.rb:110:in `logical_volume'" @guard_interpreter: nil @default_guard_interpreter: :default @elapsed_time: 0 @sensitive: false @resource_name: :lvm_logical_volume @declared_type: :lvm_logical_volume @cookbook_name: :"cars-jenkins" @recipe_name: "master" @size: "80G" @filesystem: "ext4" @mount_point: {:location=>"/build"}>, <lvm_logical_volume[tomcatlv] @performed_actions: {} @name: "tomcatlv" @noop: nil @before: nil @params: {} @provider: Chef::Provider::LvmLogicalVolume @allowed_actions: [:nothing, :create, :resize] @action: [:nothing] @updated: false @updated_by_last_action: false @supports: {} @ignore_failure: false @retries: 0 @retry_delay: 2 @source_line: "/home/cruhl/chef-cookbooks/lvm/libraries/resource_lvm_volume_group.rb:110:in `logical_volume'" @guard_interpreter: nil @default_guard_interpreter: :default @elapsed_time: 0 @sensitive: false @resource_name: :lvm_logical_volume @declared_type: :lvm_logical_volume @cookbook_name: :"cars-jenkins" @recipe_name: "master" @size: "5G" @filesystem: "ext4" @mount_point: {:location=>"/apps/tomcat"}>]

Does anyone know what the correct "rspec/chefspec" format for this test would be? Is there a better way to test this? I tried using Step_into, but that didn't seem to make much difference (besides, I'm not trying to test the LVM lwrp, just that I'm passing it what I'm supposed to be).

Thanks

Error executing action `create` on resource 'lvm_physical_volume['/dev/sdb']'

Cookbook version

2.1

Chef-client version

version 12.8.1

Platform Details

Red Hat Enterprise Linux Server release 6.7 (Santiago)

Scenario:

execute lvm_physical_volume physical_volumes.to_s on subsequent executions of the chef client

Steps to Reproduce:

lvm_physical_volume physical_volumes.to_s

lvm_volume_group group.to_s do
physical_volumes physical_volumes.to_s
end

lvm_logical_volume name.to_s do
group group.to_s
size size.to_s
filesystem filesystem.to_s
mount_point mount_point.to_s
if stripes.to_i > 0
stripes = stripes.to_s
end
end

If I comment out the lvm_physical_volume it completes. So its not detecting that the pvcreate has already been run.

Expected Result:

to see the pvcreate has already been executed and continue execution of cookbook.

Actual Result:

================================================================================
Error executing action `create` on resource 'lvm_physical_volume['/dev/sdb']'
================================================================================

LVM::External::ExternalFailure
------------------------------
Fatal error, `/sbin/lvm pvcreate '/dev/sdb'` returned 5 with 'Can't initialize physical volume "/dev/sdb" of volume group "vg01" without -ff'

cannot use **readahead** option

Hi,

I define an logical_volume as follow.

lvm_volume_group 'VG_01' do
  physical_volumes ['/dev/xvdf']

  logical_volume 'mongodb-data' do
    size        '100%VG'
    filesystem  'ext4'
    mount_point location: "#{node['mongodb']['config']['dbpath']}", options: 'defaults,auto,noatime,noexec'
    readahead 32
  end
end

But when chef run, it says No Method Error for NilClass

   ================================================================================
   Recipe Compile Error in /var/chef/cache/cookbooks/abcd/recipes/lvm_disks.rb
   ================================================================================

   NoMethodError
   -------------
   undefined method `join' for nil:NilClass

   Cookbook Trace:
   ---------------
     /var/chef/cache/cookbooks/lvm/libraries/resource_lvm_logical_volume.rb:237:in `readahead'
     /var/chef/cache/cookbooks/abcd/recipes/lvm_disks.rb:68:in `block (2 levels) in from_file'
     /var/chef/cache/cookbooks/lvm/libraries/resource_lvm_volume_group.rb:110:in `logical_volume'
     /var/chef/cache/cookbooks/abcd/recipes/lvm_disks.rb:64:in `block in from_file'
     /var/chef/cache/cookbooks/abcd/recipes/lvm_disks.rb:61:in `from_file'

   Relevant File Content:
   ----------------------
   /var/chef/cache/cookbooks/lvm/libraries/resource_lvm_logical_volume.rb:

   230:        # Attribute: readahead - the read ahead sector count of the logical volume
   231:        #
   232:        # @param arg [Integer, String] the read ahead sector count
   233:        #
   234:        # @return [Integer, String] the read ahead sector count
   235:        #
   236:        def readahead(arg = nil)
   237>>         set_or_return(
   238:            :readahead,
   239:            arg,
   240:            :kind_of => [Integer, String],
   241:            :equal_to => [2..120, 'auto', 'none'].flatten!
   242:          )
   243:        end
   244:
   245:        # Attribute: take_up_free_space - whether to have the LV take up the remainder of free space on the VG
   246:        #

di-ruby-lvm-attrib version error again

default['lvm']['di-ruby-lvm-attrib']['version'] = '0.0.23' needs to be bumped up to 0.0.25 which is the latest to fix issue with lvm not being able to create volume group due to missing di-ruby-lvm-attrib version of gem.

Error executing action `create` on resource 'lvm_volume_group[name]'

Cookbook version

3.1.0

Chef-client version

Chef: 12.15.19

Platform Details

RedHat AMI on AWS - ami-6f68cf0f

Scenario:using LVM cookbook to convert EBS to mount point volume

Steps to Reproduce:

take an AMI from AWS cloud which I mentioned above and just run the cookbook with required parameters as per README.md file

Expected Result:

expecting volume group to get created

Actual Result:

Unable to load lvm attributes [lvs.yaml] for version [2.02.166(2)]. The version/object may not be supported or you may need to upgrade the di-ruby-lvm-attrib gem. Error [No such file or directory @ rb_sysopen - /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/di-ruby-lvm-attrib-0.0.27/lib/lvm/attributes/2.02.166(2)/lvs.yaml

support for -T (thin pool) option

Is there support for lvm -T option. I am unable to find info:

from man lvcreate:

-T, --thin, --thinpool ThinPoolLogicalVolume{Name|Path} Creates thin pool or thin logical volume or both. Specifying the optional argument --size will cause the creation of the thin pool logical volume. Specifying the optional argument --virtualsize will cause the creation of the thin logical volume from given thin pool volume. Specifying both arguments will cause the creation of both thin pool and thin volume using this pool. Requires device mapper kernel driver for thin provisioning from kernel 3.2 or newer.

undefined method `list' when using volume group providers if the gem isn't loaded

I've tried debugging this a hundred ways, but I can't get lvm 1.4.1 with Chef 12.4 to work at all.... Error follows:

  • lvm_physical_volume[/dev/xvdb1] action create (up to date)
    • lvm_volume_group[/dev/vg1] action create

      Error executing action create on resource 'lvm_volume_group[/dev/vg1]'

      NoMethodError

      undefined method `list' for #LVM::PhysicalVolumes:0x000000073cb818

      Cookbook Trace:

      /var/chef/cache/cookbooks/lvm/libraries/provider_lvm_volume_group.rb:124:in create_volume_group' /var/chef/cache/cookbooks/lvm/libraries/provider_lvm_volume_group.rb:58:inaction_create'

      Resource Declaration:

      In /var/chef/cache/cookbooks/carvemystorage/recipes/mongodb_layout.rb

      43: lvm_volume_group '/dev/vg1' do
      44:
      45: physical_volumes ['/dev/xvdb1']
      46: #only_if { File.exist?('/dev/xvdb1' )}
      47: end
      48:

      Compiled Resource:

      Declared in /var/chef/cache/cookbooks/carvemystorage/recipes/mongodb_layout.rb:43:in `from_file'

      lvm_volume_group("/dev/vg1") do
      provider Chef::Provider::LvmVolumeGroup
      action :create
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      declared_type :lvm_volume_group
      cookbook_name "carvemystorage"
      recipe_name "mongodb_layout"
      physical_volumes ["/dev/xvdb1"]
      end

Running handlers:
[2015-12-04T13:28:06-05:00] ERROR: Running exception handlers
Running handlers complete
[2015-12-04T13:28:06-05:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 9.179841209 seconds
[2015-12-04T13:28:07-05:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2015-12-04T13:28:07-05:00] ERROR: lvm_volume_group[/dev/vg1](carvemystorage::mongodb_layout line 43) had an error: NoMethodError: undefined method `list' for #LVM::PhysicalVolumes:0x000000073cb818
[2015-12-04T13:28:07-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Error creating volumes on Ubuntu 16.04

We need to install the latest version of di-ruby-lvm-attrib

Cookbook version

3.0.0

Chef-client version

12.15.19

Platform Details

Ubuntu 16.04

Scenario:

Create volumes

Steps to Reproduce:

Run test-kitchen tests

Expected Result:

Not bomb out creating volumes

Actual Result:

 Recipe: test::create_thin
         * log[Creating physical volume for test] action write

         * lvm_physical_volume[/dev/loop0] action create
           * chef_gem[di-ruby-lvm-attrib] action install
             - install version 0.0.26 of package di-ruby-lvm-attrib
           * chef_gem[di-ruby-lvm] action install
             - install version 0.2.1 of package di-ruby-lvm

           ================================================================================
           Error executing action `create` on resource 'lvm_physical_volume[/dev/loop0]'
           ================================================================================

           ArgumentError
           -------------
           Unable to load lvm attributes [lvs.yaml] for version [2.02.133(2)]. The version/object may not be supported or you may need to upgrade the di-ruby-lvm-attrib gem. Error [No such file or directory @ rb_sysopen - /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/di-ruby-lvm-attrib-0.0.26/lib/lvm/attributes/2.02.133(2)/lvs.yaml]

           Cookbook Trace:
           ---------------
           /tmp/kitchen/cache/cookbooks/lvm/libraries/provider_lvm_physical_volume.rb:47:in `new'
           /tmp/kitchen/cache/cookbooks/lvm/libraries/provider_lvm_physical_volume.rb:47:in `action_create'

           Resource Declaration:
           ---------------------


#
           # In /tmp/kitchen/cache/cookbooks/test/recipes/create_thin.rb

            35:   lvm_physical_volume device
            36: end

           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cache/cookbooks/test/recipes/create_thin.rb:35:in `block in from_file'

           lvm_physical_volume("/dev/loop0") do
             provider Chef::Provider::LvmPhysicalVolume
             action :create
             retries 0
             retry_delay 2
             default_guard_interpreter :default
             declared_type :lvm_physical_volume
             cookbook_name "test"
             recipe_name "create_thin"
           end

           Platform:
           ---------
           x86_64-linux

lvcreate hangs due to lvm lock.

Cookbook version

4.0.4

Chef-client version

12.17.44

Platform Details

RHEL 7.2

Scenario:

Create VG and associate LVs

Steps to Reproduce:

basic cookbook and it fails every time.

Expected Result:

create VG and associated LV, mounts etc.

Actual Result:

chef-client -r dcos

Starting Chef Client, version 12.17.44
resolving cookbooks for run list: ["dcos"]
Synchronizing Cookbooks:

  • lvm (4.0.4)
  • dcos (0.1.0)
    Installing Cookbook Gems:
    Compiling Cookbooks...
    Converging 7 resources
    Recipe: dcos::default
  • lvm_logical_volume[lv_docker] action nothing (skipped due to action :nothing)
  • lvm_logical_volume[lv_docker_repos] action nothing (skipped due to action :nothing)
  • lvm_logical_volume[lv_docker_volumes] action nothing (skipped due to action :nothing)
  • lvm_logical_volume[lv_mesosphere] action nothing (skipped due to action :nothing)
  • lvm_logical_volume[lv_mesos] action nothing (skipped due to action :nothing)
  • lvm_logical_volume[lv_dcos] action nothing (skipped due to action :nothing)
  • lvm_volume_group[vg_docker] action create
    • chef_gem[vg_docker_di-ruby-lvm-attrib_removal] action remove (up to date)
    • chef_gem[vg_docker_di-ruby-lvm_removal] action remove (up to date)
    • lvm_logical_volume[lv_docker] action create
      • chef_gem[lv_docker_di-ruby-lvm-attrib_removal] action remove (up to date)
      • chef_gem[lv_docker_di-ruby-lvm_removal] action remove (up to date)

*** Hangs here ***

Cookbook ...

# cat default.rb
#
# Cookbook Name:: dcos
# Recipe:: default
#
# Copyright (c) 2017 The Authors, All Rights Reserved.

lvm_volume_group 'vg_docker' do
physical_volumes ['/dev/sda']
wipe_signatures true

logical_volume 'lv_docker' do
action :create
size '9G'
filesystem 'xfs'
end

logical_volume 'lv_docker_repos' do
action :create
size '15M'
filesystem 'xfs'
end

logical_volume 'lv_docker_volumes' do
action :create
size '4G'
filesystem 'xfs'
end

logical_volume 'lv_mesosphere' do
action :create
size '9G'
filesystem 'xfs'
end

logical_volume 'lv_mesos' do
action :create
size '40G'
filesystem 'xfs'
end

logical_volume 'lv_dcos' do
action :create
size '4G'
filesystem 'xfs'
end

end

Newest Version of lvm (lib-lvm2) on CentOS breaks this cookbook

The newest Version of lib-lvm2 does not seem to be compatible with di-ruby-lvm anymore.
17-Oct-2014 20:02
lvm2-2.02.111-2.el6.x86_64.rpm
lvm2-libs-2.02.111-2.el6.x86_64.rpm

di-ruby-lvm / lib / lvm / wrapper / lvsseg.rb on line 40 breaks because args[:size] is a string and not and integer.

40: args[:finish] = args[:start] + args[:size]

args[:size].to_i will fix this !

undefined method `mount'

    ================================================================================
    Error executing action `create` on resource 'lvm_volume_group[storagevg]'
    ================================================================================

    NoMethodError
    -------------
    undefined method `mount' for #<Chef::Provider::LvmVolumeGroup:0x00000007a55378>

    Cookbook Trace:
    ---------------
    /home/ubuntu/chef-solo/cookbooks-3/lvm/libraries/provider_lvm_volume_group.rb:109:in `block in create_mount_resource'
    /home/ubuntu/chef-solo/cookbooks-3/lvm/libraries/provider_lvm_volume_group.rb:103:in `each'
    /home/ubuntu/chef-solo/cookbooks-3/lvm/libraries/provider_lvm_volume_group.rb:103:in `create_mount_resource'
    /home/ubuntu/chef-solo/cookbooks-3/lvm/libraries/provider_lvm_volume_group.rb:48:in `action_create'

    Resource Declaration:
    ---------------------
    # In /home/ubuntu/chef-solo/cookbooks-2/tm-box-elasticsearch-event-logs-master/recipes/attach_raid.rb

     13: lvm_volume_group 'storagevg' do
     14:   physical_volumes node['tm-box-elasticsearch-event-logs-master']['physical_volumes']
     15:   logical_volume 'storagelv' do
     16:     size '100%VG'
     17:     filesystem 'xfs'
     18:     mount_point node['tm-box-elasticsearch-event-logs-master']['storage_dir']
     19:     stripes node['tm-box-elasticsearch-event-logs-master']['physical_volumes'].length
     20:   end
     21: end

    Compiled Resource:
    ------------------
    # Declared in /home/ubuntu/chef-solo/cookbooks-2/tm-box-elasticsearch-event-logs-master/recipes/attach_raid.rb:13:in `from_file'

    lvm_volume_group("storagevg") do
      provider Chef::Provider::LvmVolumeGroup
      action :create
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      logical_volumes [<lvm_logical_volume[storagelv] @name: "storagelv" @noop: nil @before: nil @params: {} @provider: Chef::Provider::LvmLogicalVolume @allowed_actions: [:nothing, :create, :resize] @action: [:nothing] @updated: false @updated_by_last_action: false @supports: {} @ignore_failure: false @retries: 0 @retry_delay: 2 @source_line: "/home/ubuntu/chef-solo/cookbooks-3/lvm/libraries/resource_lvm_volume_group.rb:110:in `logical_volume'" @guard_interpreter: nil @default_guard_interpreter: :default @elapsed_time: 0.000373769 @sensitive: false @resource_name: :lvm_logical_volume @declared_type: :lvm_logical_volume @cookbook_name: :"tm-box-elasticsearch-event-logs-master" @recipe_name: "attach_raid" @size: "100%VG" @filesystem: "xfs" @mount_point: "/vol" @stripes: 2>]
      declared_type :lvm_volume_group
      cookbook_name :"tm-box-elasticsearch-event-logs-master"
      recipe_name "attach_raid"
      physical_volumes ["/dev/xvdb", "/dev/xvdc"]
    end

lvm cookbook failed to run on chef 12 client

On my configuration, there was a big problem with chef 12 client. I started to debug what was wrong... And finally was not able to finish it.

So i started to refactor your code.. To the way that chef explain how we must do our LWRP. Then, tested the code against chef 12 client on my production servers, and everything was back.

So i just push this PR, which only refactor LWRP (change only rubocop offenses in the core code).

Hope this help ( Refactor lwrp #41 )

Extend action on lvm_volume_group fails with a uninitialized constant NameError

Scenario: Base VM image consists of volume group vg0, which contains a logical volume var. The base image does not have sufficient space for my requirements, so I attached a disk to the VM at /dev/vardata0. The following code snippet to extend the VG fails:

volumes = Dir.glob("/dev/vardata*")
lvm_volume_group "vg0" do
    physical_volumes volumes
    action :extend
end

The error is:

[2015-03-19T06:53:09+00:00] INFO: Processing lvm_volume_group[vg0] action extend (my-server::service_linux_config line 6)

================================================================================ 
Error executing action `extend` on resource 'lvm_volume_group[vg0]' 
================================================================================ 


NameError 
--------- 
uninitialized constant Chef::Provider::LvmVolumeGroup::LVM 


Cookbook Trace: 
--------------- 
/var/lib/scratch/repos/ninadsp/servicedev/chef/cookbooks/lvm/libraries/provider_lvm_volume_group.rb:69:in `action_extend' 


Resource Declaration: 
--------------------- 
# In /var/lib/scratch/repos/ninadsp/servicedev/chef/site-cookbooks/my-server/recipes/service_linux_config.rb

  6: lvm_volume_group "vg0" do
  7:     physical_volumes volumes
  8:     action :extend
  9:     notifies :resize, 'lvm_logical_volume[/dev/vg0/var]', :immediately



Compiled Resource: 
------------------ 
# Declared in /var/lib/scratch/repos/ninadsp/servicedev/lsdev/chef/site-cookbooks/my-server/recipes/service_linux_config.rb:6:in `from_file'

lvm_volume_group("vg0") do
  provider Chef::Provider::LvmVolumeGroup
  action [:extend]
  retries 0
  retry_delay 2
  cookbook_name :"my-server"
  recipe_name "service_linux_config"
  physical_volumes ["/dev/vardata0"]
end

Looking at the definition of action_extend, the error is reported at Line 69. Is it because the lvm gem is not imported in this method? Or does the action_create import the gem wrongly, and it should be imported during the initialization of LvmVolumeGroup?

Recipe for SuSE fails in version 2.1.0

Cookbook version

2.1.0

Chef-client version

Chef: 11.18.12

Platform Details

Suse 11.3 (SLES11 SP3) 64bit

Scenario:

Create LVM Volumes/Groups. I have been using this recipe for a few months now without any issues. Everything used to work perfectly until version 2.0.0. For some reason there is an issue in my environment with version 2.1.0

Steps to Reproduce:

Creating an LVM Group:

  include_recipe "lvm"
  volumes =  Dir.glob("/dev/data*")
  lvm_volume_group "vg01r1" do
    physical_volumes volumes
    physical_extent_size "32M"
    logical_volume "backup" do
      size '100%VG'
      filesystem "xfs"
      mount_point :location => "/backup", :options => "noatime,nodiratime"
      stripes volumes.count
      stripe_size 4
    end
  end

Expected Result:

Recipe should run

Actual Result:

Generated at 2016-05-13 16:10:00 +0000
NoMethodError: undefined method `lvm_logical_volume' for Chef::Resource::LvmVolumeGroup
/opt/chef/embedded/apps/chef/lib/chef/resource.rb:300:in `method_missing'
/var/lib/chef/cookbooks/lvm/libraries/resource_lvm_volume_group.rb:110:in `logical_volume'

Failed to connect to lvmetad

Hi there!
I got a error-message at boot.

Here is the log:

Begin: Mounting root file system ... Begin: Running /scripts/local-top ... /run/lvm/lvmetad.socket: connect failed: No such file or directory
WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
Reading all physical volumes. This may take a while...
Found volume group "ubuntu-mate-vg" using metadata type lvm2
/run/lvm/lvmetad.socket: connect failed: No such file or directory
WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
2 logical volume(s) in volume group "ubuntu-mate-vg" now active
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed: Device or resource busy
Device sda5_crypt is still in use.

How to fix it?

LVM Ruby gem is broken as of today

It looks like the di-ruby-lvm was updated from 0.1.3 to 0.2.2 TODAY. This seems to be causing this cookbook to fail with "undefined method `list' for :LVM::PhysicalVolumes" when using the lvm_volume_group resource, like this:

 27:   lvm_volume_group 'vg00' do
 28:     physical_volumes physical_disks
 29:     logical_volume "#{node['slice-bootstrap-node']['instance_store']['name']}" do
 30:       size        "#{node['slice-bootstrap-node']['instance_store']['size']}"
 31:       filesystem  "#{node['slice-bootstrap-node']['instance_store']['fs_type']}"
 32:       mount_point location: "#{node['slice-bootstrap-node']['instance_store']['mount_point']}", options: 'defaults,nofail,nobootwait'
 33:       stripes physical_disks.length
 34:     end
 35:   end
 36:

Could not find a valid gem 'di-ruby-lvm-attrib' (= 0.0.28) in any repository

Cookbook version

cookbook 'lvm', '~> 4.1.0'

Chef-client version

Chef: 12.19.36

Platform Details

Operating System: Red Hat Enterprise Linux Server 7.3 (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.3:GA:server
Kernel: Linux 3.10.0-514.16.1.el7.x86_64
Architecture: x86-64

Scenario:

include_recipe "lvm"
lvm_volume_group name do
physical_volumes volumes
physical_extent_size '32M'
logical_volume "data" do
size "100%VG"
filesystem 'ext3'
mount_point :location => location, :options => 'noatime,nodiratime'
stripes volumes.count
stripe_size 4
end
end

Steps to Reproduce:

include_recipe "lvm"
lvm_volume_group name do
physical_volumes volumes
physical_extent_size '32M'
logical_volume "data" do
size "100%VG"
filesystem 'ext3'
mount_point :location => location, :options => 'noatime,nodiratime'
stripes volumes.count
stripe_size 4
end
end

Expected Result:

[What are you expecting to happen as the consequence of above reproduction steps?]

Actual Result:

[2017-05-03T08:58:55+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2017-05-03T08:58:55+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-05-03T08:58:55+00:00] ERROR: lvm_volume_group[vg01r1] (my-jenkins::lvm_config line 16) had an error: Mixlib::ShellOut::ShellCommandFailed: chef_gem[di-ruby-lvm-attrib] (/var/chef/cache/cookbooks/lvm/libraries/lvm.rb line 28) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '2'
---- Begin output of /opt/chef/embedded/bin/gem install di-ruby-lvm-attrib -q --no-rdoc --no-ri -v "0.0.28" ----
STDOUT:
STDERR: ERROR: Could not find a valid gem 'di-ruby-lvm-attrib' (= 0.0.28) in any repository
ERROR: Possible alternatives: di-ruby-lvm-attrib
---- End output of /opt/chef/embedded/bin/gem install di-ruby-lvm-attrib -q --no-rdoc --no-ri -v "0.0.28" ----
Ran /opt/chef/embedded/bin/gem install di-ruby-lvm-attrib -q --no-rdoc --no-ri -v "0.0.28" returned 2
[2017-05-03T08:58:55+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Need ability to remove

Cookbook version

4.0.5

Chef-client version

12.17.44

Platform Details

Redhat 7 aws ami

Scenario:

Run a resource that runs lvremove

I would think that lvm_logical_volume would have a :remove action in addition to :create and :resize

Steps to Reproduce:

NA

Expected Result:

Trying to delete a logical volume with this cookbook.

Actual Result:

NA

State that action :resize on a lv is actually a extend

Took me a while to understand, that you only can extend, since lvextend is used, not lvresize. For one how is trying to actually downsize a lv, this was hard to understand, since


lvm_logical_volume 'root' do
  group 'debian-8-vg'
  size '20G'
  action :resize
end

will not through any errors, eventhough the lv is 40G big right now, ti will just say "up to date" - all good. But well, of course the LV is not shrinked due to the use of lvextend https://github.com/chef-cookbooks/lvm/blob/master/libraries/provider_lvm_logical_volume.rb#L255

There should be a big fat notice or rather rename it to :extend (leave room for a real resize..) and make it for now deprecated to use :resize, while still mapping it to extend until the next major release or whatsoever

Check if a mount is allready mounted

libraries/provider_lvm_logical_volume.rb the mount resource should use the mounted attribute to only execute the mount if it ist not allready mounted.

resource_lvm_logical_volume.rb library compilation error

Cookbook version

4.0.4

Chef-client version

12.17.44

Platform Details

CentOS 6.8 running in AWS

Scenario:

Chef-client convergence failure

Steps to Reproduce:

We use the ephemeral-lvm from rightscale cookbook which depends on this cookbook to configure format and mount ephemeral drives as an LVM raid drive.

Expected Result:

Drives to be configured and mounted.

Actual Result:

Failure in the resource_lvm_logical_volume.rb library during compilation. This was working before we upgraded to the latest LVM release.

Starting Chef Client, version 12.17.44
resolving cookbooks for run list: ["role-dse-aws-nativex"]
Synchronizing Cookbooks:

  • cron (3.0.0)
  • iptables (3.0.1)
  • lvm (4.0.4)
  • nfs (2.3.1)
  • timezone-ii (0.2.0)
  • ntp-nativex (1.1.0)
  • ohai (4.2.3)
  • nano (1.0.3)
  • role-base-linux-nativex (1.3.2)
  • yum-epel (2.1.0)
  • ohai-nativex (1.0.0)
  • chef-sugar (3.4.0)
  • motd (0.6.4)
  • hostsfile (2.4.5)
  • apt (5.0.1)
  • numad-nativex (0.1.0)
  • java (1.43.0)
  • logrotate (2.1.0)
  • seven_zip (2.0.2)
  • aws (4.1.3)
  • dse-nativex (1.1.1)
  • role-dse-aws-nativex (1.3.2)
  • mingw (1.2.4)
  • limits (1.0.0)
  • chef_handler (2.0.0)
  • collectd-ng (2.2.0)
  • timezone-nativex (1.0.0)
  • graphite-nativex (1.1.1)
  • vim (2.0.2)
  • bash-completion (0.1.0)
  • autofs-nativex (1.1.1)
  • sysctl (0.8.1)
  • auto-patch (0.1.10)
  • line (0.6.3)
  • mlocate-nativex (1.0.0)
  • snmp (4.0.0)
  • dstat (0.1.1)
  • ephemeral_lvm-nativex (1.0.1)
  • ssh-authorized-keys-nativex (1.0.0)
  • sshd (1.3.0)
  • windows (2.1.1)
  • ssh_authorized_keys (0.3.0)
  • ad-nativex (3.2.1)
  • autopatch-nativex (1.3.1)
  • spacewalk-nativex (1.1.0)
  • tuned-nativex (0.1.1)
  • solarwinds-nativex (1.2.0)
  • aws-tagging-nativex (1.1.1)
  • build-essential (7.0.3)
  • chef-client (7.0.3)
  • chef-client-updater-nativex (1.0.1)
  • sudo (3.1.0)
  • yum (4.1.0)
  • compat_resource (12.16.3)
  • ephemeral_lvm (1.0.17)
  • hostname-nativex (1.0.2)
  • postfix-nativex (1.0.0)
  • homebrew (3.0.0)
    Installing Cookbook Gems:
    Compiling Cookbooks...
    Recipe: aws::ec2_hints
  • ohai_hint[ec2] action create
    • directory[/etc/chef/ohai/hints] action create (up to date)
    • file[/etc/chef/ohai/hints/ec2.json] action create (up to date)
      (up to date)
      Recipe: ohai-nativex::awsplugin
  • ohai_hint[aws] action create
    • directory[/etc/chef/ohai/hints] action create (up to date)
    • file[/etc/chef/ohai/hints/aws.json] action create (up to date)
      (up to date)
  • ohai_plugin[aws] action create
    • directory[/etc/chef/ohai/plugins] action create (skipped due to not_if)
    • cookbook_file[/etc/chef/ohai/plugins/aws.rb] action create (up to date)
    • ohai[aws] action reload
      • re-run ohai and merge results into node attributes

Recipe: chef-sugar::default

  • chef_gem[chef-sugar] action install (up to date)

================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/role-dse-aws-nativex/recipes/default.rb

TypeError

false can't be coerced into Float

Cookbook Trace:

/var/chef/cache/cookbooks/lvm/libraries/resource_lvm_logical_volume.rb:87:in `%'
/var/chef/cache/cookbooks/lvm/libraries/resource_lvm_logical_volume.rb:87:in `block in stripe_size'
/var/chef/cache/cookbooks/lvm/libraries/resource_lvm_logical_volume.rb:82:in `stripe_size'
/var/chef/cache/cookbooks/ephemeral_lvm/recipes/default.rb:71:in `block (2 levels) in from_file'
/var/chef/cache/cookbooks/lvm/libraries/resource_lvm_volume_group.rb:110:in `logical_volume'
/var/chef/cache/cookbooks/ephemeral_lvm/recipes/default.rb:63:in `block in from_file'
/var/chef/cache/cookbooks/ephemeral_lvm/recipes/default.rb:60:in `from_file'
/var/chef/cache/cookbooks/ephemeral_lvm-nativex/recipes/default.rb:15:in `from_file'
/var/chef/cache/cookbooks/role-base-linux-nativex/recipes/default.rb:172:in `from_file'
/var/chef/cache/cookbooks/role-dse-aws-nativex/recipes/default.rb:96:in `from_file'

Relevant File Content:

/var/chef/cache/cookbooks/lvm/libraries/resource_lvm_logical_volume.rb:

80: #
81: def stripe_size(arg = nil)
82: set_or_return(
83: :stripe_size,
84: arg,
85: kind_of: Integer,
86: callbacks: {
87>> 'must be a power of 2' => proc { |value| Math.log2(value) % 1.zero? },
88: }
89: )
90: end
91:
92: # Attribute: mirrors - number of mirrors for the volume
93: #
94: # @param arg [Integer] number of mirrors
95: #
96: # @return [Integer] number of mirrors

Platform:

x86_64-linux

Running handlers:
Running handlers complete
Chef Client failed. 2 resources updated in 06 seconds

Mount location overrides ownership on an existing mountpoint

I want to have a mount owned by a user. I tried creating the directory resources at the top of my recipe and then calling the logical_volume resource provider with the mount location option, but this caused the provider to create new directory resources that overrode my own. I would submit a PR but I have few questions:

  • Are guard statements run at compile time (I assume yes, so I can't just change it from checking Pathname.mountpoint? to Pathname.exists?)
  • Is there a way for a HWRP to check if a resource for a directory is in the resource collection already?
  • If neither of the above are possible, could I even catch this with chefspec in my own cookbook? I seem to be unable to stub the call to Pathname.exists in my unit tests, and it seems like Pathname probably isn't being called at all (are ruby guards not evaluated in chefspec?) My test claims that the directory is created with the ownership I expect, but that's not what happens on a real machine.

Update di-ruby-lvm-attrib Version

Cookbook version

2.1.0

Chef-client version

[root@ip-172-18-0-171 etc]# chef-client -v Chef: 12.10.24

Platform Details

[root@ip-172-18-0-171 etc]# cat /etc/centos-release CentOS release 6.7 (Final)

Scenario:

Creating a logical volume fails

Steps to Reproduce:

Create a logical volume on CentOS 6.7 fails when the latest version of LVM2 is installed:

  # shell out and run mkswap / swapon / add swap to /etc/fstab
  # to setup swap using a formula, the following can be inserted after the 'code <<-EOH' and before the 'dd if=...'
  # SSIZE=`free | grep ^Mem | awk '{MEM=($2 / 1024); if (MEM < 4097) { MEM=MEM*2}; printf("%0.f\n", MEM)}'`
  bash "setup_swap" do
    flags "-ex"
    user  "root"
    code <<-EOH
      dd if=/dev/zero of=/var/swap.img count=2048 bs=1M
      mkswap /var/swap.img
      printf "/var/swap.img swap                    swap    defaults        0 0" >> /etc/fstab
      swapon -a
    EOH
    not_if "test -f /var/swap.img"
  end

else
  aws_ebs_volume "ebsvol" do
    size node[:managementnode][:ebsvolsize]
    device "/dev/xvdf"
    action [ :create, :attach]
  end

  # Setup the physical volume
  lvm_physical_volume '/dev/xvdf' do
    not_if 'pvs --noheadings 2>&1 | egrep "(xs)?v?df"'
  end

  # Setup the volume group and the logical volumes
  lvm_volume_group   'vg00' do
    name             'vg00'
    physical_volumes [ '/dev/xvdf' ]
    action           :create
    only_if           "vgs --noheadings 2>&1 | grep 'No volume groups found'"

    # Don't set the FS type - if it is set, then
    # the system will attempt to 'mkfs.#{filesystem}'
    # We'll setup swap later
    logical_volume 'SwapVol' do
      name   'SwapVol'
      size   '2G'
      action :create
    end
  end

Expected Result:

The system should create a logical volume, set it up for swap, and then enable the swap space.

Actual Result:


    ================================================================================
    Error executing action `create` on resource 'lvm_physical_volume[/dev/xvdf]'
    ================================================================================

    ArgumentError
    -------------
    Unable to load lvm attributes [lvs.yaml] for version [2.02.143(2)]. The version/object may not be supported or you may need to upgrade the di-ruby-lvm-attrib gem. Error [No such file or directory @ rb_sysopen - /root/.chefdk/gem/ruby/2.1.0/gems/di-ruby-lvm-attrib-0.0.25/lib/lvm/attributes/2.02.143(2)/lvs.yaml]

    Cookbook Trace:
    ---------------
    /var/cache/chef/cookbooks/lvm/libraries/provider_lvm_physical_volume.rb:47:in `new'
    /var/cache/chef/cookbooks/lvm/libraries/provider_lvm_physical_volume.rb:47:in `action_create'
    /var/cache/chef/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:41:in `run_action'

    Resource Declaration:
    ---------------------
    # In /var/cache/chef/cookbooks/managementnode/recipes/setup-swap.rb

     45:   lvm_physical_volume '/dev/xvdf' do
     46:     not_if 'pvs --noheadings 2>&1 | egrep "(xs)?v?df"'
     47:   end
     48: 

    Compiled Resource:
    ------------------
    # Declared in /var/cache/chef/cookbooks/managementnode/recipes/setup-swap.rb:45:in `from_file'

    lvm_physical_volume("/dev/xvdf") do
      provider Chef::Provider::LvmPhysicalVolume
      action :create
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      declared_type :lvm_physical_volume
      cookbook_name "managementnode"
      recipe_name "setup-swap"
      not_if "pvs --noheadings 2>&1 | egrep "(xs)?v?df""
    end

    Platform:
    ---------
    x86_64-linux

I seem to have a newer version of LVM2:

[root@ip-172-18-0-171 etc]# rpm -qi lvm2
Name        : lvm2                         Relocations: (not relocatable)
Version     : 2.02.143                          Vendor: CentOS
Release     : 7.el6                         Build Date: Wed 11 May 2016 10:18:52 AM UTC
Install Date: Thu 26 May 2016 07:07:51 PM UTC      Build Host: worker1.bsys.centos.org
Group       : System Environment/Base       Source RPM: lvm2-2.02.143-7.el6.src.rpm
Size        : 2160255                          License: GPLv2
Signature   : RSA/SHA1, Thu 12 May 2016 10:48:12 AM UTC, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem <http://bugs.centos.org>
URL         : http://sources.redhat.com/lvm2
Summary     : Userland logical volume management tools
Description :
LVM2 includes all of the support for handling read/write operations on
physical volumes (hard disks, RAID-Systems, magneto optical, etc.,
multiple devices (MD), see mdadd(8) or even loop devices, see
losetup(8)), creating volume groups (kind of virtual disks) from one
or more physical volumes and creating one or more logical volumes
(kind of logical partitions) in volume groups.

I am running LVM 2.02.143, hence the Error [No such file or directory @ rb_sysopen - /root/.chefdk/gem/ruby/2.1.0/gems/di-ruby-lvm-attrib-0.0.25/lib/lvm/attributes/2.02.143(2)/lvs.yaml]

Checking the Gem, that directory/file does indeed NOT exist:

[root@ip-172-18-0-171 etc]# ls /root/.chefdk/gem/ruby/2.1.0/gems/di-ruby-lvm-attrib-0.0.25/lib/lvm/attributes
2.02.100(2)  2.02.105(2)  2.02.111(2)  2.02.115(2)  2.02.118(2)  2.02.120(2)  2.02.130(2)  2.02.26  2.02.29  2.02.54(1)  2.02.74(2)  2.02.84(2)  2.02.87(2)  2.02.95(2)
2.02.104(2)  2.02.106(2)  2.02.114(2)  2.02.116(2)  2.02.119(2)  2.02.122(2)  2.02.132(2)  2.02.27  2.02.30  2.02.66(2)  2.02.83(2)  2.02.86(2)  2.02.88(2)  2.02.98(2)

Installing the latest version of the di-ruby-lvm-attrib however, does:

[root@ip-172-18-0-171 etc]# gem install di-ruby-lvm-attrib
Fetching: di-ruby-lvm-attrib-0.0.26.gem (100%)
Successfully installed di-ruby-lvm-attrib-0.0.26
Parsing documentation for di-ruby-lvm-attrib-0.0.26
Installing ri documentation for di-ruby-lvm-attrib-0.0.26
Done installing documentation for di-ruby-lvm-attrib after 1 seconds
1 gem installed
[root@ip-172-18-0-171 etc]# which ruby
/usr/local/rvm/rubies/ruby-2.2.0/bin/ruby
[root@ip-172-18-0-171 etc]# find /usr/local/rvm/ -name di-ruby*
/usr/local/rvm/gems/ruby-2.2.0/doc/di-ruby-lvm-attrib-0.0.26
/usr/local/rvm/gems/ruby-2.2.0/specifications/di-ruby-lvm-attrib-0.0.26.gemspec
/usr/local/rvm/gems/ruby-2.2.0/cache/di-ruby-lvm-attrib-0.0.26.gem
/usr/local/rvm/gems/ruby-2.2.0/gems/di-ruby-lvm-attrib-0.0.26
/usr/local/rvm/gems/ruby-2.2.0/gems/di-ruby-lvm-attrib-0.0.26/di-ruby-lvm-attrib.gemspec
[root@ip-172-18-0-171 etc]# ls -latr /usr/local/rvm/gems/ruby-2.2.0/gems/di-ruby-lvm-attrib-0.0.26/lib/lvm/attributes/2.02.143* -d
drwxrwsr-x 2 root rvm 4096 May 27 17:29 /usr/local/rvm/gems/ruby-2.2.0/gems/di-ruby-lvm-attrib-0.0.26/lib/lvm/attributes/2.02.143(2)

Timeout formatting volume

Is there any way to increase the timeout? Looks like mkfs.ext4 is taking more than 5 minutes to format a 1000Gb ebs volume.

Mixlib::ShellOut::CommandTimeout
--------------------------------
Command timed out after 600s:
Command exceeded allowed execution time, process terminated
---- Begin output of yes | mkfs -t ext4 /dev/mapper/graphite-data ----
STDOUT: Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536000 inodes, 262142976 blocks
13107148 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
8000 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848

Writing inode tables: 6751/8000
STDERR: mke2fs 1.41.12 (17-May-2010)
---- End output of yes | mkfs -t ext4  /dev/mapper/graphite-data ----
Ran yes | mkfs -t ext4  /dev/mapper/graphite-data returned

Cookbook Trace:
---------------
/var/chef/cache/cookbooks/lvm/libraries/provider_lvm_logical_volume.rb:99:in `action_create'

Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/rse_graphite/recipes/ebs.rb

 45:   lvm_logical_volume 'data' do
 46:     name  'data'
 47:     group 'graphite'
 48:     size        '100%VG'
 49:     filesystem  'ext4'
 50:     mount_point(location: mount_point, options: 'noatime,nodiratime')
 51:   end
 52:

Removal of Old Gems Fails

Cookbook version

4.0.4

Chef-client version

12.17.44

Platform Details

CentOS 7.2.1511 (Core)

Scenario:

Using any resource from this cookbook fails as the new Gems conflict with the old ones.

Steps to Reproduce:

  1. Use a pre-4.x version of the cookbook to create some lvm resources.
  2. Update to a 4.x release of the cookbook.

Expected Result:

Old Gems should be removed, new Gems should be installed & Chef run continues without any changes to the system otherwise.

Actual Result:

Chef run fails. It claims the old Gems are removed but cannot install the new ones as the binaries conflict with the old ones:

* lvm_physical_volume[/dev/sdb] action create
    * chef_gem[/dev/sdb_di-ruby-lvm-attrib_removal] action remove (up to date)
    * chef_gem[/dev/sdb_di-ruby-lvm_removal] action remove (up to date)
    * chef_gem[chef-ruby-lvm-attrib] action install
      
      ================================================================================
      Error executing action `install` on resource 'chef_gem[chef-ruby-lvm-attrib]'
      ================================================================================
      
      Mixlib::ShellOut::ShellCommandFailed
      ------------------------------------
      Expected process to exit with [0], but received '1'
      ---- Begin output of /opt/chef/embedded/bin/gem install chef-ruby-lvm-attrib -q --no-rdoc --no-ri -v "0.0.28" ----
      STDOUT: 
      STDERR: ERROR:  Error installing chef-ruby-lvm-attrib:
        "generate_field_data" from chef-ruby-lvm-attrib conflicts with installed executable from di-ruby-lvm-attrib
      ---- End output of /opt/chef/embedded/bin/gem install chef-ruby-lvm-attrib -q --no-rdoc --no-ri -v "0.0.28" ----
      Ran /opt/chef/embedded/bin/gem install chef-ruby-lvm-attrib -q --no-rdoc --no-ri -v "0.0.28" returned 1
      
      Cookbook Trace:
      ---------------
      /var/chef/cache/cookbooks/lvm/libraries/lvm.rb:44:in `rescue in require_lvm_gems'
      /var/chef/cache/cookbooks/lvm/libraries/lvm.rb:20:in `require_lvm_gems'
      /var/chef/cache/cookbooks/lvm/libraries/provider_lvm_physical_volume.rb:46:in `action_create'
      
      Resource Declaration:
      ---------------------
      # In /var/chef/cache/cookbooks/lvm/libraries/lvm.rb
      
       44:     chef_gem 'chef-ruby-lvm-attrib' do
       45:       action :install
       46:       version node['lvm']['chef-ruby-lvm-attrib']['version']
       47:       compile_time true
       48:     end
       49: 
      
      Compiled Resource:
      ------------------
      # Declared in /var/chef/cache/cookbooks/lvm/libraries/lvm.rb:44:in `rescue in require_lvm_gems'
      
      chef_gem("chef-ruby-lvm-attrib") do
        package_name "chef-ruby-lvm-attrib"
        action [:install]
        retries 0
        retry_delay 2
        default_guard_interpreter :default
        declared_type :chef_gem
        cookbook_name "sbi_lvm"
        version "0.0.28"
        compile_time true
        gem_binary "/opt/chef/embedded/bin/gem"
      end
      
      Platform:
      ---------
      x86_64-linux
      
    
    ================================================================================
    Error executing action `create` on resource 'lvm_physical_volume[/dev/sdb]'
    ================================================================================
    
    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    chef_gem[chef-ruby-lvm-attrib] (/var/chef/cache/cookbooks/lvm/libraries/lvm.rb line 44) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
    ---- Begin output of /opt/chef/embedded/bin/gem install chef-ruby-lvm-attrib -q --no-rdoc --no-ri -v "0.0.28" ----
    STDOUT: 
    STDERR: ERROR:  Error installing chef-ruby-lvm-attrib:
        "generate_field_data" from chef-ruby-lvm-attrib conflicts with installed executable from di-ruby-lvm-attrib
    ---- End output of /opt/chef/embedded/bin/gem install chef-ruby-lvm-attrib -q --no-rdoc --no-ri -v "0.0.28" ----
    Ran /opt/chef/embedded/bin/gem install chef-ruby-lvm-attrib -q --no-rdoc --no-ri -v "0.0.28" returned 1
    
    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/lvm/libraries/lvm.rb:44:in `rescue in require_lvm_gems'
    /var/chef/cache/cookbooks/lvm/libraries/lvm.rb:20:in `require_lvm_gems'
    /var/chef/cache/cookbooks/lvm/libraries/provider_lvm_physical_volume.rb:46:in `action_create'
    
    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/sbi_lvm/recipes/extradisks.rb
    
      2:   lvm_physical_volume disk['device']
      3:   lvm_volume_group disk['vg'] do
    
    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/sbi_lvm/recipes/extradisks.rb:2:in `block in from_file'
    
    lvm_physical_volume("/dev/sdb") do
      provider Chef::Provider::LvmPhysicalVolume
      action :create
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      declared_type :lvm_physical_volume
      cookbook_name "sbi_lvm"
      recipe_name "extradisks"
    end
    
    Platform:
    ---------
    x86_64-linux

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.