We believe that the best way to build software is to do it in close collaboration with the people who use it. We invite you to submit your ideas using the form below. Please be sure to include the problem for which you are solving and the benefits of implementing the idea.
We do our best to implement as many Ideas as we can. Our Product team will evaluate all submitted ideas in a timely manner and will disposition each into one of the following categories: will integrate into the product roadmap, further research is needed, unlikely to implement.
Thanks for collaborating with us!
Was trying to use the standard 'package' resource to install a package across different Linux platforms, which use different installer file types. While being able to use conditional to feed the resource the different file name/types, I found that 'package' didn't necessarily call the correct sub-package resource, in this case on Ubuntu it was trying to use apt_package and I needed it to use dpkg_package.
So my thought is it would be nice if there was a property in the 'package' resource, like 'type' that would allow you to force 'package' to use a specific sub-package resource.
Ex:
case node['platform']
when 'centos', 'redhat', 'ubuntu'
package"Install Splunk Client #{new_resource.installer_version}" do
package_name 'splunkforwarder
source installer_path
action :install
end
end
def installer_path
"#{new_resource.installer_dir}/#{new_resource.installer_file}"
end
So in this case the installer_file is passed into the installer_path definition is based on which Linux platform this code is running on, that logic is elsewhere to make that determination which then creates the platform specific installer_path that is passed into the source property.
case node['platform']
when 'centos', 'redhat', 'ubuntu'
package"Install Splunk Client #{new_resource.installer_version}" do
package_name 'splunkforwarder
source installer_path
type: dkpg
action :install
end
end
def installer_path
"#{new_resource.installer_dir}/#{new_resource.installer_file}"
end
Not possible.
The dpkg_package resource needs to be declared in order to pass the block which contains the type provider. So you'd need to create the right object before you parse the thing which tells you which object to create. This is also currently possible with the provider argument to override the provider object, but that is unfixably buggy since it winds up creating situations like apt_package resources wrapping dpkg_package providers, so nobody should use that approach.
A better solution for this example is to just use `dpkg_package` directly instead of `package` on the DSL.
For situations where the user wants to reuse contents of the block then declare_resource can be used to switch both the resource and provider, in such a way that it does not bypass the dynamic provider-resolver and resource-resolver. This winds up properly with a dpkg_package resource wrapping a dpkg_package provider:
pack_res = ubuntu? ? :dpkg_package : :rpm_package
declare_resource(pack_res, "lsof") do
[ ... common codeblock ... ]
end