diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2016-02-04 17:36:41 -0800 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2016-02-24 21:24:14 -0800 |
commit | 9cfe82b9af36c92457598f857cba5671a1e24ef2 (patch) | |
tree | 3835f3023a32e83a69558b7f35b8329dfdbc2161 /lib/chef/application | |
parent | d0f2106071bf6cd8caf41555fe1a1784b3aff1fa (diff) | |
download | chef-9cfe82b9af36c92457598f857cba5671a1e24ef2.tar.gz |
Make chef-client read client.d
client.d/*.rb will be read in sorted order. All directories will be
ignored.
Diffstat (limited to 'lib/chef/application')
-rw-r--r-- | lib/chef/application/client.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb index 9ec553fb8a..c9a381a045 100644 --- a/lib/chef/application/client.rb +++ b/lib/chef/application/client.rb @@ -372,7 +372,12 @@ class Chef::Application::Client < Chef::Application config[:config_file] = Chef::Config.platform_specific_path("/etc/chef/client.rb") end end + + # Load the client.rb configuration super + + # Load all config files in client.d + load_config_d_directory end def configure_logging @@ -503,4 +508,28 @@ class Chef::Application::Client < Chef::Application end end end + + def load_config_d_directory + list_config_d_files.sort.each do |conf| + if File.file?(conf) + load_config_d_file(conf) + end + end + end + + def load_config_d_file(f) + config_fetcher = Chef::ConfigFetcher.new(conf) + config_fetcher.read_local_config.tap do |config_content| + apply_config(config_content, conf) + end + end + + def list_config_d_files + if Chef::Config[:client_d_dir] + Dir.glob(File.join(Chef::Util::PathHelper.escape_glob( + Chef::Config[:client_d_dir]), "*.rb")) + else + [] + end + end end |