Class: Chef::Application::Solo
- Inherits:
-
Chef::Application
- Object
- Chef::Application
- Chef::Application::Solo
- Includes:
- Mixin::ShellOut, ChefConfig::Mixin::DotD
- Defined in:
- lib/chef/application/solo.rb
Instance Attribute Summary collapse
-
#chef_client_json ⇒ Object
readonly
Returns the value of attribute chef_client_json.
Instance Method Summary collapse
- #configure_legacy_mode! ⇒ Object
- #reconfigure ⇒ Object
-
#run ⇒ Object
Get this party started.
- #run_application ⇒ Object
- #setup_application ⇒ Object
Methods included from Mixin::ShellOut
#a_to_s, #clean_array, #shell_out, #shell_out!, #shell_out_compact, #shell_out_compact!, #shell_out_compact_timeout, #shell_out_compact_timeout!, #shell_out_with_systems_locale, #shell_out_with_systems_locale!
Methods included from Mixin::PathSanity
#enforce_path_sanity, #sanitized_path
Methods inherited from Chef::Application
#apply_extra_config_options, #auto_log_level?, #chef_config, #chef_configfetcher, #configure_chef, #configure_encoding, #configure_log_location, #configure_logging, #configure_stdout_logger, debug_stacktrace, #emit_warnings, exit!, fatal!, #initialize, #load_config_file, #logger, logger, normalize_exit_code, #resolve_log_level, #run_chef_client, #set_specific_recipes, #setup_signal_handlers, use_separate_defaults?, #using_output_formatter?, #want_additional_logger?
Constructor Details
This class inherits a constructor from Chef::Application
Instance Attribute Details
#chef_client_json ⇒ Object (readonly)
Returns the value of attribute chef_client_json.
216 217 218 |
# File 'lib/chef/application/solo.rb', line 216 def chef_client_json @chef_client_json end |
Instance Method Details
#configure_legacy_mode! ⇒ Object
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/chef/application/solo.rb', line 258 def configure_legacy_mode! if Chef::Config[:daemonize] Chef::Config[:interval] ||= 1800 end # supervisor processes are enabled by default for interval-running processes but not for one-shot runs if Chef::Config[:client_fork].nil? Chef::Config[:client_fork] = !!Chef::Config[:interval] end Chef::Application.fatal!() if !Chef::Config[:client_fork] && Chef::Config[:interval] if Chef::Config[:recipe_url] cookbooks_path = Array(Chef::Config[:cookbook_path]).detect { |e| Pathname.new(e).cleanpath.to_s =~ /\/cookbooks\/*$/ } recipes_path = File.(File.join(cookbooks_path, "..")) if Chef::Config[:delete_entire_chef_repo] Chef::Log.trace "Cleanup path #{recipes_path} before extract recipes into it" FileUtils.rm_rf(recipes_path, :secure => true) end Chef::Log.trace "Creating path #{recipes_path} to extract recipes into" FileUtils.mkdir_p(recipes_path) tarball_path = File.join(recipes_path, "recipes.tgz") fetch_recipe_tarball(Chef::Config[:recipe_url], tarball_path) Mixlib::Archive.new(tarball_path).extract(Chef::Config.chef_repo_path, perms: false, ignore: /^\.$/) end # json_attribs shuld be fetched after recipe_url tarball is unpacked. # Otherwise it may fail if points to local file from tarball. if Chef::Config[:json_attribs] config_fetcher = Chef::ConfigFetcher.new(Chef::Config[:json_attribs]) @chef_client_json = config_fetcher.fetch_json end # Disable auditing for solo Chef::Config[:audit_mode] = :disabled end |
#reconfigure ⇒ Object
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'lib/chef/application/solo.rb', line 231 def reconfigure super load_dot_d(Chef::Config[:solo_d_dir]) if Chef::Config[:solo_d_dir] set_specific_recipes Chef::Config[:solo] = true if !Chef::Config[:solo_legacy_mode] # Because we re-parse ARGV when we move to chef-client, we need to tidy up some options first. ARGV.delete("--ez") # For back compat reasons, we need to ensure that we try and use the cache_path as a repo first Chef::Log.trace "Current chef_repo_path is #{Chef::Config.chef_repo_path}" if !Chef::Config.has_key?(:cookbook_path) && !Chef::Config.has_key?(:chef_repo_path) Chef::Config.chef_repo_path = Chef::Config.find_chef_repo_path(Chef::Config[:cache_path]) end Chef::Config[:local_mode] = true Chef::Config[:listen] = false else configure_legacy_mode! end end |
#run ⇒ Object
Get this party started
219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/chef/application/solo.rb', line 219 def run setup_signal_handlers reconfigure for_ezra if Chef::Config[:ez] if !Chef::Config[:solo_legacy_mode] Chef::Application::Client.new.run else setup_application run_application end end |
#run_application ⇒ Object
300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
# File 'lib/chef/application/solo.rb', line 300 def run_application if !Chef::Config[:client_fork] || Chef::Config[:once] # Run immediately without interval sleep or splay begin run_chef_client(Chef::Config[:specific_recipes]) rescue SystemExit raise rescue Exception => e Chef::Application.fatal!("#{e.class}: #{e.message}", e) end else interval_run_chef_client end end |
#setup_application ⇒ Object
296 297 298 |
# File 'lib/chef/application/solo.rb', line 296 def setup_application Chef::Daemon.change_privilege end |