summaryrefslogtreecommitdiff
path: root/chef-config/lib
diff options
context:
space:
mode:
Diffstat (limited to 'chef-config/lib')
-rw-r--r--chef-config/lib/chef-config/config.rb6
-rw-r--r--chef-config/lib/chef-config/workstation_config_loader.rb35
2 files changed, 34 insertions, 7 deletions
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb
index b162cacd89..2187787c5e 100644
--- a/chef-config/lib/chef-config/config.rb
+++ b/chef-config/lib/chef-config/config.rb
@@ -490,9 +490,13 @@ module ChefConfig
# HTTP file servers.
default(:trusted_certs_dir) { PathHelper.join(config_dir, "trusted_certs") }
- # A directory that contains additional configuration scripts to load
+ # A directory that contains additional configuration scripts to load for chef-client
default(:client_d_dir) { PathHelper.join(config_dir, "client.d") }
+ # A directory that contains additional configuration scripts to load for
+ # the workstation config
+ default(:conf_d_dir) { PathHelper.join(config_dir, "conf.d") }
+
# Where should chef-solo download recipes from?
default :recipe_url, nil
diff --git a/chef-config/lib/chef-config/workstation_config_loader.rb b/chef-config/lib/chef-config/workstation_config_loader.rb
index 34ba6d6537..aabfe7235b 100644
--- a/chef-config/lib/chef-config/workstation_config_loader.rb
+++ b/chef-config/lib/chef-config/workstation_config_loader.rb
@@ -62,15 +62,17 @@ module ChefConfig
def load
# Ignore it if there's no explicit_config_file and can't find one at a
# default path.
- return false if config_location.nil?
+ if !config_location.nil?
+ if explicit_config_file && !path_exists?(config_location)
+ raise ChefConfig::ConfigurationError, "Specified config file #{config_location} does not exist"
+ end
- if explicit_config_file && !path_exists?(config_location)
- raise ChefConfig::ConfigurationError, "Specified config file #{config_location} does not exist"
+ # Have to set Config.config_file b/c other config is derived from it.
+ Config.config_file = config_location
+ read_config(IO.read(config_location), config_location)
end
- # Have to set Config.config_file b/c other config is derived from it.
- Config.config_file = config_location
- read_config(IO.read(config_location), config_location)
+ load_conf_d_directory
end
# (Private API, public for test purposes)
@@ -124,6 +126,27 @@ module ChefConfig
end
end
+ def load_conf_d_directory
+ conf_d_files.sort.map do |conf|
+ read_config(IO.read(conf), conf)
+ end
+ end
+
+ def conf_d_files
+ @conf_d_files ||=
+ begin
+ entries = if Config[:conf_d_dir]
+ Dir.glob(File.join(PathHelper.escape_glob(
+ Config[:conf_d_dir]), "*.rb"))
+ else
+ []
+ end
+ entries.select do |entry|
+ File.file?(entry)
+ end
+ end
+ end
+
def working_directory
a = if ChefConfig.windows?
env["CD"]