Search code examples
environmentknifechef-infra

Chef/Knife running two environments on same machine


We have a series of cookbooks that are common across many environments. Up until recently, they've always been on different machines. Now we have a requirement that we need to run the same series of cookbooks across two environment files on the same machine.

What is the best practice here for doing this? Simply calling:

knife winrm %server% chef-client -m -x %user% -P %pass% -E %environment%

Is that the same as:

Knife node edit %server% 

And changing the environment there? We need to be able to do command line switching of environments. Please advise, TIA!


Solution

  • The tool you are looking for is knife-flip by John Cowie from Etsy:

    $ knife node flip mynode.foo.com myenv [--preview]