summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2019-09-12 22:14:14 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2019-09-12 22:14:14 -0700
commitc09c8e4a4814da64e8f5752d87860ed86eaa03e3 (patch)
treec8a4d21f8c079e393064a4677575805aa8ce2760
parent2b14e6417cdfdc91db6ceaf6533bc3313df1445c (diff)
downloadchef-lcg/deprecate-solo-legacy.tar.gz
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rwxr-xr-xchef-bin/bin/chef-solo2
-rw-r--r--lib/chef/application/base.rb44
-rw-r--r--lib/chef/application/client.rb39
-rw-r--r--lib/chef/application/solo.rb17
4 files changed, 45 insertions, 57 deletions
diff --git a/chef-bin/bin/chef-solo b/chef-bin/bin/chef-solo
index 3222323a46..fd45837b42 100755
--- a/chef-bin/bin/chef-solo
+++ b/chef-bin/bin/chef-solo
@@ -19,6 +19,6 @@
# limitations under the License.
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
-require "chef/application/solo"
+require "chef/application/client"
Chef::Application::Client.new(solo: true).run(enforce_license: true)
diff --git a/lib/chef/application/base.rb b/lib/chef/application/base.rb
index bef048287c..2e3ac3d500 100644
--- a/lib/chef/application/base.rb
+++ b/lib/chef/application/base.rb
@@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+require_relative "../../chef"
require_relative "../application"
require_relative "../client"
require_relative "../log"
@@ -22,9 +23,12 @@ require_relative "../mixin/shell_out"
require_relative "../config_fetcher"
require_relative "../dist"
require_relative "../daemon"
+require_relative "../workstation_config_loader"
require "chef-config/mixin/dot_d"
require "license_acceptance/cli_flags/mixlib_cli"
require "mixlib/archive" unless defined?(Mixlib::Archive)
+require "fileutils" unless defined?(FileUtils)
+require "uri" unless defined?(URI)
# This is a temporary class being used as a part of an effort to reduce duplication
# between Chef::Application::Client and Chef::Application::Solo.
@@ -163,6 +167,15 @@ class Chef::Application::Base < Chef::Application
long: "--[no-]fork",
description: "Fork #{Chef::Dist::PRODUCT} process."
+ unless Chef::Platform.windows?
+ option :daemonize,
+ short: "-d [WAIT]",
+ long: "--daemonize [WAIT]",
+ description: "Daemonize the process. Accepts an optional integer which is the " \
+ "number of seconds to wait before the first daemonized run.",
+ proc: lambda { |wait| wait =~ /^\d+$/ ? wait.to_i : true }
+ end
+
option :why_run,
short: "-W",
long: "--why-run",
@@ -180,6 +193,12 @@ class Chef::Application::Base < Chef::Application
end
}
+ option :pid_file,
+ short: "-P PID_FILE",
+ long: "--pid PIDFILE",
+ description: "Set the PID file location, for the #{Chef::Dist::PRODUCT} daemon process. Defaults to /tmp/chef-client.pid.",
+ proc: nil
+
option :run_lock_timeout,
long: "--run-lock-timeout SECONDS",
description: "Set maximum duration to wait for another client run to finish, default is indefinitely.",
@@ -394,7 +413,11 @@ class Chef::Application::Base < Chef::Application
if config[:local_mode]
config[:config_file] = Chef::WorkstationConfigLoader.new(nil, Chef::Log).config_location
else
- config[:config_file] = Chef::Config.platform_specific_path("#{Chef::Dist::CONF_DIR}/client.rb")
+ if Chef::Config[:solo]
+ config[:config_file] = Chef::Config.platform_specific_path("#{Chef::Dist::CONF_DIR}/solo.rb")
+ else
+ config[:config_file] = Chef::Config.platform_specific_path("#{Chef::Dist::CONF_DIR}/client.rb")
+ end
end
end
@@ -445,6 +468,25 @@ class Chef::Application::Base < Chef::Application
end
end
+ def run(enforce_license: false)
+ setup_signal_handlers
+ reconfigure
+ # setup_application does a Dir.chdir("/") and cannot come before reconfigure or many things break
+ setup_application
+ check_license_acceptance if enforce_license
+ for_ezra if Chef::Config[:ez]
+ if Chef::Config[:solo_legacy_mode]
+ Chef.deprecated(:solo_legacy_mode, "#{Chef::Dist::SOLOEXEC} --legacy-mode is deprecated and will be removed in #{Chef::Dist::PRODUCT} 16 (April 2020)")
+ end
+ run_application
+ end
+
+ def configure_logging
+ super
+ Mixlib::Authentication::Log.use_log_devices( Chef::Log )
+ Ohai::Log.use_log_devices( Chef::Log )
+ end
+
private
def windows_interval_error_message
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 2ea3df9f7b..56c40cda2b 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -18,8 +18,6 @@
# limitations under the License.
require_relative "base"
-require_relative "../handler/error_report"
-require_relative "../workstation_config_loader"
require "uri" unless defined?(URI)
# DO NOT MAKE EDITS, see Chef::Application::Base
@@ -31,23 +29,9 @@ class Chef::Application::Client < Chef::Application::Base
option :config_file,
short: "-c CONFIG",
long: "--config CONFIG",
+ default: Chef::Config.platform_specific_path("#{Chef::Dist::CONF_DIR}/solo.rb"),
description: "The configuration file to use."
- unless Chef::Platform.windows?
- option :daemonize,
- short: "-d [WAIT]",
- long: "--daemonize [WAIT]",
- description: "Daemonize the process. Accepts an optional integer which is the " \
- "number of seconds to wait before the first daemonized run.",
- proc: lambda { |wait| wait =~ /^\d+$/ ? wait.to_i : true }
- end
-
- option :pid_file,
- short: "-P PID_FILE",
- long: "--pid PIDFILE",
- description: "Set the PID file location, for the #{Chef::Dist::CLIENT} daemon process. Defaults to /tmp/chef-client.pid.",
- proc: nil
-
option :runlist,
short: "-r RunlistItem,RunlistItem...",
long: "--runlist RunlistItem,RunlistItem...",
@@ -67,25 +51,4 @@ class Chef::Application::Client < Chef::Application::Base
@solo_flag = solo
super()
end
-
- def run(enforce_license: false)
- setup_signal_handlers
- reconfigure
- # setup_application does a Dir.chdir("/") and cannot come before reconfigure or many things break
- setup_application
- check_license_acceptance if enforce_license
- for_ezra if Chef::Config[:ez]
- if Chef::Config[:solo_legacy_mode]
- Chef::Application::Solo.new.run # FIXME: minimally we just need to reparse the cli and then run_application
- else
- run_application
- end
- end
-
- def configure_logging
- super
- Mixlib::Authentication::Log.use_log_devices( Chef::Log )
- Ohai::Log.use_log_devices( Chef::Log )
- end
-
end
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index 3fac9520ec..5b8bdd2437 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -17,10 +17,6 @@
# limitations under the License.
require_relative "base"
-require_relative "../../chef"
-require_relative "client"
-require "fileutils" unless defined?(FileUtils)
-require "pathname" unless defined?(Pathname)
# DO NOT MAKE EDITS, see Chef::Application::Base
#
@@ -36,14 +32,6 @@ class Chef::Application::Solo < Chef::Application::Base
default: Chef::Config.platform_specific_path("#{Chef::Dist::CONF_DIR}/solo.rb"),
description: "The configuration file to use."
- unless Chef::Platform.windows?
- option :daemonize,
- short: "-d",
- long: "--daemonize",
- description: "Daemonize the process.",
- proc: lambda { |p| true }
- end
-
option :recipe_url,
short: "-r RECIPE_URL",
long: "--recipe-url RECIPE_URL",
@@ -53,9 +41,4 @@ class Chef::Application::Solo < Chef::Application::Base
@solo_flag = solo
super()
end
-
- def run(enforce_license: false)
- super
- Chef.deprecated(:solo_legacy_mode, "#{Chef::Dist::SOLOEXEC} --legacy-mode is deprecated and will be removed in #{Chef::Dist::PRODUCT} 16 (April 2020)")
- end
end