Skip to content

Commit

Permalink
Uninstall the previous lvm gems
Browse files Browse the repository at this point in the history
This is quite noisy in the chef logs. I'll see if we can come up with a
better way to handle this soon.

Signed-off-by: Tim Smith <[email protected]>
  • Loading branch information
tas50 committed Dec 15, 2016
1 parent 8586e74 commit fde98bd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
1 change: 1 addition & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@

default['lvm']['chef-ruby-lvm']['version'] = '0.2.2'
default['lvm']['chef-ruby-lvm-attrib']['version'] = '0.0.28'
default['lvm']['cleanup_old_gems'] = true
12 changes: 12 additions & 0 deletions libraries/lvm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ module LVMCookbook
def require_lvm_gems
raise 'The previous di-ruby-lvm and di-ruby-lvm-attrib gems have been replaced with chef maintained forks. You have set the legacy attributes for pinning installed gem versions. You will need to remove these attributes and instead set the new chef varients. See the attributes file for the latest attributes.' if node['lvm']['di-ruby-lvm'] || node['lvm']['di-ruby-lvm-attrib']

if node['lvm']['cleanup_old_gems']
chef_gem 'di-ruby-lvm-attrib' do
action :remove
compile_time true
end

chef_gem 'di-ruby-lvm' do
action :remove
compile_time true
end
end

# require attribute specified gems
gem 'chef-ruby-lvm-attrib', node['lvm']['chef-ruby-lvm-attrib']['version']
gem 'chef-ruby-lvm', node['lvm']['chef-ruby-lvm']['version']
Expand Down
15 changes: 7 additions & 8 deletions libraries/provider_lvm_volume_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,13 @@ def action_extend
end
end

unless pvs_to_add.empty?
command = "vgextend #{name} #{pvs_to_add.join(' ')}"
Chef::Log.debug "Executing lvm command: '#{command}'"
output = lvm.raw command
Chef::Log.debug "Command output: '#{output}'"
new_resource.updated_by_last_action(true)
resize_logical_volumes
end
return if pvs_to_add.empty?
command = "vgextend #{name} #{pvs_to_add.join(' ')}"
Chef::Log.debug "Executing lvm command: '#{command}'"
output = lvm.raw command
Chef::Log.debug "Command output: '#{output}'"
new_resource.updated_by_last_action(true)
resize_logical_volumes
end

private
Expand Down
6 changes: 5 additions & 1 deletion test/fixtures/cookbooks/test/recipes/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
apt_update 'update' if platform_family?('debian')

# install the old gems to make sure the uninstall works
chef_gem ['di-chef-ruby-lvm-attrib', 'di-chef-ruby-lvm'] do
chef_gem 'di-ruby-lvm' do
compile_time true
end

chef_gem 'di-ruby-lvm-attrib' do
compile_time true
end

Expand Down

0 comments on commit fde98bd

Please sign in to comment.