chef-ingredient
chef-ingredient copied to clipboard
Downgrading throws "undefined method `allow_downgrade' for Chef::Resource::AptPackage"
Cookbook version
2.1.10
Chef-client version
13.6.2
Platform Details
Ubuntu 16.04
Scenario:
Downgrading a product is throwing:
* apt_package[delivery] action upgrade
================================================================================
Error executing action `upgrade` on resource 'apt_package[delivery]'
================================================================================
NoMethodError
-------------
undefined method `allow_downgrade' for Chef::Resource::AptPackage
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/chef-ingredient/libraries/default_handler.rb
55: package new_resource.product_name do # ~FC009
56: action action_name
57: package_name ingredient_package_name
58: options new_resource.options
59: source local_path || new_resource.package_source
60: timeout new_resource.timeout if new_resource.timeout
61: provider value_for_platform_family(
62: 'debian' => Chef::Provider::Package::Dpkg,
63: 'rhel' => node['platform_version'].to_i == 5 ? Chef::Provider::Package::Rpm : Chef::Provider::Package::Yum,
64: 'suse' => Chef::Provider::Package::Rpm,
65: 'windows' => Chef::Provider::Package::Windows
66: )
67: if new_resource.product_name == 'chef'
68: # We define this resource in ChefIngredientProvider
69: notifies :run, 'ruby_block[stop chef run]', :immediately
70: end
71: end
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/chef-ingredient/libraries/default_handler.rb:55:in `configure_from_source_package'
apt_package("delivery") do
package_name "automate"
provider Chef::Provider::Package::Dpkg
action [:upgrade]
default_guard_interpreter :default
declared_type :package
cookbook_name "automate-deploy"
options nil
source "/var/chef/cache/automate_1.7.39-1_amd64.deb"
end
System Info:
------------
chef_version=13.6.2
platform=ubuntu
platform_version=16.04
ruby=ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]
program_name=chef-client worker: ppid=26146;start=19:29:07;
executable=/opt/chef/bin/chef-client
@schisamo I'll save you all the experimentation I conducted, but it looks like there's a conflict with the package
resource's :upgrade
action when used with the source
property. I was able to replicate this error using apt_package
and package
directly.
Try changing the resource's action to :install
. This worked for me:
chef_ingredient 'automate-1.7' do
product_name 'automate'
version '1.7'
end
chef_ingredient 'automate-1.6' do
product_name 'automate'
version '1.6'
end
@wrightp If we use action :install
instead of action :upgrade
will upgrades still occur when available in the configured channel?
If you are setting package_source
it will always install the specified package.
If you are relying on channel
and version
, mixlib-install will always install a later version if found.
For example:
chef_ingredient 'automate-1.6' do
product_name 'automate'
version '1.6'
end
# installs 1.7.39
chef_ingredient 'automate-latest' do
product_name 'automate'
end
This is just a workaround though as it looks like a bug in chef