sous-chefs / lvm

Development repository for the lvm cookbook
https://supermarket.chef.io/cookbooks/lvm
Apache License 2.0
56 stars 122 forks source link

Update di-ruby-lvm-attrib Version #98

Closed eyespies closed 8 years ago

eyespies commented 8 years ago

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)
donaldgifford commented 8 years ago

+1. Just ran into this same problem.

donaldgifford commented 8 years ago

From @zts on #chef IRC:

https://github.com/chef-cookbooks/lvm/blob/master/attributes/default.rb#L21

default['lvm']['di-ruby-lvm-attrib']['version'] = '0.0.26'

Set the version of the gem in attributes.