From e60111f2773b60309db41581a98a66b5ed7cdad6 Mon Sep 17 00:00:00 2001 From: tylercloke Date: Mon, 27 Apr 2015 16:12:53 -0700 Subject: Set chef_server_root config value to sane defaults. If chef_server_url matches /\/organizations\/\S*$/ aka .../organizations/someorg, then strip /organizations/someorg and use that as the chef_server_root default. Otherwise, just use whatever chef_server_url is as the default. --- lib/chef/config.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/chef/config.rb b/lib/chef/config.rb index 25557b077f..d73bcf8e6e 100644 --- a/lib/chef/config.rb +++ b/lib/chef/config.rb @@ -319,7 +319,17 @@ class Chef default :host, 'localhost' default :port, 8889.upto(9999) # Will try ports from 8889-9999 until one works end + default :chef_server_url, "https://localhost:443" + default(:chef_server_root) do + # if the chef_server_url is a path to an organization, aka + # 'some_url.../organizations/*' then remove the '/organization/*' by default + if self.configuration[:chef_server_url] =~ /\/organizations\/\S*$/ + self.configuration[:chef_server_url].split('/')[0..-3].join('/') + else # default to whatever chef_server_url is + self.configuration[:chef_server_url] + end + end default :rest_timeout, 300 default :yum_timeout, 900 -- cgit v1.2.1