diff options
author | AJ Christensen <aj@junglistheavy.industries> | 2014-12-30 11:39:55 +1300 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2015-02-09 21:58:39 -0500 |
commit | 95be9a0418b8db7b224092ef3e15282b5ae97eee (patch) | |
tree | 02c5ef4fa4fac28adf1a0abe5033e7b2642b3274 /lib/chef/application.rb | |
parent | 955bce9ed05d6c69a37c506dc9e24a6e407e1a4d (diff) | |
download | chef-95be9a0418b8db7b224092ef3e15282b5ae97eee.tar.gz |
Refs #2709: Isolate/fix the no-fork fault
* Share specific recipes code to application parent
* Update specs to passing, update specs to RSpec 3.
* Specs for set_specific_recipes, solo, client.
Diffstat (limited to 'lib/chef/application.rb')
-rw-r--r-- | lib/chef/application.rb | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/lib/chef/application.rb b/lib/chef/application.rb index 6c85f951f6..297e46ef3c 100644 --- a/lib/chef/application.rb +++ b/lib/chef/application.rb @@ -104,6 +104,12 @@ class Chef Chef::Config.merge!(config) end + def set_specific_recipes + Chef::Config[:specific_recipes] = + cli_arguments.map { |file| File.expand_path(file) } if + cli_arguments.respond_to?(:map) + end + # Initialize and configure the logger. # === Loggers and Formatters # In Chef 10.x and previous, the Logger was the primary/only way that Chef @@ -200,16 +206,18 @@ class Chef # Initializes Chef::Client instance and runs it def run_chef_client(specific_recipes = []) + unless specific_recipes.respond_to?(:size) + raise ArgumentError, 'received non-Array like specific_recipes argument' + end + Chef::LocalMode.with_server_connectivity do override_runlist = config[:override_runlist] - if specific_recipes.size > 0 - override_runlist ||= [] - end + override_runlist ||= [] if specific_recipes.size > 0 @chef_client = Chef::Client.new( @chef_client_json, - :override_runlist => config[:override_runlist], - :specific_recipes => specific_recipes, - :runlist => config[:runlist] + override_runlist: override_runlist, + specific_recipes: specific_recipes, + runlist: config[:runlist] ) @chef_client_json = nil @@ -239,7 +247,7 @@ class Chef # Override the TERM signal. trap('TERM') do Chef::Log.debug("SIGTERM received during converge," + - " finishing converge to exit normally (send SIGINT to terminate immediately)") + " finishing converge to exit normally (send SIGINT to terminate immediately)") end @chef_client.run @@ -253,7 +261,7 @@ class Chef # TERM singal is received (exit gracefully) trap('TERM') do Chef::Log.debug("SIGTERM received during converge," + - " finishing converge to exit normally (send SIGINT to terminate immediately)") + " finishing converge to exit normally (send SIGINT to terminate immediately)") end client_solo = Chef::Config[:solo] ? "chef-solo" : "chef-client" @@ -299,7 +307,7 @@ class Chef def configure_http_proxy if http_proxy = Chef::Config[:http_proxy] http_proxy_string = configure_proxy("http", http_proxy, - Chef::Config[:http_proxy_user], Chef::Config[:http_proxy_pass]) + Chef::Config[:http_proxy_user], Chef::Config[:http_proxy_pass]) env['http_proxy'] = http_proxy_string unless env['http_proxy'] env['HTTP_PROXY'] = http_proxy_string unless env['HTTP_PROXY'] end @@ -309,7 +317,7 @@ class Chef def configure_https_proxy if https_proxy = Chef::Config[:https_proxy] https_proxy_string = configure_proxy("https", https_proxy, - Chef::Config[:https_proxy_user], Chef::Config[:https_proxy_pass]) + Chef::Config[:https_proxy_user], Chef::Config[:https_proxy_pass]) env['https_proxy'] = https_proxy_string unless env['https_proxy'] env['HTTPS_PROXY'] = https_proxy_string unless env['HTTPS_PROXY'] end @@ -319,7 +327,7 @@ class Chef def configure_ftp_proxy if ftp_proxy = Chef::Config[:ftp_proxy] ftp_proxy_string = configure_proxy("ftp", ftp_proxy, - Chef::Config[:ftp_proxy_user], Chef::Config[:ftp_proxy_pass]) + Chef::Config[:ftp_proxy_user], Chef::Config[:ftp_proxy_pass]) env['ftp_proxy'] = ftp_proxy_string unless env['ftp_proxy'] env['FTP_PROXY'] = ftp_proxy_string unless env['FTP_PROXY'] end |