-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to handle changing url of ChefZero during chef-client run #59
Comments
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. |
@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). |
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? |
@jaymzh I see what you are getting at, but in my original post I mention the use of the The cookbook writes a |
If client.rb doens't suit your environment change it...
and change line 73 to:
Then add:
|
Well, of course I can modify the community cookbook, but that's really an anti-pattern. That's why I also mentioned I did just commit a pull request to add the option not to reload the config. That will solve my issues. |
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. :) |
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. |
I'm running into an issue where my Chef run changes the chef-client config during the chef run (see chef-boneyard/chef-client#117). After this change, my cookbooks can no longer connect to ChefZero:
To handle test environments, I add a conditional resource to my chef run that adds the new chef-server domain to the
/etc/hosts
file like this:However, this only works on any subsequent runs, not during the initial run where the chef-config is updated mid-run, because ChefZero already started using the original
client.rb
configs.I suspect this is due to the fact that ChefZero only listens to a specific url+port, instead of globally listening on any url + port (ie
0.0.0.0:8889
). Listening on every ip is probably not the best idea (and seems to be unsupported in test-kitchen anyway), but is there any other option you can think of to solve this issue?The text was updated successfully, but these errors were encountered: