summaryrefslogtreecommitdiff
path: root/lib
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
parentf1a97f33d4b67645ed55ce6e15274d6adf396670 (diff)
downloadchef-33d1f9e3ad1013387a3b3a53d6969c905942b692.tar.gz
Replacing workmarks with distro constants
Signed-off-by: Marc Chamberland <mchamberland@pbsc.com>
Diffstat (limited to 'lib')
-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
-rw-r--r--lib/chef/client.rb15
-rw-r--r--lib/chef/dist.rb21
-rw-r--r--lib/chef/http/http_request.rb5
-rw-r--r--lib/chef/knife.rb37
-rw-r--r--lib/chef/knife/bootstrap/templates/chef-full.erb4
-rw-r--r--lib/chef/run_lock.rb3
-rw-r--r--lib/chef/shell.rb9
12 files changed, 114 insertions, 83 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
diff --git a/lib/chef/client.rb b/lib/chef/client.rb
index 40266df64d..0c4acc0a8d 100644
--- a/lib/chef/client.rb
+++ b/lib/chef/client.rb
@@ -54,6 +54,7 @@ require "chef/platform/rebooter"
require "chef/mixin/deprecation"
require "ohai"
require "rbconfig"
+require "chef/dist"
class Chef
# == Chef::Client
@@ -240,10 +241,10 @@ class Chef
events.run_start(Chef::VERSION, run_status)
- logger.info("*** Chef #{Chef::VERSION} ***")
+ logger.info("*** #{Chef::Dist::PRODUCT} #{Chef::VERSION} ***")
logger.info("Platform: #{RUBY_PLATFORM}")
- logger.info "Chef-client pid: #{Process.pid}"
- logger.debug("Chef-client request_id: #{request_id}")
+ logger.info "#{Chef::Dist::CLIENT.capitalize} pid: #{Process.pid}"
+ logger.debug("#{Chef::Dist::CLIENT.capitalize} request_id: #{request_id}")
enforce_path_sanity
run_ohai
@@ -262,7 +263,7 @@ class Chef
build_node
run_status.start_clock
- logger.info("Starting Chef Run for #{node.name}")
+ logger.info("Starting #{Chef::Dist::PRODUCT} Run for #{node.name}")
run_started
do_windows_admin_check
@@ -277,7 +278,7 @@ class Chef
converge_and_save(run_context)
run_status.stop_clock
- logger.info("Chef Run complete in #{run_status.elapsed_time} seconds")
+ logger.info("#{Chef::Dist::PRODUCT} Run complete in #{run_status.elapsed_time} seconds")
run_completed_successfully
events.run_completed(node, run_status)
@@ -715,7 +716,7 @@ class Chef
logger.trace("Checking for administrator privileges....")
if !has_admin_privileges?
- message = "chef-client doesn't have administrator privileges on node #{node_name}."
+ message = "#{Chef::Dist::CLIENT} doesn't have administrator privileges on node #{node_name}."
if Chef::Config[:fatal_windows_admin_check]
logger.fatal(message)
logger.fatal("fatal_windows_admin_check is set to TRUE.")
@@ -724,7 +725,7 @@ class Chef
logger.warn("#{message} This might cause unexpected resource failures.")
end
else
- logger.trace("chef-client has administrator privileges on node #{node_name}.")
+ logger.trace("#{Chef::Dist::CLIENT} has administrator privileges on node #{node_name}.")
end
end
end
diff --git a/lib/chef/dist.rb b/lib/chef/dist.rb
new file mode 100644
index 0000000000..bb69611e80
--- /dev/null
+++ b/lib/chef/dist.rb
@@ -0,0 +1,21 @@
+class Chef
+ class Dist
+ # When referencing a product directly, like Chef (Now Chef Infra)
+ PRODUCT = "Chef Infra".freeze
+
+ # The client's alias (chef-client)
+ CLIENT = "chef-client".freeze
+
+ # the server tool's name (knife)
+ KNIFE = "knife".freeze
+
+ # Name used for certain directories. Merge with chef_executable?
+ GENERIC = "chef".freeze
+
+ # The chef executable, as in `chef gem install` or `chef generate cookbook`
+ EXEC = "chef".freeze
+
+ # product website address
+ WEBSITE = "https://chef.io".freeze
+ end
+end
diff --git a/lib/chef/http/http_request.rb b/lib/chef/http/http_request.rb
index c38ac08133..7a84c07e2b 100644
--- a/lib/chef/http/http_request.rb
+++ b/lib/chef/http/http_request.rb
@@ -22,6 +22,7 @@
#
require "uri"
require "net/http"
+require "chef/dist"
# To load faster, we only want ohai's version string.
# However, in ohai before 0.6.0, the version is defined
@@ -40,8 +41,8 @@ class Chef
engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"
- UA_COMMON = "/#{::Chef::VERSION} (#{engine}-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}; ohai-#{Ohai::VERSION}; #{RUBY_PLATFORM}; +https://chef.io)".freeze
- DEFAULT_UA = "Chef Client" << UA_COMMON
+ UA_COMMON = "/#{::Chef::VERSION} (#{engine}-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}; ohai-#{Ohai::VERSION}; #{RUBY_PLATFORM}; +#{Chef::Dist::WEBSITE})".freeze
+ DEFAULT_UA = "#{Chef::Dist::PRODUCT} Client" << UA_COMMON
USER_AGENT = "User-Agent".freeze
diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb
index 2bb6169cc9..a1b1d66255 100644
--- a/lib/chef/knife.rb
+++ b/lib/chef/knife.rb
@@ -31,11 +31,12 @@ require "chef/http/authenticator"
require "chef/http/http_request"
require "chef/http"
require "pp"
+require "chef/dist"
class Chef
class Knife
- Chef::HTTP::HTTPRequest.user_agent = "Chef Knife#{Chef::HTTP::HTTPRequest::UA_COMMON}"
+ Chef::HTTP::HTTPRequest.user_agent = "#{Chef::Dist::PRODUCT} #{Chef::Dist::KNIFE} #{Chef::HTTP::HTTPRequest::UA_COMMON}"
include Mixlib::CLI
include Chef::Mixin::PathSanity
@@ -182,7 +183,7 @@ class Chef
config_loader.profile = profile
config_loader.load
- ui.warn("No knife configuration file found. See https://docs.chef.io/config_rb_knife.html for details.") if config_loader.no_config_found?
+ ui.warn("No config.rb (formerly #{Chef::Dist::KNIFE}.rb) configuration file found. See https://docs.chef.io/config_rb_knife.html for details.") if config_loader.no_config_found?
config_loader
rescue Exceptions::ConfigurationError => e
@@ -239,7 +240,7 @@ class Chef
class << self
def list_commands(preferred_category = nil)
category_desc = preferred_category ? preferred_category + " " : ""
- msg "Available #{category_desc}subcommands: (for details, knife SUB-COMMAND --help)\n\n"
+ msg "Available #{category_desc}subcommands: (for details, #{Chef::Dist::KNIFE} SUB-COMMAND --help)\n\n"
subcommand_loader.list_commands(preferred_category).sort.each do |category, commands|
next if category =~ /deprecated/i
msg "** #{category.upcase} COMMANDS **"
@@ -266,13 +267,13 @@ class Chef
# Mention rehash when the subcommands cache(plugin_manifest.json) is used
if subcommand_loader.is_a?(Chef::Knife::SubcommandLoader::HashedCommandLoader)
- ui.info("If this is a recently installed plugin, please run 'knife rehash' to update the subcommands cache.")
+ ui.info("If this is a recently installed plugin, please run '#{Chef::Dist::KNIFE} rehash' to update the subcommands cache.")
end
if category_commands = guess_category(args)
list_commands(category_commands)
elsif OFFICIAL_PLUGINS.include?(args[0]) # command was an uninstalled official chef knife plugin
- ui.info("Use `chef gem install knife-#{args[0]}` to install the plugin into ChefDK")
+ ui.info("Use `#{Chef::Dist::EXEC} gem install knife-#{args[0]}` to install the plugin into ChefDK")
else
list_commands
end
@@ -438,7 +439,7 @@ class Chef
def run_with_pretty_exceptions(raise_exception = false)
unless respond_to?(:run)
- ui.error "You need to add a #run method to your knife command before you can use it"
+ ui.error "You need to add a #run method to your #{Chef::Dist::KNIFE} command before you can use it"
end
enforce_path_sanity
maybe_setup_fips
@@ -459,17 +460,17 @@ class Chef
humanize_http_exception(e)
when OpenSSL::SSL::SSLError
ui.error "Could not establish a secure connection to the server."
- ui.info "Use `knife ssl check` to troubleshoot your SSL configuration."
- ui.info "If your Chef Server uses a self-signed certificate, you can use"
- ui.info "`knife ssl fetch` to make knife trust the server's certificates."
+ ui.info "Use `#{Chef::Dist::KNIFE} ssl check` to troubleshoot your SSL configuration."
+ ui.info "If your #{Chef::Dist::PRODUCT} Server uses a self-signed certificate, you can use"
+ ui.info "`#{Chef::Dist::KNIFE} ssl fetch` to make #{Chef::Dist::KNIFE} trust the server's certificates."
ui.info ""
ui.info "Original Exception: #{e.class.name}: #{e.message}"
when Errno::ECONNREFUSED, Timeout::Error, Errno::ETIMEDOUT, SocketError
ui.error "Network Error: #{e.message}"
- ui.info "Check your knife configuration and network settings"
+ ui.info "Check your #{Chef::Dist::KNIFE} configuration and network settings"
when NameError, NoMethodError
- ui.error "knife encountered an unexpected error"
- ui.info "This may be a bug in the '#{self.class.common_name}' knife command or plugin"
+ ui.error "#{Chef::Dist::KNIFE} encountered an unexpected error"
+ ui.info "This may be a bug in the '#{self.class.common_name}' #{Chef::Dist::KNIFE} command or plugin"
ui.info "Please collect the output of this command with the `-VVV` option before filing a bug report."
ui.info "Exception: #{e.class.name}: #{e.message}"
when Chef::Exceptions::PrivateKeyMissing
@@ -477,7 +478,7 @@ class Chef
ui.info "Check your configuration file and ensure that your private key is readable"
when Chef::Exceptions::InvalidRedirect
ui.error "Invalid Redirect: #{e.message}"
- ui.info "Change your server location in knife.rb to the server's FQDN to avoid unwanted redirections."
+ ui.info "Change your server location in config.rb (formerly #{Chef::Dist::KNIFE}.rb) to the server's FQDN to avoid unwanted redirections."
else
ui.error "#{e.class.name}: #{e.message}"
end
@@ -493,7 +494,7 @@ class Chef
ui.error "You authenticated successfully to #{server_url} as #{username} but you are not authorized for this action."
proxy_env_vars = ENV.to_hash.keys.map(&:downcase) & %w{http_proxy https_proxy ftp_proxy socks_proxy no_proxy}
unless proxy_env_vars.empty?
- ui.error "There are proxy servers configured, your Chef server may need to be added to NO_PROXY."
+ ui.error "There are proxy servers configured, your #{Chef::Dist::PRODUCT} server may need to be added to NO_PROXY."
end
ui.info "Response: #{format_rest_error(response)}"
when Net::HTTPBadRequest
@@ -516,10 +517,10 @@ class Chef
client_api_version = version_header["request_version"]
min_server_version = version_header["min_version"]
max_server_version = version_header["max_version"]
- ui.error "The version of Chef that Knife is using is not supported by the Chef server you sent this request to"
- ui.info "The request that Knife sent was using API version #{client_api_version}"
- ui.info "The Chef server you sent the request to supports a min API verson of #{min_server_version} and a max API version of #{max_server_version}"
- ui.info "Please either update your Chef client or server to be a compatible set"
+ ui.error "The version of #{Chef::Dist::PRODUCT} that #{Chef::Dist::KNIFE} is using is not supported by the #{Chef::Dist::PRODUCT} server you sent this request to"
+ ui.info "The request that #{Chef::Dist::KNIFE} sent was using API version #{client_api_version}"
+ ui.info "The #{Chef::Dist::PRODUCT} server you sent the request to supports a min API verson of #{min_server_version} and a max API version of #{max_server_version}"
+ ui.info "Please either update your #{Chef::Dist::PRODUCT} client or server to be a compatible set"
else
ui.error response.message
ui.info "Response: #{format_rest_error(response)}"
diff --git a/lib/chef/knife/bootstrap/templates/chef-full.erb b/lib/chef/knife/bootstrap/templates/chef-full.erb
index 094cca1c08..ec1f7e72c9 100644
--- a/lib/chef/knife/bootstrap/templates/chef-full.erb
+++ b/lib/chef/knife/bootstrap/templates/chef-full.erb
@@ -173,7 +173,7 @@ do_download() {
<% else %>
install_sh="<%= knife_config[:bootstrap_url] ? knife_config[:bootstrap_url] : "https://omnitruck.chef.io/chef/install.sh" %>"
if test -f /usr/bin/chef-client; then
- echo "-----> Existing Chef installation detected"
+ echo "-----> Existing <%= Chef::Dist::PRODUCT %> installation detected"
else
echo "-----> Installing Chef Omnibus (<%= latest_current_chef_version_string %>)"
do_download ${install_sh} $tmp_dir/install.sh
@@ -237,6 +237,6 @@ mkdir -p /etc/chef/client.d
<%= client_d %>
<% end -%>
-echo "Starting the first Chef Client run..."
+echo "Starting the first <%= Chef::Dist::PRODUCT %> Client run..."
<%= start_chef %>'
diff --git a/lib/chef/run_lock.rb b/lib/chef/run_lock.rb
index 08d58fd164..513bfd8849 100644
--- a/lib/chef/run_lock.rb
+++ b/lib/chef/run_lock.rb
@@ -23,6 +23,7 @@ end
require "chef/config"
require "chef/exceptions"
require "timeout"
+require "chef/dist"
class Chef
@@ -95,7 +96,7 @@ class Chef
# Waits until acquiring the system-wide lock.
#
def wait
- Chef::Log.warn("Chef client #{runpid} is running, will wait for it to finish and then run.")
+ Chef::Log.warn("#{Chef::Dist::PRODUCT} client #{runpid} is running, will wait for it to finish and then run.")
if Chef::Platform.windows?
mutex.wait
else
diff --git a/lib/chef/shell.rb b/lib/chef/shell.rb
index e717c3705e..f05e63b420 100644
--- a/lib/chef/shell.rb
+++ b/lib/chef/shell.rb
@@ -25,6 +25,7 @@ require "chef/version"
require "chef/client"
require "chef/config"
require "chef/config_fetcher"
+require "chef/dist"
require "chef/shell/shell_session"
require "chef/workstation_config_loader"
@@ -253,7 +254,7 @@ module Shell
option :client,
short: "-z",
long: "--client",
- description: "chef-client session",
+ description: "#{Chef::Dist::CLIENT} session",
boolean: true
option :solo_legacy_shell,
@@ -271,15 +272,15 @@ module Shell
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 :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,