[chef] Re: Re: Re: Re: Re: Re: Re: Good example of a lwrp


Chronological Thread 
  • From: Daniel DeLeo < >
  • To:
  • Subject: [chef] Re: Re: Re: Re: Re: Re: Re: Good example of a lwrp
  • Date: Fri, 21 Dec 2012 17:29:10 -0800


On Friday, December 21, 2012 at 4:15 PM, Maven User wrote:

actually - I'm a BIT further now (maybe).

So removing the action and end.run_action items, I can see now it's executing the ruby code when it should.

BUT - now it doesn't understand what a "directory" or a "template" is - how do I import these things?

You went a bit in the wrong direction. I'd recommend either:
1) use resources like normal, and put raw ruby code into ruby blocks:

action :something do
  directory "path" do
    #stuff
  end
  ruby_block "arbitrary_code" do
    block do
      # some code
    end
  end
  file "path/file" do
    #stuff
  end
end

OR

2) Use action :nothing plus run_action, but *no* ruby blocks

action :something do
  directory "path" do
    #stuff
    action :nothing
    run_action(:create) # this works if it's very last
  end # or you can put `.run_action()` here, it'll be the same result

  # random ruby code, NO ruby_block resource

  r = file "path/file" do
    #stuff
    action :nothing
  end
  r.run_action(:create) # this is the other way to use run_action(): assign resource to a variable
end

This example is a little complicated, but you should be able to see the general pattern:

https://github.com/opscode-cookbooks/java/blob/1.6.0/providers/ark.rb

-- 
Daniel DeLeo




Archive powered by MHonArc 2.6.16.

§