Skip to content

Commit

Permalink
Use declare_resource for local package install
Browse files Browse the repository at this point in the history
Per this comment:

chef/chef#3487 (comment)

We should not use the `provider` property of resources. We should
instead use the DSL method, #declare_resource. This commit converts the
definition to use that method.
  • Loading branch information
jtimberman committed Jun 10, 2015
1 parent 2508ccd commit 987cca4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ cookbook doesn't support installing from networked package managers

## Requirements

Chef 11.10.0+ for `declare_resource`.

### Platforms

This cookbook uses Test Kitchen to do cross-platform convergence and
Expand Down
18 changes: 8 additions & 10 deletions definitions/splunk_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,14 @@
end
end

package params[:name] do
local_package_resource = case node['platform_family']
when 'rhel' then :rpm_package
when 'debian' then :dpkg_package
when 'omnios' then :solaris_package
end

declare_resource local_package_resource, params[:name] do
source cached_package.gsub(/\.Z/, '')
case node['platform_family']
when 'rhel'
provider Chef::Provider::Package::Rpm
when 'debian'
provider Chef::Provider::Package::Dpkg
when 'omnios'
provider Chef::Provider::Package::Solaris
options pkgopts.join(' ')
end
options pkgopts.join(' ') if platform?('omnios')
end
end

0 comments on commit 987cca4

Please sign in to comment.