Closed quulah closed 7 years ago
@coderanger Could you please assist here? Do we actually need to replace options
with new_resource.options
in poise-driven providers?
As a quick hack I change the cached version of the cookbook to not give stuff from the options directly to the package resource, but used a temporary parameter in between.
The source parameter wouldn't work in this case any way since apt_package doesn't support it. dpkg_package is required in that case.
Removing checksum was also necessary, as the package resource doesn't have it.
It now installs in my particular case from the repository, but this might require a bit more thought. :)
Confirmed - the provider package
for consul_installation
resource doesn't work at the moment:
package
resource:# ...
def action_create
notifying_block do
pp options # => {\"version\"=>\"0.7.2\", \"package_name\"=>\"consul\"}"
pp new_resource.options # => {}
package options[:package_name] do
pp options # => nil
pp new_resource.options # => {}
source options[:package_source]
version options[:version]
action :upgrade
end
end
end
It is nil
because the name "options" is already in use as an attribute of package
: https://github.com/chef/chef/blob/master/lib/chef/resource/package.rb#L39
@coderanger @johnbellone Do you have any ideas how it could be fixed or worked around?
checksum
is not supported for "package" resourceIt causes the following error on RHEL:
NoMethodError
-------------
undefined method `checksum' for Chef::Resource::YumPackage
It is a custom attribute available only in "windows_package" resource, so it should be removed.
:uninstall
is not supported for "package" resourceIt causes the following exception:
Chef::Exceptions::ValidationFailed
----------------------------------
Option action must be equal to one of: nothing, install, upgrade, remove, purge, reconfig, lock, unlock! You passed :uninstall.
It is supported only in "chocolatey_package", but is already deprecated in favor of :remove
. We should use :remove
action instead.
Haven't had time to test it yet, sorry. I'll try as soon as I can.
Looking at the changes, it looks better, but I think it will still fail on Debian based installs when you specify the source. I don't know what's the reason behind it, but if you do so, you get this error message from the apt_package
resource instead of it just changing to dpkg_package
by itself.
@quulah I've appended the PR with a new commit, adding a new option - package_provider
. So now you can force it to use "dpkg" instead of "apt":
node.default['consul']['options']['package_provider'] = Chef::Provider::Package::Dpkg
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
I've packaged consul as a .deb package, and have it in an internal repository. I've been trying to persuade this cookbook to install it by using the consul_installation with the package provider.
There's little documentation on the subject, and seems like the tests are limited too. The best I've got so far is giving the following options based on the suggestion in #383.
But this results in a warning about new_resource.options and NilClass error:
The program parameter seems to go to the resource properly, but I'm unsure how the rest of the options are interpreted. The error points to line 39.
Do the options from apt_package interfere as the warning suggests?