summaryrefslogtreecommitdiff
path: root/lib/chef/application
diff options
context:
space:
mode:
authorMarc Chamberland <mchamberland@pbsc.com>2019-04-06 19:16:22 -0400
committerMarc Chamberland <mchamberland@pbsc.com>2019-04-19 19:02:35 -0400
commit33d1f9e3ad1013387a3b3a53d6969c905942b692 (patch)
treeff8ed416f691478e046a65210040311a6608d985 /lib/chef/application
parentf1a97f33d4b67645ed55ce6e15274d6adf396670 (diff)
downloadchef-33d1f9e3ad1013387a3b3a53d6969c905942b692.tar.gz
Replacing workmarks with distro constants
Signed-off-by: Marc Chamberland <mchamberland@pbsc.com>
Diffstat (limited to 'lib/chef/application')
-rw-r--r--lib/chef/application/apply.rb9
-rw-r--r--lib/chef/application/client.rb35
-rw-r--r--lib/chef/application/knife.rb15
-rw-r--r--lib/chef/application/solo.rb17
-rw-r--r--lib/chef/application/windows_service.rb27
5 files changed, 54 insertions, 49 deletions
diff --git a/lib/chef/application/apply.rb b/lib/chef/application/apply.rb
index 5b697703d7..c25f0ed46e 100644
--- a/lib/chef/application/apply.rb
+++ b/lib/chef/application/apply.rb
@@ -26,6 +26,7 @@ require "fileutils"
require "tempfile"
require "chef/providers"
require "chef/resources"
+require "chef/dist"
class Chef::Application::Apply < Chef::Application
@@ -85,9 +86,9 @@ class Chef::Application::Apply < Chef::Application
option :version,
short: "-v",
long: "--version",
- description: "Show chef version",
+ description: "Show #{Chef::Dist::PRODUCT} version",
boolean: true,
- proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" },
+ proc: lambda { |v| puts "#{Chef::Dist::PRODUCT}: #{::Chef::VERSION}" },
exit: 0
option :why_run,
@@ -98,7 +99,7 @@ class Chef::Application::Apply < Chef::Application
option :profile_ruby,
long: "--[no-]profile-ruby",
- description: "Dump complete Ruby call graph stack of entire Chef run (expert only)",
+ description: "Dump complete Ruby call graph stack of entire #{Chef::Dist::PRODUCT} run (expert only)",
boolean: true,
default: false
@@ -110,7 +111,7 @@ class Chef::Application::Apply < Chef::Application
option :minimal_ohai,
long: "--minimal-ohai",
- description: "Only run the bare minimum ohai plugins chef needs to function",
+ description: "Only run the bare minimum ohai plugins #{Chef::Dist::CLIENT} needs to function",
boolean: true
attr_reader :json_attribs
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 789b938213..3758abe378 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -29,6 +29,7 @@ require "chef/mixin/shell_out"
require "chef-config/mixin/dot_d"
require "mixlib/archive"
require "uri"
+require "chef/dist"
class Chef::Application::Client < Chef::Application
include Chef::Mixin::ShellOut
@@ -70,7 +71,7 @@ class Chef::Application::Client < Chef::Application
option :profile_ruby,
long: "--[no-]profile-ruby",
- description: "Dump complete Ruby call graph stack of entire Chef run (expert only)",
+ description: "Dump complete Ruby call graph stack of entire #{Chef::Dist::PRODUCT} run (expert only)",
boolean: true,
default: false
@@ -125,7 +126,7 @@ class Chef::Application::Client < Chef::Application
option :pid_file,
short: "-P PID_FILE",
long: "--pid PIDFILE",
- description: "Set the PID file location, for the chef-client daemon process. Defaults to /tmp/chef-client.pid",
+ description: "Set the PID file location, for the #{Chef::Dist::CLIENT} daemon process. Defaults to /tmp/chef-client.pid",
proc: nil
option :lockfile,
@@ -136,12 +137,12 @@ class Chef::Application::Client < Chef::Application
option :interval,
short: "-i SECONDS",
long: "--interval SECONDS",
- description: "Run chef-client periodically, in seconds",
+ description: "Run #{Chef::Dist::CLIENT} periodically, in seconds",
proc: lambda { |s| s.to_i }
option :once,
long: "--once",
- description: "Cancel any interval or splay options, run chef once and exit",
+ description: "Cancel any interval or splay options, run #{Chef::Dist::CLIENT} once and exit",
boolean: true
option :json_attribs,
@@ -165,7 +166,7 @@ class Chef::Application::Client < Chef::Application
option :chef_server_url,
short: "-S CHEFSERVERURL",
long: "--server CHEFSERVERURL",
- description: "The chef server URL",
+ description: "The #{Chef::Dist::PRODUCT} server URL",
proc: nil
option :validation_key,
@@ -188,14 +189,14 @@ class Chef::Application::Client < Chef::Application
option :environment,
short: "-E ENVIRONMENT",
long: "--environment ENVIRONMENT",
- description: "Set the Chef Environment on the node"
+ description: "Set the #{Chef::Dist::PRODUCT} Environment on the node"
option :version,
short: "-v",
long: "--version",
- description: "Show chef version",
+ description: "Show #{Chef::Dist::PRODUCT} version",
boolean: true,
- proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" },
+ proc: lambda { |v| puts "#{Chef::Dist::PRODUCT}: #{::Chef::VERSION}" },
exit: 0
option :override_runlist,
@@ -237,13 +238,13 @@ class Chef::Application::Client < Chef::Application
option :enable_reporting,
short: "-R",
long: "--enable-reporting",
- description: "Enable reporting data collection for chef runs",
+ description: "Enable reporting data collection for #{Chef::Dist::PRODUCT} runs",
boolean: true
option :local_mode,
short: "-z",
long: "--local-mode",
- description: "Point chef-client at local repository",
+ description: "Point #{Chef::Dist::CLIENT} at local repository",
boolean: true
option :chef_zero_host,
@@ -268,13 +269,13 @@ class Chef::Application::Client < Chef::Application
option :fatal_windows_admin_check,
short: "-A",
long: "--fatal-windows-admin-check",
- description: "Fail the run when chef-client doesn't have administrator privileges on Windows",
+ description: "Fail the run when #{Chef::Dist::CLIENT} doesn't have administrator privileges on Windows",
boolean: true
end
option :minimal_ohai,
long: "--minimal-ohai",
- description: "Only run the bare minimum ohai plugins chef needs to function",
+ description: "Only run the bare minimum ohai plugins #{Chef::Dist::CLIENT} needs to function",
boolean: true
option :listen,
@@ -328,7 +329,7 @@ class Chef::Application::Client < Chef::Application
if Chef::Config[:recipe_url]
if !Chef::Config.local_mode
- Chef::Application.fatal!("chef-client recipe-url can be used only in local-mode")
+ Chef::Application.fatal!("recipe-url can be used only in local-mode")
else
if Chef::Config[:delete_entire_chef_repo]
Chef::Log.trace "Cleanup path #{Chef::Config.chef_repo_path} before extract recipes into it"
@@ -419,7 +420,7 @@ class Chef::Application::Client < Chef::Application
# Run the chef client, optionally daemonizing or looping at intervals.
def run_application
if Chef::Config[:version]
- puts "Chef version: #{::Chef::VERSION}"
+ puts "#{Chef::Dist::PRODUCT} version: #{::Chef::VERSION}"
end
if !Chef::Config[:client_fork] || Chef::Config[:once]
@@ -440,7 +441,7 @@ class Chef::Application::Client < Chef::Application
def interval_run_chef_client
if Chef::Config[:daemonize]
- Chef::Daemon.daemonize("chef-client")
+ Chef::Daemon.daemonize(Chef::DIST::CLIENT)
# Start first daemonized run after configured number of seconds
if Chef::Config[:daemonize].is_a?(Integer)
@@ -503,10 +504,10 @@ class Chef::Application::Client < Chef::Application
end
def unforked_interval_error_message
- "Unforked chef-client interval runs are disabled in Chef 12." +
+ "Unforked #{Chef::Dist::CLIENT} interval runs are disabled in Chef 12." +
"\nConfiguration settings:" +
("\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]).to_s +
- "\nEnable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
+ "\nEnable #{Chef::Dist::CLIENT} interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
end
def fetch_recipe_tarball(url, path)
diff --git a/lib/chef/application/knife.rb b/lib/chef/application/knife.rb
index 76dd5707fe..5b84ffdf1a 100644
--- a/lib/chef/application/knife.rb
+++ b/lib/chef/application/knife.rb
@@ -20,12 +20,13 @@ require "chef/application"
require "mixlib/log"
require "ohai/config"
require "chef/monkey_patches/net_http.rb"
+require "chef/dist"
class Chef::Application::Knife < Chef::Application
- NO_COMMAND_GIVEN = "You need to pass a sub-command (e.g., knife SUB-COMMAND)\n".freeze
+ NO_COMMAND_GIVEN = "You need to pass a sub-command (e.g., #{Chef::Dist::KNIFE} SUB-COMMAND)\n".freeze
- banner "Usage: knife sub-command (options)"
+ banner "Usage: #{Chef::Dist::KNIFE} sub-command (options)"
option :config_file,
short: "-c CONFIG",
@@ -58,7 +59,7 @@ class Chef::Application::Knife < Chef::Application
option :environment,
short: "-E ENVIRONMENT",
long: "--environment ENVIRONMENT",
- description: "Set the Chef environment (except for in searches, where this will be flagrantly ignored)"
+ description: "Set the #{Chef::Dist::PRODUCT} environment (except for in searches, where this will be flagrantly ignored)"
option :editor,
short: "-e EDITOR",
@@ -94,7 +95,7 @@ class Chef::Application::Knife < Chef::Application
option :chef_server_url,
short: "-s URL",
long: "--server-url URL",
- description: "Chef Server URL"
+ description: "#{Chef::Dist::PRODUCT} Server URL"
option :yes,
short: "-y",
@@ -118,7 +119,7 @@ class Chef::Application::Knife < Chef::Application
option :local_mode,
short: "-z",
long: "--local-mode",
- description: "Point knife commands at local repository instead of server",
+ description: "Point #{Chef::Dist::KNIFE} commands at local repository instead of server",
boolean: true
option :chef_zero_host,
@@ -137,9 +138,9 @@ class Chef::Application::Knife < Chef::Application
option :version,
short: "-v",
long: "--version",
- description: "Show chef version",
+ description: "Show #{Chef::Dist::PRODUCT} version",
boolean: true,
- proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" },
+ proc: lambda { |v| puts "#{Chef::Dist::PRODUCT}: #{::Chef::VERSION}" },
exit: 0
option :fips,
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index 43bf31530c..457cb1578c 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -29,6 +29,7 @@ require "chef/mixin/shell_out"
require "pathname"
require "chef-config/mixin/dot_d"
require "mixlib/archive"
+require "chef/dist"
class Chef::Application::Solo < Chef::Application
include Chef::Mixin::ShellOut
@@ -68,7 +69,7 @@ class Chef::Application::Solo < Chef::Application
option :profile_ruby,
long: "--[no-]profile-ruby",
- description: "Dump complete Ruby call graph stack of entire Chef run (expert only)",
+ description: "Dump complete Ruby call graph stack of entire #{Chef::Dist::PRODUCT} run (expert only)",
boolean: true,
default: false
@@ -127,7 +128,7 @@ class Chef::Application::Solo < Chef::Application
option :interval,
short: "-i SECONDS",
long: "--interval SECONDS",
- description: "Run chef-client periodically, in seconds",
+ description: "Run #{Chef::Dist::CLIENT} periodically, in seconds",
proc: lambda { |s| s.to_i }
option :json_attribs,
@@ -156,9 +157,9 @@ class Chef::Application::Solo < Chef::Application
option :version,
short: "-v",
long: "--version",
- description: "Show chef version",
+ description: "Show #{Chef::Dist::EXEC} version",
boolean: true,
- proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" },
+ proc: lambda { |v| puts "#{Chef::Dist::PRODUCT}: #{::Chef::VERSION}" },
exit: 0
option :override_runlist,
@@ -191,7 +192,7 @@ class Chef::Application::Solo < Chef::Application
option :environment,
short: "-E ENVIRONMENT",
long: "--environment ENVIRONMENT",
- description: "Set the Chef Environment on the node"
+ description: "Set the #{Chef::Dist::PRODUCT} Environment on the node"
option :run_lock_timeout,
long: "--run-lock-timeout SECONDS",
@@ -200,7 +201,7 @@ class Chef::Application::Solo < Chef::Application
option :minimal_ohai,
long: "--minimal-ohai",
- description: "Only run the bare minimum ohai plugins chef needs to function",
+ description: "Only run the bare minimum ohai plugins #{Chef::Dist::PRODUCT} needs to function",
boolean: true
option :delete_entire_chef_repo,
@@ -365,9 +366,9 @@ class Chef::Application::Solo < Chef::Application
end
def unforked_interval_error_message
- "Unforked chef-client interval runs are disabled in Chef 12." +
+ "Unforked #{Chef::Dist::CLIENT} interval runs are disabled in #{Chef::Dist::PRODUCT} 12." +
"\nConfiguration settings:" +
("\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]).to_s +
- "\nEnable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
+ "\nEnable #{Chef::Dist::CLIENT} interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
end
end
diff --git a/lib/chef/application/windows_service.rb b/lib/chef/application/windows_service.rb
index a9da048ab8..2bb2fedec9 100644
--- a/lib/chef/application/windows_service.rb
+++ b/lib/chef/application/windows_service.rb
@@ -29,6 +29,7 @@ require "socket"
require "uri"
require "win32/daemon"
require "chef/mixin/shell_out"
+require "chef/dist"
class Chef
class Application
@@ -66,7 +67,7 @@ class Chef
@service_signal = ConditionVariable.new
reconfigure
- Chef::Log.info("Chef Client Service initialized")
+ Chef::Log.info("#{Chef::Dist::CLIENT} Service initialized")
end
def service_main(*startup_parameters)
@@ -78,7 +79,7 @@ class Chef
# Grab the service_action_mutex to make a chef-client run
@service_action_mutex.synchronize do
begin
- Chef::Log.info("Next chef-client run will happen in #{timeout} seconds")
+ Chef::Log.info("Next #{Chef::Dist::CLIENT} run will happen in #{timeout} seconds")
@service_signal.wait(@service_action_mutex, timeout)
# Continue only if service is RUNNING
@@ -95,7 +96,7 @@ class Chef
# run chef-client only if service is in RUNNING state
next if state != RUNNING
- Chef::Log.info("Chef-Client service is starting a chef-client run...")
+ Chef::Log.info("#{Chef::Dist::CLIENT} service is starting a #{Chef::Dist::CLIENT} run...")
run_chef_client
rescue SystemExit => e
# Do not raise any of the errors here in order to
@@ -120,7 +121,7 @@ class Chef
def service_stop
run_warning_displayed = false
- Chef::Log.info("STOP request from operating system.")
+ Chef::Log.info("STOP requeschefm.")
loop do
# See if a run is in flight
if @service_action_mutex.try_lock
@@ -130,12 +131,12 @@ class Chef
break
else
unless run_warning_displayed
- Chef::Log.info("Currently a chef run is happening on this system.")
- Chef::Log.info("Service will stop when run is completed.")
+ Chef::Log.info("Currently a #{Chef::Dist::GENERIC} run is happening on this system.")
+ Chef::Log.info("Service will stop when run is completed.")
run_warning_displayed = true
end
- Chef::Log.trace("Waiting for chef-client run...")
+ Chef::Log.trace("Waiting for #{Chef::Dist::CLIENT} run...")
sleep 1
end
end
@@ -149,7 +150,7 @@ class Chef
# since this is a PAUSE signal.
if @service_action_mutex.locked?
- Chef::Log.info("Currently a chef-client run is happening.")
+ Chef::Log.info("Currently a #{Chef::Dist::CLIENT} run is happening.")
Chef::Log.info("Service will pause once it's completed.")
else
Chef::Log.info("Service is pausing....")
@@ -184,7 +185,7 @@ class Chef
# The log_location and config_file of the parent process is passed to the new chef-client process.
# We need to add the --no-fork, as by default it is set to fork=true.
- Chef::Log.info "Starting chef-client in a new process"
+ Chef::Log.info "Starting #{Chef::Dist::CLIENT} in a new process"
# Pass config params to the new process
config_params = " --no-fork"
config_params += " -c #{Chef::Config[:config_file]}" unless Chef::Config[:config_file].nil?
@@ -196,20 +197,20 @@ class Chef
# Starts a new process and waits till the process exits
result = shell_out(
- "chef-client.bat #{config_params}",
+ "#{Chef::Dist::CLIENT}.bat #{config_params}",
timeout: Chef::Config[:windows_service][:watchdog_timeout],
logger: Chef::Log
)
Chef::Log.trace (result.stdout).to_s
Chef::Log.trace (result.stderr).to_s
rescue Mixlib::ShellOut::CommandTimeout => e
- Chef::Log.error "chef-client timed out\n(#{e})"
+ Chef::Log.error "#{Chef::Dist::CLIENT} timed out\n(#{e})"
Chef::Log.error(<<-EOF)
- Your chef-client run timed out. You can increase the time chef-client is given
+ Your #{Chef::Dist::CLIENT} run timed out. You can increase the time #{Chef::Dist::CLIENT} is given
to complete by configuring windows_service.watchdog_timeout in your client.rb.
EOF
rescue Mixlib::ShellOut::ShellCommandFailed => e
- Chef::Log.warn "Not able to start chef-client in new process (#{e})"
+ Chef::Log.warn "Not able to start #{Chef::Dist::CLIENT} in new process (#{e})"
rescue => e
Chef::Log.error e
ensure