Module: ChefConfig::Mixin::ChefCloud
- Defined in:
- lib/chef-config/mixin/chef_cloud.rb
Constant Summary collapse
- CHEF_CLOUD_CLIENT_CONFIG =
"/Library/Managed Preferences/io.chef.chef_client.plist"
Class Method Summary collapse
Instance Method Summary collapse
-
#load_cloud_config ⇒ void
Load chef client cloud config configuration.
- #parse_cloud_config(path) ⇒ Object
Class Method Details
.cloud_config? ⇒ Boolean
25 26 27 |
# File 'lib/chef-config/mixin/chef_cloud.rb', line 25 def cloud_config? File.file?(CHEF_CLOUD_CLIENT_CONFIG) end |
Instance Method Details
#load_cloud_config ⇒ void
This method returns an undefined value.
Load chef client cloud config configuration.
50 51 52 |
# File 'lib/chef-config/mixin/chef_cloud.rb', line 50 def load_cloud_config Config.merge!(Hash[parse_cloud_config.map { |k, v| [k.to_sym, v] }]) end |
#parse_cloud_config(path) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/chef-config/mixin/chef_cloud.rb', line 30 def parse_cloud_config(path) return nil unless cloud_config? begin plist_cmd = Mixlib::ShellOut.new("plutil -convert json '" + CHEF_CLOUD_CLIENT_CONFIG + "' -o -") plist_cmd.run_command plist_cmd.error! JSON.parse(plist_cmd.stdout) rescue => e # TOML's error messages are mostly rubbish, so we'll just give a generic one = "Unable to parse chef client cloud config.\n" << e. raise ChefConfig::ConfigurationError, end end |