Coder Social home page Coder Social logo

Comments (8)

jaymzh avatar jaymzh commented on July 27, 2024

What we do is have /etc/chef/client.rb be a symlink. It either points to client-prod.rb or client-test.rb, and we have chef write out client-prod.rb instead of client.rb. Our setup is slightly more complicated, but that's the basic idea.

from chef-zero.

JeanMertz avatar JeanMertz commented on July 27, 2024

@jaymzh That's one way to go. But ideally I don't want to know the url beforehand (it is handled by a Chef recipe, based on the environment the Chef run is running in).

from chef-zero.

jaymzh avatar jaymzh commented on July 27, 2024

For the main client.rb? Sure... have Chef write that out that template as /etc/chef/client-prod.rb instead of /etc/chef/client.rb - the fact that Chef writes out that file doesn't have to change. Or am I misunderstanding?

from chef-zero.

JeanMertz avatar JeanMertz commented on July 27, 2024

@jaymzh I see what you are getting at, but in my original post I mention the use of the chef-client cookbook. Looking at the way the config-reload is handled, I don't see any way (besides using something like chef-rewind to override the loading of the written config file.

The cookbook writes a client.rb and the loads the configs from that file. There is no way to change this right now.

from chef-zero.

jaymzh avatar jaymzh commented on July 27, 2024

If client.rb doens't suit your environment change it...

vi cookbooks/chef-client/recipes/client.rb

and change line 73 to:

template "#{node["chef_client"]["conf_dir"]}/client-prod.rb" do

Then add:

link "#{node["chef_client"]["conf_dir"]}/client.rb" do
  # let our test processes point this elsewhere for chef-zero testing
  not_if { File.exists?("#{node["chef_client"]["conf_dir"]}/client.rb") }
  to "#{node["chef_client"]["conf_dir"]}/client-prod.rb"
end

from chef-zero.

JeanMertz avatar JeanMertz commented on July 27, 2024

Well, of course I can modify the community cookbook, but that's really an anti-pattern. That's why I also mentioned chef-rewind, but I'd rather do this the "proper way", instead of monkey patching a community cookbook using chef-rewind, or worse, forking the community cookbook for personal use.

I did just commit a pull request to add the option not to reload the config. That will solve my issues.

from chef-zero.

jaymzh avatar jaymzh commented on July 27, 2024

That approach means you only get one test-run against your chefzero server. The indirection means that you can do as many test runs as you need until you're ready to revert it.

Modifying cookbooks shouldn't be an anti-pattern... git handles merges very well. :)

from chef-zero.

JeanMertz avatar JeanMertz commented on July 27, 2024

Git does. But I just prefer the wrapper-cookbook approach to be on the safe side. And if possible (and it makes sense for others), I'd rather merge changes upstream.

You are right that this approach only gives a single test-run against ChefZero. But I also want this change for other changes unrelated to ChefZero (f.e. one-time changes to be used during a Packer.io machine building process).

Thank you for your valuable input though. It helped me solve the problem eventually.

from chef-zero.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.