Can we force a "node save" in a "why run" mode


#1

Currently we don’t get a node save if we run in WhyRun mode. I was
wondering if there was a way to force a “node save” in this mode?
Thanks.
Bhavna


#2

WhyRun is supposed to be a dry run that doesn’t affect your server. Why do
you want to node.save in this mode?

On Thu, Sep 17, 2015 at 5:09 PM, Bhavna Agrawal bhavna@us.ibm.com wrote:

Currently we don’t get a node save if we run in WhyRun mode. I was
wondering if there was a way to force a “node save” in this mode?
Thanks.
Bhavna


#3

theres nothing stopping you from invoking a node.save. Add a handler that
hooks at run_finished and then inside it check if its why run mode and
invoke node.save.
but as brian said, this is a very very bad idea,
whole point of why run is to not change anything …just to estimate what
will be updated

On Thu, Sep 17, 2015 at 2:09 PM, Bhavna Agrawal bhavna@us.ibm.com wrote:

Currently we don’t get a node save if we run in WhyRun mode. I was
wondering if there was a way to force a “node save” in this mode?
Thanks.
Bhavna


#4

On Thursday, September 17, 2015 at 2:42 PM, Ranjib Dey wrote:

theres nothing stopping you from invoking a node.save. Add a handler that hooks at run_finished and then inside it check if its why run mode and invoke node.save.
but as brian said, this is a very very bad idea,
whole point of why run is to not change anything …just to estimate what will be updated

Node#save itself will try to stop you: https://github.com/chef/chef/blob/a59b1992cabd063bdcf1494a1a3d0edf48ffa0d5/lib/chef/node.rb#L546-L560
Though you could do a begin/ensure around temporarily unsetting why_run.

Anyway, we can probably give you better options if you tell us what problem you are trying to solve.


Daniel DeLeo