RE: RE: RE: How to force convergence without bootstrapping?


#1

Like others, I’m not sure I understand what you are asking.

chef-client runs every recipe in your run list every time. It converges every recipe every time - but then it only executes the parts that need executing. If it tried to reconfigure everything on every run, you’d have a chef-client that’s excruciatingly slow, and likely would break all kinds of things (such as restarting services in the middle of the day).

I have a feeling that you are trying to get chef-client to actually execute something every time?

There are two answers to that.

First of all, chef may be the wrong tool for that job. It is not a good replacement for cron or the like.

Secondly, it can be done. Simply have the resource depend on some condition that is never true. Or, if your goal is to run the same thing regularly, use chef to install a script into cron.

Kevin Keane

The NetTech

http://www.4nettech.com

Our values: Privacy, Liberty, Justice

See https://www.4nettech.com/corp/the-nettech-values.html

-----Original message-----
From: Fouts, Chris Chris.Fouts@Sensus.com
Sent: Wednesday 15th October 2014 7:23
To: chef@lists.opscode.com
Subject: [chef] RE: RE: How to force convergence without bootstrapping?

Sorry, let me ask it differently.

I do the following

  1.  knife bootstrap a node
    
  2.  knife node run_list add <node> “run_list”
    
  3.  chef-client on node, which converges the cookbooks
    

Normally, re-running chef-client on the node again will not do anything since the cookbooks have already run the first time, meaning I’ll just get an “up-to-date” message

My question is, how can I re-run chef-client to make it “act” like I have not done step 3 above the first time?

Chris

From: Nguyen, Dang [mailto:Dang.Nguyen@disney.com]
Sent: Tuesday, October 14, 2014 8:12 PM
To: chef@lists.opscode.com
Subject: [chef] RE: How to force convergence without bootstrapping?

Assuming you’ve bootstrapped the node already and assigned it a role, you simply run chef client.

-----Original Message-----
From: Fouts, Chris [Chris.Fouts@Sensus.com]
Received: Tuesday, 14 Oct 2014, 5:08PM
To: chef@lists.opscode.com mailto:chef@lists.opscode.com [chef@lists.opscode.com]
Subject: [chef] How to force convergence without bootstrapping?

Is there a way to “force” my cookbooks to rerun without bootstrapping my nodes?

Chris


#2

Maybe he is asking for the ability to have a certain part of a recipe run
every single time. Period.

I’m not sure either, but here is how youd do it.

You can put in something like an “execute” resource block (execute, by
itself, is not idempotent, and will be run in its entirety, every. single.
time.

Also, parts of the recipe that manually modify the attributes will run
every single time (They will not be skipped), incase your wanting to update
some node/ohai data each time it runs.

On Wed, Oct 15, 2014 at 11:00 AM, Kevin Keane Subscription <
subscription@kkeane.com> wrote:

Like others, I’m not sure I understand what you are asking.

chef-client runs every recipe in your run list every time. It converges
every recipe every time - but then it only executes the parts that need
executing. If it tried to reconfigure everything on every run, you’d have a
chef-client that’s excruciatingly slow, and likely would break all kinds of
things (such as restarting services in the middle of the day).

I have a feeling that you are trying to get chef-client to actually
execute something every time?

There are two answers to that.

First of all, chef may be the wrong tool for that job. It is not a good
replacement for cron or the like.

Secondly, it can be done. Simply have the resource depend on some
condition that is never true. Or, if your goal is to run the same thing
regularly, use chef to install a script into cron.

Kevin Keane

The NetTech

http://www.4nettech.com

Our values: Privacy, Liberty, Justice

See https://www.4nettech.com/corp/the-nettech-values.html

-----Original message-----
From: Fouts, Chris Chris.Fouts@Sensus.com
Sent: Wednesday 15th October 2014 7:23
To: chef@lists.opscode.com
Subject: [chef] RE: RE: How to force convergence without bootstrapping?

Sorry, let me ask it differently.

I do the following

  1.  knife bootstrap a node
    
  2.  knife node run_list add <node> “run_list”
    
  3.  chef-client on node, which converges the cookbooks
    

Normally, re-running chef-client on the node again will not do anything
since the cookbooks have already run the first time, meaning I’ll just get
an “up-to-date” message

My question is, how can I re-run chef-client to make it “act” like I have
not done step 3 above the first time?

Chris

From: Nguyen, Dang [mailto:Dang.Nguyen@disney.com]
Sent: Tuesday, October 14, 2014 8:12 PM
To: chef@lists.opscode.com
Subject: [chef] RE: How to force convergence without bootstrapping?

Assuming you’ve bootstrapped the node already and assigned it a role, you
simply run chef client.

-----Original Message-----
From: Fouts, Chris [Chris.Fouts@Sensus.com]
Received: Tuesday, 14 Oct 2014, 5:08PM
To: chef@lists.opscode.com [chef@lists.opscode.com]
Subject: [chef] How to force convergence without bootstrapping?

Is there a way to “force” my cookbooks to rerun without bootstrapping my
nodes?

Chris

Kenneth Barry
TuneIn | Build and Release Engineer
M: 409-673-0544
www.tunein.com


#3

While it certainly is possible to use ‘execute’ resources without guards to
force a command to run every single time you invoke chef-client, that’s
typically not a recommended practice and a big red flag. Convergent
infrastructure is about managing the entire state of your stack and running
arbitrary commands (especially running them always) is an anti-pattern that
introduces complexity down the road. You’ll probably end up needing to
refactor that decision after you hit inevitable roadblocks.

One of the things I usually tell folks getting started with Chef is to take
every situation that requires an ‘execute’ or ‘script’ resource and use
that opportunity to re-think how a particular process is handled. An
overwhelming majority of the time, there’s typically a better way to do
what you’re after. You can use recipes to always run arbitrary commands
and effectively turn Chef into bash++. But you’re going to lose out on all
the benefits of using Configuration Management.

Hit me up directly if you’d like to pick apart your use case.

On Wed, Oct 15, 2014 at 11:57 AM, Kenneth Barry kbarry@tunein.com wrote:

Maybe he is asking for the ability to have a certain part of a recipe run
every single time. Period.

I’m not sure either, but here is how youd do it.

You can put in something like an “execute” resource block (execute, by
itself, is not idempotent, and will be run in its entirety, every. single.
time.

Also, parts of the recipe that manually modify the attributes will run
every single time (They will not be skipped), incase your wanting to update
some node/ohai data each time it runs.

On Wed, Oct 15, 2014 at 11:00 AM, Kevin Keane Subscription <
subscription@kkeane.com> wrote:

Like others, I’m not sure I understand what you are asking.

chef-client runs every recipe in your run list every time. It converges
every recipe every time - but then it only executes the parts that need
executing. If it tried to reconfigure everything on every run, you’d have a
chef-client that’s excruciatingly slow, and likely would break all kinds of
things (such as restarting services in the middle of the day).

I have a feeling that you are trying to get chef-client to actually
execute something every time?

There are two answers to that.

First of all, chef may be the wrong tool for that job. It is not a good
replacement for cron or the like.

Secondly, it can be done. Simply have the resource depend on some
condition that is never true. Or, if your goal is to run the same thing
regularly, use chef to install a script into cron.

Kevin Keane

The NetTech

http://www.4nettech.com

Our values: Privacy, Liberty, Justice

See https://www.4nettech.com/corp/the-nettech-values.html

-----Original message-----
From: Fouts, Chris Chris.Fouts@Sensus.com
Sent: Wednesday 15th October 2014 7:23
To: chef@lists.opscode.com
Subject: [chef] RE: RE: How to force convergence without bootstrapping?

Sorry, let me ask it differently.

I do the following

  1.  knife bootstrap a node
    
  2.  knife node run_list add <node> “run_list”
    
  3.  chef-client on node, which converges the cookbooks
    

Normally, re-running chef-client on the node again will not do anything
since the cookbooks have already run the first time, meaning I’ll just get
an “up-to-date” message

My question is, how can I re-run chef-client to make it “act” like I have
not done step 3 above the first time?

Chris

From: Nguyen, Dang [mailto:Dang.Nguyen@disney.com]
Sent: Tuesday, October 14, 2014 8:12 PM
To: chef@lists.opscode.com
Subject: [chef] RE: How to force convergence without bootstrapping?

Assuming you’ve bootstrapped the node already and assigned it a role, you
simply run chef client.

-----Original Message-----
From: Fouts, Chris [Chris.Fouts@Sensus.com]
Received: Tuesday, 14 Oct 2014, 5:08PM
To: chef@lists.opscode.com [chef@lists.opscode.com]
Subject: [chef] How to force convergence without bootstrapping?

Is there a way to “force” my cookbooks to rerun without bootstrapping my
nodes?

Chris

Kenneth Barry
TuneIn | Build and Release Engineer
M: 409-673-0544
www.tunein.com


#4

Yup, I completely agree. Just wanted to make see if I could try to answer the question, regardless of the merit f the thing.

Sometimes I ask a question, looking for answers to another question, and answering te one I ask helps me answer the other one.

Or, yes we know it’s the wrong way, yes we agree with the eat practice, and no, this is not best practice. We just want to answer to this exact question.

Is it possible to format you hard drive on boot up? Yes it is, and here is how. Is that recommended? All the times I can think of, no it’s the worst idea ever. But could there be a situation when I needed/wanted to know how to do it? Sure, I am able to imagine that there could be a reason for someone to want to do it.

On Oct 15, 2014, at 12:57 PM, George Miranda gmiranda@getchef.com wrote:

While it certainly is possible to use ‘execute’ resources without guards to force a command to run every single time you invoke chef-client, that’s typically not a recommended practice and a big red flag. Convergent infrastructure is about managing the entire state of your stack and running arbitrary commands (especially running them always) is an anti-pattern that introduces complexity down the road. You’ll probably end up needing to refactor that decision after you hit inevitable roadblocks.

One of the things I usually tell folks getting started with Chef is to take every situation that requires an ‘execute’ or ‘script’ resource and use that opportunity to re-think how a particular process is handled. An overwhelming majority of the time, there’s typically a better way to do what you’re after. You can use recipes to always run arbitrary commands and effectively turn Chef into bash++. But you’re going to lose out on all the benefits of using Configuration Management.

Hit me up directly if you’d like to pick apart your use case.

On Wed, Oct 15, 2014 at 11:57 AM, Kenneth Barry kbarry@tunein.com wrote:
Maybe he is asking for the ability to have a certain part of a recipe run every single time. Period.

I’m not sure either, but here is how youd do it.

You can put in something like an “execute” resource block (execute, by itself, is not idempotent, and will be run in its entirety, every. single. time.

Also, parts of the recipe that manually modify the attributes will run every single time (They will not be skipped), incase your wanting to update some node/ohai data each time it runs.

On Wed, Oct 15, 2014 at 11:00 AM, Kevin Keane Subscription subscription@kkeane.com wrote:
Like others, I’m not sure I understand what you are asking.

chef-client runs every recipe in your run list every time. It converges every recipe every time - but then it only executes the parts that need executing. If it tried to reconfigure everything on every run, you’d have a chef-client that’s excruciatingly slow, and likely would break all kinds of things (such as restarting services in the middle of the day).

I have a feeling that you are trying to get chef-client to actually execute something every time?

There are two answers to that.

First of all, chef may be the wrong tool for that job. It is not a good replacement for cron or the like.

Secondly, it can be done. Simply have the resource depend on some condition that is never true. Or, if your goal is to run the same thing regularly, use chef to install a script into cron.

Kevin Keane

The NetTech

http://www.4nettech.com

Our values: Privacy, Liberty, Justice

See https://www.4nettech.com/corp/the-nettech-values.html

-----Original message-----
From: Fouts, Chris Chris.Fouts@Sensus.com
Sent: Wednesday 15th October 2014 7:23
To: chef@lists.opscode.com
Subject: [chef] RE: RE: How to force convergence without bootstrapping?

Sorry, let me ask it differently.

I do the following

  1.  knife bootstrap a node
    
  2.  knife node run_list add <node> “run_list”
    
  3.  chef-client on node, which converges the cookbooks
    

Normally, re-running chef-client on the node again will not do anything since the cookbooks have already run the first time, meaning I’ll just get an “up-to-date” message

My question is, how can I re-run chef-client to make it “act” like I have not done step 3 above the first time?

Chris

From: Nguyen, Dang [mailto:Dang.Nguyen@disney.com]
Sent: Tuesday, October 14, 2014 8:12 PM
To: chef@lists.opscode.com
Subject: [chef] RE: How to force convergence without bootstrapping?

Assuming you’ve bootstrapped the node already and assigned it a role, you simply run chef client.

-----Original Message-----
From: Fouts, Chris [Chris.Fouts@Sensus.com]
Received: Tuesday, 14 Oct 2014, 5:08PM
To: chef@lists.opscode.com [chef@lists.opscode.com]
Subject: [chef] How to force convergence without bootstrapping?

Is there a way to “force” my cookbooks to rerun without bootstrapping my nodes?

Chris


Kenneth Barry
TuneIn | Build and Release Engineer
M: 409-673-0544
www.tunein.com