Exclude a recipe in whyrun mode


#1

Is there a way to exclude a recipe when in whyrun mode?

I mean when running a chef-client run in whyrun mode is there a way I could
specify on the recipe to not consider it when in whyrun mode i.e. Nothing
related to that recipe should be displayed in whyrun output.

Thanks,
Kishore


#2

On Wednesday, December 5, 2012 at 7:14 AM, Kishore S Kumar wrote:

Is there a way to exclude a recipe when in whyrun mode?
I mean when running a chef-client run in whyrun mode is there a way I could specify on the recipe to not consider it when in whyrun mode i.e. Nothing related to that recipe should be displayed in whyrun output.
Thanks,
Kishore
Your best bet is to use the --override-runlist option to chef-client. Alternatively, you could add checks for Chef::Config[:why_run] to your recipe.


Daniel DeLeo


#3

Override runlist does not work in my case as I’m trying automate it.
However if I’m going to add config check for whyrun would it be possible to
do it in my recipe something like 'not_if Chef::Config[why_run]'
On Dec 5, 2012 9:44 PM, “Daniel DeLeo” dan@kallistec.com wrote:

On Wednesday, December 5, 2012 at 7:14 AM, Kishore S Kumar wrote:

Is there a way to exclude a recipe when in whyrun mode?

I mean when running a chef-client run in whyrun mode is there a way I
could specify on the recipe to not consider it when in whyrun mode i.e.
Nothing related to that recipe should be displayed in whyrun output.

Thanks,
Kishore

Your best bet is to use the --override-runlist option to chef-client.
Alternatively, you could add checks for Chef::Config[:why_run] to your
recipe.


Daniel DeLeo


#4

On Wednesday, December 5, 2012 at 8:25 AM, Kishore S Kumar wrote:

Override runlist does not work in my case as I’m trying automate it. However if I’m going to add config check for whyrun would it be possible to do it in my recipe something like ‘not_if Chef::Config[why_run]’

You’d need to use the block form:

not_if { Chef::Config[:why_run] }

Just a quick question, what is it about this recipe that makes you want to avoid it in why run mode?


Daniel DeLeo


#5

There are few resources which no matter what, will always say that it would
be updated, for example, if I had a huge runlist with one of it having a
recipe that uses remote_directory and I run them in whyrun mode immediately
after a normal client run, the whyrun output would say “1 resource would be
updated”. However in my case I don’t care about whether remote directory
runs or not I only care about my recipes so I would expect an output that
says 0 resources would have been updated. Hence the need to ignore them at
whyrun.
.
Thanks
Kishore
On Dec 5, 2012 10:20 PM, “Daniel DeLeo” dan@kallistec.com wrote:

On Wednesday, December 5, 2012 at 8:25 AM, Kishore S Kumar wrote:

Override runlist does not work in my case as I’m trying automate it.
However if I’m going to add config check for whyrun would it be possible to
do it in my recipe something like ‘not_if Chef::Config[why_run]’

You’d need to use the block form:

not_if { Chef::Config[:why_run] }

Just a quick question, what is it about this recipe that makes you want to
avoid it in why run mode?


Daniel DeLeo


#6

Hi,

On Thu, Dec 6, 2012 at 1:26 PM, Kishore S Kumar <
abyu.kishore@thoughtworks.com> wrote:

There are few resources which no matter what, will always say that it
would be updated, for example, if I had a huge runlist with one of it
having a recipe that uses remote_directory and I run them in whyrun mode
immediately after a normal client run, the whyrun output would say “1
resource would be updated”. However in my case I don’t care about whether
remote directory runs or not I only care about my recipes so I would expect
an output that says 0 resources would have been updated. Hence the need to
ignore them at whyrun.

I am not sure it is possible. It is also a pain point in the handlers
aswell. In several of our handlers we allow the configuration of
blacklisted resources [1] that we know will spuriously report changes or
report changes we don’t care about. It would be nice to have a universal
way of blacklisting changes across handlers and why run if possible.

[1]


Cheers,

Peter Donald


#7

Adding not_if { #check for whyrun} on a recipe made doc formatter to skip
it and hence the whyrun output is as desired.

@Peter: yes that would be really helpful if we had a way of blacklisting
resources for why run mode

On Thu, Dec 6, 2012 at 8:42 AM, Peter Donald peter@realityforge.org wrote:

Hi,

On Thu, Dec 6, 2012 at 1:26 PM, Kishore S Kumar <
abyu.kishore@thoughtworks.com> wrote:

There are few resources which no matter what, will always say that it
would be updated, for example, if I had a huge runlist with one of it
having a recipe that uses remote_directory and I run them in whyrun mode
immediately after a normal client run, the whyrun output would say “1
resource would be updated”. However in my case I don’t care about whether
remote directory runs or not I only care about my recipes so I would expect
an output that says 0 resources would have been updated. Hence the need to
ignore them at whyrun.

I am not sure it is possible. It is also a pain point in the handlers
aswell. In several of our handlers we allow the configuration of
blacklisted resources [1] that we know will spuriously report changes or
report changes we don’t care about. It would be nice to have a universal
way of blacklisting changes across handlers and why run if possible.

[1]
https://github.com/realityforge/chef-gelf_handler/blob/master/files/default/chef_gelf_handler.rb#L66


Cheers,

Peter Donald


#8

On Thu, Dec 6, 2012 at 1:26 PM, Kishore S Kumar <abyu.kishore@thoughtworks.com (mailto:abyu.kishore@thoughtworks.com)> wrote:

There are few resources which no matter what, will always say that it would be updated, for example, if I had a huge runlist with one of it having a recipe that uses remote_directory and I run them in whyrun mode immediately after a normal client run, the whyrun output would say “1 resource would be updated”. However in my case I don’t care about whether remote directory runs or not I only care about my recipes so I would expect an output that says 0 resources would have been updated. Hence the need to ignore them at whyrun.
The remote_directory behavior is a bug that’s been fixed in master, by the way:

http://tickets.opscode.com/browse/CHEF-3564


Daniel DeLeo


#9

On Thu, Dec 6, 2012 at 4:12 AM, Peter Donald peter@realityforge.org wrote:

I am not sure it is possible. It is also a pain point in the handlers
aswell. In several of our handlers we allow the configuration of
blacklisted resources [1] that we know will spuriously report changes or
report changes we don’t care about. It would be nice to have a universal
way of blacklisting changes across handlers and why run if possible.

We do the same, and it would be nice indeed.

However I have to say: that would require support in Chef itself, and it’s
not necessarily trivial to implement in a useful way.
There is an alternative: as a community we need to step up and get those
cookbooks fixed.

Each of us can do their part according to the skill level: in many cases
there isn’t even a bug filed in Jira; just filing one when we noticed those
kind of spurious resource updates, instead of just ignoring, doesn’t take
long and is a step in the right direction.
I am as guilty as anybody else :slight_smile: