[chef-dev] Re: Resource requirements for an Idempotent resource


Chronological Thread 
  • From: Daniel DeLeo < >
  • To: Kishore S Kumar < >
  • Cc: chef-dev < >
  • Subject: [chef-dev] Re: Resource requirements for an Idempotent resource
  • Date: Mon, 10 Dec 2012 16:55:29 -0800


On Monday, December 10, 2012 at 4:41 PM, Kishore S Kumar wrote:

its here https://gist.github.com/4254683  -  I had a recipe to install a package X on a node which already had that package, and also in my recipe I provided a source which did not exist. The recipe failed saying that the requirements were not met, however I wouldn't want to fail because the running the action would cause no change as package is already installed (idenpotency)

If that's how you want it to behave, then you need to make the check do the equivalent of "source package available OR package is installed".

As a matter of correctness in messaging, the message you set for `whyrun` in your requirements should explain what's wrong/inconsistent with the system, in this case that it would try to install a package from a file that's not there.
-- 
Daniel DeLeo
 


On Mon, Dec 10, 2012 at 11:08 PM, Daniel DeLeo < " target="_blank"> > wrote:

On Sunday, December 9, 2012 at 10:25 PM, Kishore S Kumar wrote:

Hi,

I'm trying to understand how resource requirements work with idempotent resource. Can someone help me. Currently I have a idempotent resource which say install a software unless it is already installed. I have resource requirement assertion set for the action which fail if the installer does not exist.
What should have happened  when I try to run the recipe on a node where the software is already installed(idempotency) and the installer does not exist(resource requirements failed). 

right now the recipe fails saying the resource requirements failure.

Thanks
Kishore
Full explanation of what resource requirements are and do here: https://github.com/opscode/chef/blob/master/lib/chef/mixin/why_run.rb#L63-123

Short version is that they are for implementing why-run's precondition detection and assumption behavior. The canonical example is the case where you have a service that's not installed yet. Since chef can't query the init script to see if the service is running, it can't give any realistic information about whether a service would be started, so it emits a warning and then proceeds assuming the action would have been run.

-- 
Daniel DeLeo






Archive powered by MHonArc 2.6.16.

§