- From: Daniel DeLeo <
>
- To:
- Subject: [chef] Re: Re: Re: Re: Re: LWRP prevents code-reuse...
- Date: Mon, 5 Jul 2010 16:28:18 -0700
On Mon, Jul 5, 2010 at 8:12 AM, Ringo De Smet
<
>
wrote:
>
Daniel,
>
>
On 1 July 2010 17:50, Daniel DeLeo
>
<
>
>
wrote:
>
> Chef will automatically load them, but not in any guaranteed order. If
>
> they are all in the same cookbook, I'd recommend using something like:
>
>
>
> require File.dirname(__FILE__) + '/qshell_resource'
>
>
The ruby require worked now. However, on the Chef level, it is a pity
>
I can't use my custom script resource in the body of my package
>
provider:
>
>
def install_package(name, version)
>
pylabs_qshell "install_package" do
>
user "root"
>
code <<-EOH
>
pkg =
>
q.qp.find('#{new_resource.package_name}','#{new_resource.domain}','#{new_resource.version}')
>
pkg.install()
>
EOH
>
end
>
end
>
>
This would be a very elegant implementation. Any more suggestions? :-)
Sure, here's a few:
* Create a resource via something like Chef::ResourcePylabsQshell.new,
set the values you want and then use run_action to run it, similar to
this:
http://github.com/opscode/chef/blob/master/chef/lib/chef/provider/remote_directory.rb#L99-108
* Use Chef::Provider#recipe_eval
http://github.com/opscode/chef/blob/master/chef/lib/chef/provider.rb#L61-77
* Make your qshell functionality a ruby Module that you could mix in
* Make your qshell functionality into an "implementation class" and do
the same thing as the previous suggestion, except with composition
instead of inheritance.
>
>
Ringo
>
Archive powered by MHonArc 2.6.16.