Chef Ideas

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.  Thanks for collaborating with us!

Add a 'type' property to the standard 'package' resource

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. 

 
Every other property I am passing into 'package' which I didn't include for the sake of brevity, is the same regardless of Linux platform.  So without this, it is forcing me to define separate RHEL and Ubuntu package resources which is 10 repetitive additional lines of code. 
 
but Ubuntu used apt_package for a .dpkg file.
 
So if I was able to do something like this:
 

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

  • Brian Whitacre
  • Nov 14 2019
  • Attach files