[chef] Re: How Can I Run a recipe twice on the same machine with different settings for each invocation?


Chronological Thread 
  • From: Adam Jacob < >
  • To:
  • Subject: [chef] Re: How Can I Run a recipe twice on the same machine with different settings for each invocation?
  • Date: Tue, 18 Oct 2011 10:43:17 -0700

Title: Re: [chef] Re: How Can I Run a recipe twice on the same machine with different settings for each invocation?
A reasonable approach. The answer from support was the 'best' one, though, which is to take the recipe wrap it up in a definition or an LWRP.

If all you did was create a definition, paste the recipe in, and replace the 'agentid' with a parameter to the definition, you would wind up with:

agent "1" 
agent "2"

In your recipe.

Best,
Adam


On Oct 18, 2011, at 10:33 AM, Joe Lind wrote:

Just starting to work on chef  and not a ruby expert but I’ve done something similar like so:

attributes:
  default[“agent_config”][“agent1”][“param”] = “foo”
  default[“agent_config”][“agent2”][“param”] = “bar”

recipe:
    node[“agent_config”].each do |agent_id|
           node[“agent_config”][“#{agent_id}”].each do |agent_param|
               execute “#{agent_id}” do
                   command “#{agent_id}.sh #{agent_param}”
                   action :run
          end
    end


On 10/18/11 11:51 AM, "Bryan Baugher" < "> > wrote:

I asked this question to Opscode support earlier. They mentioned trying to use LWRP or Definitions to apply a set of chef commands multiple times with different settings. This of course did not help 100%, as I was hoping to leverage already existing cookbooks and did not want to have to write my cookbook to do something multiple times.

Another option is to setup multiple "nodes" on your system. You can do this by running chef_client with the -N option for its name and -k for the client key. Then you can adjust the node specific attributes use knife node edit MY_NODE.

Bryan

On Tue, Oct 18, 2011 at 11:37 AM, Tom Duckering < "> > wrote:
Hi,

I'm wondering if it's possible to apply a recipe twice on the same machine with different settings.

The exact reason is that I have a build farm and each agent can only run a single job at a time. I'd therefore like to install more than one agent on each machine. Each agent needs slightly different settings so that they don't clash.

So I'd like to say, run the agent recipe passing it a parameter to say "agentId=1" and run it again with "agentId=2" and so on.

Thanks in advance.
Tom




Archive powered by MHonArc 2.6.16.

§