diff options
120 files changed, 634 insertions, 530 deletions
@@ -27,6 +27,7 @@ begin require_relative "tasks/docs" require_relative "tasks/spellcheck" require_relative "lib/chef/dist" + require "chef-utils" rescue LoadError => e puts "Skipping missing rake dep: #{e}" end diff --git a/chef-bin/bin/chef-service-manager b/chef-bin/bin/chef-service-manager index 2575e23dc0..44e39a5bd3 100755 --- a/chef-bin/bin/chef-service-manager +++ b/chef-bin/bin/chef-service-manager @@ -21,13 +21,13 @@ $:.unshift(File.join(__dir__, "..", "lib")) require "chef" require "chef/application/windows_service_manager" -require "chef/dist" +require "chef-utils/dist/infra" if Chef::Platform.windows? chef_client_service = { - service_name: Chef::Dist::CLIENT, - service_display_name: "#{Chef::Dist::PRODUCT} Service", - service_description: "Runs #{Chef::Dist::PRODUCT} on regular, configurable intervals.", + service_name: ChefUtils::Dist::Infra::CLIENT, + service_display_name: "#{ChefUtils::Dist::Infra::PRODUCT} Service", + service_description: "Runs #{ChefUtils::Dist::Infra::PRODUCT} on regular, configurable intervals.", service_file_path: File.expand_path("../chef-windows-service", $PROGRAM_NAME), delayed_start: true, dependencies: ["Winmgmt"], diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb index 2c4323db82..1254911e35 100644 --- a/chef-config/lib/chef-config/config.rb +++ b/chef-config/lib/chef-config/config.rb @@ -36,7 +36,6 @@ autoload :URI, "uri" autoload :Addressable, "addressable/uri" autoload :OpenSSL, "openssl" autoload :YAML, "yaml" -require_relative "dist" module ChefConfig @@ -82,7 +81,7 @@ module ChefConfig # @return [String] the platform-specific path # def self.etc_chef_dir(windows: ChefUtils.windows?) - path = windows ? c_chef_dir : PathHelper.join("/etc", ChefConfig::Dist::DIR_SUFFIX, windows: windows) + path = windows ? c_chef_dir : PathHelper.join("/etc", ChefUtils::Dist::Infra::DIR_SUFFIX, windows: windows) PathHelper.cleanpath(path, windows: windows) end @@ -92,7 +91,7 @@ module ChefConfig # @return [String] the platform-specific path # def self.var_chef_dir(windows: ChefUtils.windows?) - path = windows ? c_chef_dir : PathHelper.join("/var", ChefConfig::Dist::DIR_SUFFIX, windows: windows) + path = windows ? c_chef_dir : PathHelper.join("/var", ChefUtils::Dist::Infra::DIR_SUFFIX, windows: windows) PathHelper.cleanpath(path, windows: windows) end @@ -114,7 +113,7 @@ module ChefConfig # def self.c_chef_dir(windows: ChefUtils.windows?) drive = windows_installation_drive || "C:" - PathHelper.join(drive, ChefConfig::Dist::DIR_SUFFIX, windows: windows) + PathHelper.join(drive, ChefUtils::Dist::Infra::DIR_SUFFIX, windows: windows) end # On windows, C:/opscode @@ -125,7 +124,7 @@ module ChefConfig # def self.c_opscode_dir(windows: ChefUtils.windows?) drive = windows_installation_drive || "C:" - PathHelper.join(drive, ChefConfig::Dist::LEGACY_CONF_DIR, ChefConfig::Dist::DIR_SUFFIX, windows: windows) + PathHelper.join(drive, ChefConfig::Dist::LEGACY_CONF_DIR, ChefUtils::Dist::Infra::DIR_SUFFIX, windows: windows) end # the drive where Chef is installed on a windows host. This is determined @@ -190,7 +189,7 @@ module ChefConfig if config_file PathHelper.dirname(PathHelper.canonical_path(config_file, false)) else - PathHelper.join(PathHelper.cleanpath(user_home), ChefConfig::Dist::USER_CONF_DIR, "") + PathHelper.join(PathHelper.cleanpath(user_home), ChefUtils::Dist::Infra::USER_CONF_DIR, "") end end @@ -269,7 +268,7 @@ module ChefConfig end path = new_path end - ChefConfig.logger.info("Auto-discovered #{ChefConfig::Dist::SHORT} repository at #{path}") + ChefConfig.logger.info("Auto-discovered #{ChefUtils::Dist::Infra::SHORT} repository at #{path}") path end @@ -398,7 +397,7 @@ module ChefConfig # If your `file_cache_path` resides on a NFS (or non-flock()-supporting # fs), it's recommended to set this to something like # '/tmp/chef-client-running.pid' - default(:lockfile) { PathHelper.join(file_cache_path, "#{ChefConfig::Dist::CLIENT}-running.pid") } + default(:lockfile) { PathHelper.join(file_cache_path, "#{ChefUtils::Dist::Infra::CLIENT}-running.pid") } ## Daemonization Settings ## # What user should Chef run as? @@ -795,7 +794,7 @@ module ChefConfig if chef_server_url.to_s =~ %r{/organizations/(.*)$} "#{$1}-validator" else - "#{ChefConfig::Dist::SHORT}-validator" + "#{ChefUtils::Dist::Infra::SHORT}-validator" end end @@ -869,7 +868,7 @@ module ChefConfig default :profile, nil default :chef_guid_path do - PathHelper.join(config_dir, "#{ChefConfig::Dist::SHORT}_guid") + PathHelper.join(config_dir, "#{ChefUtils::Dist::Infra::SHORT}_guid") end default :chef_guid, nil @@ -1078,7 +1077,7 @@ module ChefConfig # generated by the DataCollector when Chef is run in Solo mode. This # allows users to associate their Solo nodes with faux organizations # without the nodes being connected to an actual Chef Server. - default :organization, "#{ChefConfig::Dist::SHORT}_solo" + default :organization, "#{ChefUtils::Dist::Infra::SHORT}_solo" end configurable(:http_proxy) diff --git a/chef-config/lib/chef-config/mixin/credentials.rb b/chef-config/lib/chef-config/mixin/credentials.rb index de004a062f..b7c83a7611 100644 --- a/chef-config/lib/chef-config/mixin/credentials.rb +++ b/chef-config/lib/chef-config/mixin/credentials.rb @@ -36,7 +36,7 @@ module ChefConfig # normally set via a command-line option. # @return [String] def credentials_profile(profile = nil) - context_file = PathHelper.home(ChefConfig::Dist::USER_CONF_DIR, "context").freeze + context_file = PathHelper.home(ChefUtils::Dist::Infra::USER_CONF_DIR, "context").freeze if !profile.nil? profile elsif ENV.include?("CHEF_PROFILE") @@ -53,7 +53,7 @@ module ChefConfig # @since 14.4 # @return [String] def credentials_file_path - PathHelper.home(ChefConfig::Dist::USER_CONF_DIR, "credentials").freeze + PathHelper.home(ChefUtils::Dist::Infra::USER_CONF_DIR, "credentials").freeze end # Load and parse the credentials file. diff --git a/chef-config/lib/chef-config/workstation_config_loader.rb b/chef-config/lib/chef-config/workstation_config_loader.rb index 4e44a24fd7..8f481a7a89 100644 --- a/chef-config/lib/chef-config/workstation_config_loader.rb +++ b/chef-config/lib/chef-config/workstation_config_loader.rb @@ -59,7 +59,7 @@ module ChefConfig @chef_config_dir = false full_path = working_directory.split(File::SEPARATOR) (full_path.length - 1).downto(0) do |i| - candidate_directory = File.join(full_path[0..i] + [ChefConfig::Dist::USER_CONF_DIR]) + candidate_directory = File.join(full_path[0..i] + [ChefUtils::Dist::Infra::USER_CONF_DIR]) if File.exist?(candidate_directory) && File.directory?(candidate_directory) @chef_config_dir = candidate_directory break @@ -129,7 +129,7 @@ module ChefConfig candidate_configs << File.join(chef_config_dir, "knife.rb") end # Look for $HOME/.chef/knife.rb - PathHelper.home(ChefConfig::Dist::USER_CONF_DIR) do |dot_chef_dir| + PathHelper.home(ChefUtils::Dist::Infra::USER_CONF_DIR) do |dot_chef_dir| candidate_configs << File.join(dot_chef_dir, "config.rb") candidate_configs << File.join(dot_chef_dir, "knife.rb") end @@ -184,7 +184,7 @@ module ChefConfig end def home_chef_dir - @home_chef_dir ||= PathHelper.home(ChefConfig::Dist::USER_CONF_DIR) + @home_chef_dir ||= PathHelper.home(ChefUtils::Dist::Infra::USER_CONF_DIR) end def apply_config(config_content, config_file_path) diff --git a/chef-utils/lib/chef-utils.rb b/chef-utils/lib/chef-utils.rb index c1b06ed3fb..5cf80ddde4 100644 --- a/chef-utils/lib/chef-utils.rb +++ b/chef-utils/lib/chef-utils.rb @@ -30,6 +30,7 @@ require_relative "chef-utils/dsl/virtualization" require_relative "chef-utils/dsl/which" require_relative "chef-utils/dsl/windows" require_relative "chef-utils/mash" +require_relative "chef-utils/dist" # This is the Chef Infra Client DSL, not everything needs to go in here module ChefUtils diff --git a/chef-utils/lib/chef-utils/dist.rb b/chef-utils/lib/chef-utils/dist.rb new file mode 100644 index 0000000000..a45dd9d64b --- /dev/null +++ b/chef-utils/lib/chef-utils/dist.rb @@ -0,0 +1,25 @@ +# Copyright:: Copyright (c) Chef Software Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +require_relative "dist/org" +require_relative "dist/infra" +require_relative "dist/apply" +require_relative "dist/automate" +require_relative "dist/compliance" +require_relative "dist/inspec" +require_relative "dist/run" +require_relative "dist/server" +require_relative "dist/solo" +require_relative "dist/workstation" +require_relative "dist/zero" diff --git a/chef-utils/lib/chef-utils/dist/apply.rb b/chef-utils/lib/chef-utils/dist/apply.rb new file mode 100644 index 0000000000..d4ef297510 --- /dev/null +++ b/chef-utils/lib/chef-utils/dist/apply.rb @@ -0,0 +1,10 @@ +module ChefUtils + module Dist + class Apply + # The chef-apply product name + PRODUCT = "Chef Infra Apply".freeze + # The chef-apply binary + EXEC = "chef-apply".freeze + end + end +end diff --git a/chef-utils/lib/chef-utils/dist/automate.rb b/chef-utils/lib/chef-utils/dist/automate.rb new file mode 100644 index 0000000000..bcdd5673bd --- /dev/null +++ b/chef-utils/lib/chef-utils/dist/automate.rb @@ -0,0 +1,7 @@ +module ChefUtils + module Dist + class Automate + PRODUCT = "Chef Automate".freeze + end + end +end diff --git a/chef-utils/lib/chef-utils/dist/compliance.rb b/chef-utils/lib/chef-utils/dist/compliance.rb new file mode 100644 index 0000000000..0f73194eb9 --- /dev/null +++ b/chef-utils/lib/chef-utils/dist/compliance.rb @@ -0,0 +1,7 @@ +module ChefUtils + module Dist + class Compliance + PRODUCT = "Chef Compliance".freeze + end + end +end diff --git a/chef-utils/lib/chef-utils/dist/infra.rb b/chef-utils/lib/chef-utils/dist/infra.rb new file mode 100644 index 0000000000..7b2c4e6fa7 --- /dev/null +++ b/chef-utils/lib/chef-utils/dist/infra.rb @@ -0,0 +1,42 @@ +module ChefUtils + module Dist + class Infra + # When referencing a product directly, as in "Chef Infra" + PRODUCT = "Chef Infra Client".freeze + + # The chef-main-wrapper executable name. + EXEC = "chef".freeze + + # The client's alias (chef-client) + CLIENT = "chef-client".freeze + + # A short name for the product + SHORT = "chef".freeze + + # The suffix for Chef's /etc/chef, /var/chef and C:\\Chef directories + # "cinc" => /etc/cinc, /var/cinc, C:\\cinc + DIR_SUFFIX = "chef".freeze + + # The user's configuration directory + USER_CONF_DIR = ".chef".freeze + + # chef-shell executable + SHELL = "chef-shell".freeze + + # The chef-shell default configuration file + SHELL_CONF ="chef_shell.rb".freeze + + # chef-zero executable + ZERO = "Chef Infra Zero".freeze + + # Chef-Solo's product name + SOLO = "Chef Infra Solo".freeze + + # The chef-zero executable (local mode) + ZEROEXEC = "chef-zero".freeze + + # The chef-solo executable (legacy local mode) + SOLOEXEC = "chef-solo".freeze + end + end +end diff --git a/chef-utils/lib/chef-utils/dist/inspec.rb b/chef-utils/lib/chef-utils/dist/inspec.rb new file mode 100644 index 0000000000..a2204b9674 --- /dev/null +++ b/chef-utils/lib/chef-utils/dist/inspec.rb @@ -0,0 +1,11 @@ +module ChefUtils + module Dist + class Inspec + PRODUCT = "Chef Inspec".freeze + + EXEC = "inspec".freeze + + DIR_SUFFIX = "inspec".freeze + end + end +end diff --git a/chef-utils/lib/chef-utils/dist/org.rb b/chef-utils/lib/chef-utils/dist/org.rb new file mode 100644 index 0000000000..69cc2771e5 --- /dev/null +++ b/chef-utils/lib/chef-utils/dist/org.rb @@ -0,0 +1,15 @@ +module ChefUtils + module Dist + class Org + # Main Website address + WEBSITE = "https://chef.io".freeze + + # The downloads site + DOWNLOADS_URL = "downloads.chef.io".freeze + + # The legacy conf folder: C:/opscode/chef. Specifically the "opscode" part + # DIR_SUFFIX is appended to it in code where relevant + LEGACY_CONF_DIR = "opscode".freeze + end + end +end diff --git a/chef-utils/lib/chef-utils/dist/run.rb b/chef-utils/lib/chef-utils/dist/run.rb new file mode 100644 index 0000000000..0045b405d2 --- /dev/null +++ b/chef-utils/lib/chef-utils/dist/run.rb @@ -0,0 +1,11 @@ +module ChefUtils + module Dist + class Run + # chef-run's product name + PRODUCT = "Chef Infra Run".freeze + + # The chef-run binary + EXEC = "chef-run".freeze + end + end +end diff --git a/chef-utils/lib/chef-utils/dist/server.rb b/chef-utils/lib/chef-utils/dist/server.rb new file mode 100644 index 0000000000..797f0efbf2 --- /dev/null +++ b/chef-utils/lib/chef-utils/dist/server.rb @@ -0,0 +1,12 @@ +module ChefUtils + module Dist + class Server + # The name of the server product + PRODUCT = "Chef Infra Server".freeze + + # Assumed location of the chef-server configuration directory + # TODO: This actually sounds like a job for ChefUtils methods + CONF_DIR = "/etc/chef-server".freeze + end + end +end diff --git a/chef-utils/lib/chef-utils/dist/solo.rb b/chef-utils/lib/chef-utils/dist/solo.rb new file mode 100644 index 0000000000..8b3ee9c9d5 --- /dev/null +++ b/chef-utils/lib/chef-utils/dist/solo.rb @@ -0,0 +1,11 @@ +module ChefUtils + module Dist + class Solo + # Chef-Solo's product name + PRODUCT = "Chef Infra Solo".freeze + + # The chef-solo executable (legacy local mode) + EXEC = "chef-solo".freeze + end + end +end diff --git a/chef-utils/lib/chef-utils/dist/workstation.rb b/chef-utils/lib/chef-utils/dist/workstation.rb new file mode 100644 index 0000000000..c8725dd86d --- /dev/null +++ b/chef-utils/lib/chef-utils/dist/workstation.rb @@ -0,0 +1,17 @@ +module ChefUtils + module Dist + class Workstation + # The Workstation's product name + PRODUCT = "Chef Workstation".freeze + + # The old ChefDK product name + DK = "ChefDK".freeze + + # The suffix for workstation's eponymous folders, like /opt/workstation + DIR_SUFFIX = "chef-workstation".freeze + + # The suffix for ChefDK's eponymous folders, like /opt/chef-dk + LEGACY_DIR_SUFFIX = "chef-dk".freeze + end + end +end diff --git a/chef-utils/lib/chef-utils/dist/zero.rb b/chef-utils/lib/chef-utils/dist/zero.rb new file mode 100644 index 0000000000..74d2b8132c --- /dev/null +++ b/chef-utils/lib/chef-utils/dist/zero.rb @@ -0,0 +1,11 @@ +module ChefUtils + module Dist + class Zero + # chef-zero executable + PRODUCT = "Chef Infra Zero".freeze + + # The chef-zero executable (local mode) + EXEC = "chef-zero".freeze + end + end +end diff --git a/distro/templates/powershell/chef/chef.psm1.erb b/distro/templates/powershell/chef/chef.psm1.erb index f8b24dc54b..35344d907d 100644 --- a/distro/templates/powershell/chef/chef.psm1.erb +++ b/distro/templates/powershell/chef/chef.psm1.erb @@ -412,40 +412,40 @@ function Run-RubyCommand($command, $argList) { } -function <%= Chef::Dist::APPLY %> { - Run-RubyCommand '<%= Chef::Dist::APPLY %>' $args +function <%= ChefUtils::Dist::Apply::EXEC %> { + Run-RubyCommand '<%= ChefUtils::Dist::Apply::EXEC %>' $args } -function <%= Chef::Dist::CLIENT %> { - Run-RubyCommand '<%= Chef::Dist::CLIENT %>' $args +function <%= ChefUtils::Dist::Infra::CLIENT %> { + Run-RubyCommand '<%= ChefUtils::Dist::Infra::CLIENT %>' $args } -function <%= Chef::Dist::EXEC %>-service-manager { - Run-RubyCommand '<%= Chef::Dist::EXEC %>-service-manager' $args +function <%= ChefUtils::Dist::Infra::EXEC %>-service-manager { + Run-RubyCommand '<%= ChefUtils::Dist::Infra::EXEC %>-service-manager' $args } -function <%= Chef::Dist::SHELL %> { - Run-RubyCommand '<%= Chef::Dist::SHELL %>' $args +function <%= ChefUtils::Dist::Infra::SHELL %> { + Run-RubyCommand '<%= ChefUtils::Dist::Infra::SHELL %>' $args } -function <%= Chef::Dist::SOLOEXEC %> { - Run-RubyCommand '<%= Chef::Dist::SOLOEXEC %>' $args +function <%= ChefUtils::Dist::Solo::EXEC %> { + Run-RubyCommand '<%= ChefUtils::Dist::Solo::EXEC %>' $args } -function <%= Chef::Dist::EXEC %>-windows-service { - Run-RubyCommand '<%= Chef::Dist::EXEC %>-windows-service' $args +function <%= ChefUtils::Dist::Infra::EXEC %>-windows-service { + Run-RubyCommand '<%= ChefUtils::Dist::Infra::EXEC %>-windows-service' $args } function knife { Run-RubyCommand 'knife' $args } -Export-ModuleMember -function <%= Chef::Dist::APPLY %> -Export-ModuleMember -function <%= Chef::Dist::CLIENT %> -Export-ModuleMember -function <%= Chef::Dist::EXEC %>-service-manager -Export-ModuleMember -function <%= Chef::Dist::SHELL %> -Export-ModuleMember -function <%= Chef::Dist::SOLOEXEC %> -Export-ModuleMember -function <%= Chef::Dist::EXEC %>-windows-service +Export-ModuleMember -function <%= ChefUtils::Dist::Apply::EXEC %> +Export-ModuleMember -function <%= ChefUtils::Dist::Infra::CLIENT %> +Export-ModuleMember -function <%= ChefUtils::Dist::Infra::EXEC %>-service-manager +Export-ModuleMember -function <%= ChefUtils::Dist::Infra::SHELL %> +Export-ModuleMember -function <%= ChefUtils::Dist::Solo::EXEC %> +Export-ModuleMember -function <%= ChefUtils::Dist::Infra::EXEC %>-windows-service Export-ModuleMember -function knife # To debug this module, uncomment the line below diff --git a/ext/win32-eventlog/Rakefile b/ext/win32-eventlog/Rakefile index 2cf1a40896..8d681611d3 100644 --- a/ext/win32-eventlog/Rakefile +++ b/ext/win32-eventlog/Rakefile @@ -2,7 +2,7 @@ require "rubygems" require "rake" require "mkmf" require "erb" -require_relative "../../lib/chef/dist" +require_relative "../../chef-utils/lib/chef-utils/dist" desc "Building event log dll" @@ -51,7 +51,7 @@ task register: EVT_SHARED_OBJECT do begin Win32::EventLog.add_event_source( source: "Application", - key_name: Chef::Dist::SHORT, + key_name: ChefUtils::Dist::Infra::SHORT, event_message_file: dll_file, category_message_file: dll_file ) diff --git a/ext/win32-eventlog/chef-log.man.erb b/ext/win32-eventlog/chef-log.man.erb index 2e767a8cfe..83be49b4d2 100644 --- a/ext/win32-eventlog/chef-log.man.erb +++ b/ext/win32-eventlog/chef-log.man.erb @@ -1,25 +1,25 @@ MessageId=10000 SymbolicName=RUN_START Language=English -Starting <%= Chef::Dist::PRODUCT %> run v%1 +Starting <%= ChefUtils::Dist::Infra::PRODUCT %> run v%1 . MessageId=10001 SymbolicName=RUN_STARTED Language=English -Started <%= Chef::Dist::PRODUCT %> run %1 +Started <%= ChefUtils::Dist::Infra::PRODUCT %> run %1 . MessageId=10002 SymbolicName=RUN_COMPLETED Language=English -Completed <%= Chef::Dist::PRODUCT %> run %1 in %2 seconds +Completed <%= ChefUtils::Dist::Infra::PRODUCT %> run %1 in %2 seconds . MessageId=10003 SymbolicName=RUN_FAILED Language=English -Failed <%= Chef::Dist::PRODUCT %> run %1 in %2 seconds.%n +Failed <%= ChefUtils::Dist::Infra::PRODUCT %> run %1 in %2 seconds.%n Exception type: %3%n Exception message: %4%n Exception backtrace: %5%n diff --git a/lib/chef/application.rb b/lib/chef/application.rb index 599ec67bc0..2b4da2720f 100644 --- a/lib/chef/application.rb +++ b/lib/chef/application.rb @@ -27,7 +27,7 @@ require "mixlib/cli" unless defined?(Mixlib::CLI) require "tmpdir" unless defined?(Dir.mktmpdir) require "rbconfig" unless defined?(RbConfig) require_relative "application/exit_code" -require_relative "dist" +require "chef-utils" module LicenseAcceptance autoload :Acceptor, "license_acceptance/acceptor" end @@ -307,7 +307,7 @@ class Chef end def fork_chef_client - logger.info "Forking #{Chef::Dist::PRODUCT} instance to converge..." + logger.info "Forking #{ChefUtils::Dist::Infra::PRODUCT} instance to converge..." pid = fork do # Want to allow forked processes to finish converging when # TERM singal is received (exit gracefully) @@ -316,7 +316,7 @@ class Chef " finishing converge to exit normally (send SIGINT to terminate immediately)") end - client_solo = chef_config[:solo] ? Chef::Dist::SOLOEXEC : Chef::Dist::CLIENT + client_solo = chef_config[:solo] ? ChefUtils::Dist::Solo::EXEC : ChefUtils::Dist::Infra::CLIENT $0 = "#{client_solo} worker: ppid=#{Process.ppid};start=#{Time.new.strftime("%R:%S")};" begin logger.trace "Forked instance now converging" @@ -328,7 +328,7 @@ class Chef exit 0 end end - logger.trace "Fork successful. Waiting for new #{Chef::Dist::CLIENT} pid: #{pid}" + logger.trace "Fork successful. Waiting for new #{ChefUtils::Dist::Infra::CLIENT} pid: #{pid}" result = Process.waitpid2(pid) handle_child_exit(result) logger.trace "Forked instance successfully reaped (pid: #{pid})" @@ -340,9 +340,9 @@ class Chef return true if status.success? message = if status.signaled? - "#{Chef::Dist::PRODUCT} run process terminated by signal #{status.termsig} (#{Signal.list.invert[status.termsig]})" + "#{ChefUtils::Dist::Infra::PRODUCT} run process terminated by signal #{status.termsig} (#{Signal.list.invert[status.termsig]})" else - "#{Chef::Dist::PRODUCT} run process exited unsuccessfully (exit code #{status.exitstatus})" + "#{ChefUtils::Dist::Infra::PRODUCT} run process exited unsuccessfully (exit code #{status.exitstatus})" end raise Exceptions::ChildConvergeError, message end @@ -375,8 +375,8 @@ class Chef chef_stacktrace_out = "Generated at #{Time.now}\n" chef_stacktrace_out += message - Chef::FileCache.store("#{Chef::Dist::SHORT}-stacktrace.out", chef_stacktrace_out) - logger.fatal("Stacktrace dumped to #{Chef::FileCache.load("#{Chef::Dist::SHORT}-stacktrace.out", false)}") + Chef::FileCache.store("#{ChefUtils::Dist::Infra::SHORT}-stacktrace.out", chef_stacktrace_out) + logger.fatal("Stacktrace dumped to #{Chef::FileCache.load("#{ChefUtils::Dist::Infra::SHORT}-stacktrace.out", false)}") logger.fatal("Please provide the contents of the stacktrace.out file if you file a bug report") if Chef::Config[:always_dump_stacktrace] logger.fatal(message) diff --git a/lib/chef/application/apply.rb b/lib/chef/application/apply.rb index 83e28880f9..3641f7a3f3 100644 --- a/lib/chef/application/apply.rb +++ b/lib/chef/application/apply.rb @@ -27,13 +27,13 @@ require "fileutils" unless defined?(FileUtils) require "tempfile" unless defined?(Tempfile) require_relative "../providers" require_relative "../resources" -require_relative "../dist" +require "chef-utils" require "license_acceptance/cli_flags/mixlib_cli" class Chef::Application::Apply < Chef::Application include LicenseAcceptance::CLIFlags::MixlibCLI - banner "Usage: #{Chef::Dist::APPLY} [RECIPE_FILE | -e RECIPE_TEXT | -s] [OPTIONS]" + banner "Usage: #{ChefUtils::Dist::Apply::EXEC} [RECIPE_FILE | -e RECIPE_TEXT | -s] [OPTIONS]" option :execute, short: "-e RECIPE_TEXT", @@ -100,9 +100,9 @@ class Chef::Application::Apply < Chef::Application option :version, short: "-v", long: "--version", - description: "Show #{Chef::Dist::PRODUCT} version.", + description: "Show #{ChefUtils::Dist::Infra::PRODUCT} version.", boolean: true, - proc: lambda { |v| puts "#{Chef::Dist::PRODUCT}: #{::Chef::VERSION}" }, + proc: lambda { |v| puts "#{ChefUtils::Dist::Infra::PRODUCT}: #{::Chef::VERSION}" }, exit: 0 option :why_run, @@ -119,7 +119,7 @@ class Chef::Application::Apply < Chef::Application option :profile_ruby, long: "--[no-]profile-ruby", - description: "Dump complete Ruby call graph stack of entire #{Chef::Dist::PRODUCT} run (expert only).", + description: "Dump complete Ruby call graph stack of entire #{ChefUtils::Dist::Infra::PRODUCT} run (expert only).", boolean: true, default: false @@ -131,7 +131,7 @@ class Chef::Application::Apply < Chef::Application option :minimal_ohai, long: "--minimal-ohai", - description: "Only run the bare minimum Ohai plugins #{Chef::Dist::PRODUCT} needs to function.", + description: "Only run the bare minimum Ohai plugins #{ChefUtils::Dist::Infra::PRODUCT} needs to function.", boolean: true attr_reader :json_attribs @@ -181,7 +181,7 @@ class Chef::Application::Apply < Chef::Application else Chef::RunContext.new(@chef_client.node, {}, @chef_client.events) end - recipe = Chef::Recipe.new("(#{Chef::Dist::APPLY} cookbook)", "(#{Chef::Dist::APPLY} recipe)", run_context) + recipe = Chef::Recipe.new("(#{ChefUtils::Dist::Apply::EXEC} cookbook)", "(#{ChefUtils::Dist::Apply::EXEC} recipe)", run_context) [recipe, run_context] end diff --git a/lib/chef/application/base.rb b/lib/chef/application/base.rb index 738788fa96..e79f68345f 100644 --- a/lib/chef/application/base.rb +++ b/lib/chef/application/base.rb @@ -20,7 +20,7 @@ require_relative "../log" require_relative "../config" require_relative "../mixin/shell_out" require_relative "../config_fetcher" -require_relative "../dist" +require "chef-utils/dist" require_relative "../daemon" require "chef-config/mixin/dot_d" require "license_acceptance/cli_flags/mixlib_cli" @@ -57,7 +57,7 @@ class Chef::Application::Base < Chef::Application option :once, long: "--once", - description: "Cancel any interval or splay options, run #{Chef::Dist::PRODUCT} once and exit.", + description: "Cancel any interval or splay options, run #{ChefUtils::Dist::Infra::PRODUCT} once and exit.", boolean: true option :formatter, @@ -80,7 +80,7 @@ class Chef::Application::Base < Chef::Application option :profile_ruby, long: "--[no-]profile-ruby", - description: "Dump complete Ruby call graph stack of entire #{Chef::Dist::PRODUCT} run (expert only).", + description: "Dump complete Ruby call graph stack of entire #{ChefUtils::Dist::Infra::PRODUCT} run (expert only).", boolean: true, default: false @@ -136,7 +136,7 @@ class Chef::Application::Base < Chef::Application option :interval, short: "-i SECONDS", long: "--interval SECONDS", - description: "Run #{Chef::Dist::PRODUCT} periodically, in seconds.", + description: "Run #{ChefUtils::Dist::Infra::PRODUCT} periodically, in seconds.", proc: lambda { |s| s.to_i } option :json_attribs, @@ -160,12 +160,12 @@ class Chef::Application::Base < Chef::Application option :environment, short: "-E ENVIRONMENT", long: "--environment ENVIRONMENT", - description: "Set the #{Chef::Dist::PRODUCT} environment on the node." + description: "Set the #{ChefUtils::Dist::Infra::PRODUCT} environment on the node." option :client_fork, short: "-f", long: "--[no-]fork", - description: "Fork #{Chef::Dist::PRODUCT} process." + description: "Fork #{ChefUtils::Dist::Infra::PRODUCT} process." option :why_run, short: "-W", @@ -192,14 +192,14 @@ class Chef::Application::Base < Chef::Application option :version, short: "-v", long: "--version", - description: "Show #{Chef::Dist::PRODUCT} version.", + description: "Show #{ChefUtils::Dist::Infra::PRODUCT} version.", boolean: true, - proc: lambda { |v| puts "#{Chef::Dist::PRODUCT}: #{::Chef::VERSION}" }, + proc: lambda { |v| puts "#{ChefUtils::Dist::Infra::PRODUCT}: #{::Chef::VERSION}" }, exit: 0 option :minimal_ohai, long: "--minimal-ohai", - description: "Only run the bare minimum Ohai plugins #{Chef::Dist::PRODUCT} needs to function.", + description: "Only run the bare minimum Ohai plugins #{ChefUtils::Dist::Infra::PRODUCT} needs to function.", boolean: true option :delete_entire_chef_repo, @@ -215,7 +215,7 @@ class Chef::Application::Base < Chef::Application option :target, short: "-t TARGET", long: "--target TARGET", - description: "Target #{Chef::Dist::PRODUCT} against a remote system or device", + description: "Target #{ChefUtils::Dist::Infra::PRODUCT} against a remote system or device", proc: lambda { |target| Chef::Log.warn "-- EXPERIMENTAL -- Target mode activated, resources and dsl may change without warning -- EXPERIMENTAL --" target @@ -230,7 +230,7 @@ class Chef::Application::Base < Chef::Application option :fatal_windows_admin_check, short: "-A", long: "--fatal-windows-admin-check", - description: "Fail the run when #{Chef::Dist::CLIENT} doesn't have administrator privileges on Windows.", + description: "Fail the run when #{ChefUtils::Dist::Infra::CLIENT} doesn't have administrator privileges on Windows.", boolean: true end @@ -247,7 +247,7 @@ class Chef::Application::Base < Chef::Application option :chef_server_url, short: "-S CHEFSERVERURL", long: "--server CHEFSERVERURL", - description: "The #{Chef::Dist::SERVER_PRODUCT} URL.", + description: "The #{ChefUtils::Dist::Server::PRODUCT} URL.", proc: nil option :validation_key, @@ -265,7 +265,7 @@ class Chef::Application::Base < Chef::Application option :enable_reporting, short: "-R", long: "--enable-reporting", - description: "(#{Chef::Dist::CLIENT} only) reporting data collection for runs.", + description: "(#{ChefUtils::Dist::Infra::CLIENT} only) reporting data collection for runs.", boolean: true option :local_mode, @@ -276,11 +276,11 @@ class Chef::Application::Base < Chef::Application option :chef_zero_host, long: "--chef-zero-host HOST", - description: "Host to start #{Chef::Dist::ZERO} on." + description: "Host to start #{ChefUtils::Dist::Zero::PRODUCT} on." option :chef_zero_port, long: "--chef-zero-port PORT", - description: "Port (or port range) to start #{Chef::Dist::ZERO} on. Port ranges like 1000,1010 or 8889-9999 will try all given ports until one works." + description: "Port (or port range) to start #{ChefUtils::Dist::Zero::PRODUCT} on. Port ranges like 1000,1010 or 8889-9999 will try all given ports until one works." option :listen, long: "--[no-]listen", @@ -289,7 +289,7 @@ class Chef::Application::Base < Chef::Application option :skip_cookbook_sync, long: "--[no-]skip-cookbook-sync", - description: "(#{Chef::Dist::CLIENT} only) Use cached cookbooks without overwriting local differences from the #{Chef::Dist::SERVER_PRODUCT}.", + description: "(#{ChefUtils::Dist::Infra::CLIENT} only) Use cached cookbooks without overwriting local differences from the #{ChefUtils::Dist::Server::PRODUCT}.", boolean: false option :named_run_list, @@ -328,7 +328,7 @@ class Chef::Application::Base < Chef::Application # Run the chef client, optionally daemonizing or looping at intervals. def run_application if Chef::Config[:version] - puts "#{Chef::Dist::PRODUCT} version: #{::Chef::VERSION}" + puts "#{ChefUtils::Dist::Infra::PRODUCT} version: #{::Chef::VERSION}" end if !Chef::Config[:client_fork] || Chef::Config[:once] @@ -348,17 +348,17 @@ class Chef::Application::Base < Chef::Application private def windows_interval_error_message - "Windows #{Chef::Dist::PRODUCT} interval runs are not supported in #{Chef::Dist::PRODUCT} 15 and later." + + "Windows #{ChefUtils::Dist::Infra::PRODUCT} interval runs are not supported in #{ChefUtils::Dist::Infra::PRODUCT} 15 and later." + "\nConfiguration settings:" + ("\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]).to_s + - "\nPlease manage #{Chef::Dist::PRODUCT} as a scheduled task instead." + "\nPlease manage #{ChefUtils::Dist::Infra::PRODUCT} as a scheduled task instead." end def unforked_interval_error_message - "Unforked #{Chef::Dist::PRODUCT} interval runs are disabled by default." + + "Unforked #{ChefUtils::Dist::Infra::PRODUCT} interval runs are disabled by default." + "\nConfiguration settings:" + ("\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]).to_s + - "\nEnable #{Chef::Dist::PRODUCT} interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options." + "\nEnable #{ChefUtils::Dist::Infra::PRODUCT} 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) @@ -380,7 +380,7 @@ class Chef::Application::Base < Chef::Application def interval_run_chef_client if Chef::Config[:daemonize] - Chef::Daemon.daemonize(Chef::Dist::PRODUCT) + Chef::Daemon.daemonize(ChefUtils::Dist::Infra::PRODUCT) # Start first daemonized run after configured number of seconds if Chef::Config[:daemonize].is_a?(Integer) diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb index 03ceff1727..70477722f4 100644 --- a/lib/chef/application/client.rb +++ b/lib/chef/application/client.rb @@ -50,7 +50,7 @@ class Chef::Application::Client < Chef::Application::Base 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.", + description: "Set the PID file location, for the #{ChefUtils::Dist::Infra::CLIENT} daemon process. Defaults to /tmp/chef-client.pid.", proc: nil option :runlist, @@ -105,7 +105,7 @@ class Chef::Application::Client < Chef::Application::Base tarball_path = File.join(Chef::Config.chef_repo_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: /^\.$/) - config_path = File.join(Chef::Config.chef_repo_path, "#{Chef::Dist::USER_CONF_DIR}/config.rb") + config_path = File.join(Chef::Config.chef_repo_path, "#{ChefUtils::Dist::Infra::USER_CONF_DIR}/config.rb") Chef::Config.from_string(IO.read(config_path), config_path) if File.file?(config_path) end end @@ -152,7 +152,7 @@ class Chef::Application::Client < Chef::Application::Base 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") + config[:config_file] = "#{ChefConfig::Config.etc_chef_dir}/client.rb" end end diff --git a/lib/chef/application/exit_code.rb b/lib/chef/application/exit_code.rb index ee0621f5ce..ed83d51b59 100644 --- a/lib/chef/application/exit_code.rb +++ b/lib/chef/application/exit_code.rb @@ -22,7 +22,7 @@ class Chef # These are the exit codes defined in Chef RFC 062 # https://github.com/chef/chef-rfc/blob/master/rfc062-exit-status.md class ExitCode - require_relative "../dist" + require "chef-utils" # -1 is defined as DEPRECATED_FAILURE in RFC 062, so it is # not enumerated in an active constant. @@ -153,9 +153,9 @@ class Chef end def non_standard_exit_code_warning(exit_code) - "#{Chef::Dist::CLIENT} attempted to exit with a non-standard exit code of #{exit_code}." \ - " The #{Chef::Dist::PRODUCT} Exit Codes design document (https://github.com/chef/chef-rfc/blob/master/rfc062-exit-status.md)" \ - " defines the exit codes that should be used with #{Chef::Dist::CLIENT}. Chef::Application::ExitCode defines" \ + "#{ChefUtils::Dist::Infra::CLIENT} attempted to exit with a non-standard exit code of #{exit_code}." \ + " The #{ChefUtils::Dist::Infra::PRODUCT} Exit Codes design document (https://github.com/chef/chef-rfc/blob/master/rfc062-exit-status.md)" \ + " defines the exit codes that should be used with #{ChefUtils::Dist::Infra::CLIENT}. Chef::Application::ExitCode defines" \ " valid exit codes Non-standard exit codes are redefined as GENERIC_FAILURE." end diff --git a/lib/chef/application/knife.rb b/lib/chef/application/knife.rb index e8acb8ebcd..af6d352937 100644 --- a/lib/chef/application/knife.rb +++ b/lib/chef/application/knife.rb @@ -22,7 +22,7 @@ require "ohai/config" module Net autoload :HTTP, File.expand_path("../monkey_patches/net_http", __dir__) end -require_relative "../dist" +require "chef-utils" class Chef::Application::Knife < Chef::Application @@ -61,7 +61,7 @@ class Chef::Application::Knife < Chef::Application option :environment, short: "-E ENVIRONMENT", long: "--environment ENVIRONMENT", - description: "Set the #{Chef::Dist::PRODUCT} environment (except for in searches, where this will be flagrantly ignored)." + description: "Set the #{ChefUtils::Dist::Infra::PRODUCT} environment (except for in searches, where this will be flagrantly ignored)." option :editor, short: "-e EDITOR", @@ -86,18 +86,18 @@ class Chef::Application::Knife < Chef::Application option :node_name, short: "-u USER", long: "--user USER", - description: "#{Chef::Dist::SERVER_PRODUCT} API client username." + description: "#{ChefUtils::Dist::Server::PRODUCT} API client username." option :client_key, short: "-k KEY", long: "--key KEY", - description: "#{Chef::Dist::SERVER_PRODUCT} API client key.", + description: "#{ChefUtils::Dist::Server::PRODUCT} API client key.", proc: lambda { |path| File.expand_path(path, Dir.pwd) } option :chef_server_url, short: "-s URL", long: "--server-url URL", - description: "#{Chef::Dist::SERVER_PRODUCT} URL." + description: "#{ChefUtils::Dist::Server::PRODUCT} URL." option :yes, short: "-y", @@ -122,16 +122,16 @@ class Chef::Application::Knife < Chef::Application option :local_mode, short: "-z", long: "--local-mode", - description: "Point knife commands at local repository instead of #{Chef::Dist::SERVER_PRODUCT}.", + description: "Point knife commands at local repository instead of #{ChefUtils::Dist::Server::PRODUCT}.", boolean: true option :chef_zero_host, long: "--chef-zero-host HOST", - description: "Host to start #{Chef::Dist::ZERO} on." + description: "Host to start #{ChefUtils::Dist::Zero::PRODUCT} on." option :chef_zero_port, long: "--chef-zero-port PORT", - description: "Port (or port range) to start #{Chef::Dist::ZERO} on. Port ranges like 1000,1010 or 8889-9999 will try all given ports until one works." + description: "Port (or port range) to start #{ChefUtils::Dist::Zero::PRODUCT} on. Port ranges like 1000,1010 or 8889-9999 will try all given ports until one works." option :listen, long: "--[no-]listen", @@ -141,9 +141,9 @@ class Chef::Application::Knife < Chef::Application option :version, short: "-v", long: "--version", - description: "Show #{Chef::Dist::PRODUCT} version.", + description: "Show #{ChefUtils::Dist::Infra::PRODUCT} version.", boolean: true, - proc: lambda { |v| puts "#{Chef::Dist::PRODUCT}: #{::Chef::VERSION}" }, + proc: lambda { |v| puts "#{ChefUtils::Dist::Infra::PRODUCT}: #{::Chef::VERSION}" }, exit: 0 option :fips, diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb index 9953d298a2..e514c7063f 100644 --- a/lib/chef/application/solo.rb +++ b/lib/chef/application/solo.rb @@ -33,7 +33,7 @@ class Chef::Application::Solo < Chef::Application::Base option :config_file, short: "-c CONFIG", long: "--config CONFIG", - default: Chef::Config.platform_specific_path("#{Chef::Dist::CONF_DIR}/solo.rb"), + default: "#{ChefConfig::Config.etc_chef_dir}/solo.rb", description: "The configuration file to use." unless ChefUtils.windows? diff --git a/lib/chef/application/windows_service.rb b/lib/chef/application/windows_service.rb index 770a5644ca..49ab3d2855 100644 --- a/lib/chef/application/windows_service.rb +++ b/lib/chef/application/windows_service.rb @@ -29,7 +29,7 @@ require "socket" unless defined?(Socket) require "uri" unless defined?(URI) require "win32/daemon" require_relative "../mixin/shell_out" -require_relative "../dist" +require "chef-utils" class Chef class Application @@ -41,7 +41,7 @@ class Chef short: "-c CONFIG", long: "--config CONFIG", default: "#{Chef::Config.etc_chef_dir}/client.rb", - description: "The configuration file to use for #{Chef::Dist::PRODUCT} runs." + description: "The configuration file to use for #{ChefUtils::Dist::Infra::PRODUCT} runs." option :log_location, short: "-L LOGLOCATION", @@ -57,7 +57,7 @@ class Chef option :interval, short: "-i SECONDS", long: "--interval SECONDS", - description: "Set the number of seconds to wait between #{Chef::Dist::PRODUCT} runs.", + description: "Set the number of seconds to wait between #{ChefUtils::Dist::Infra::PRODUCT} runs.", proc: lambda { |s| s.to_i } DEFAULT_LOG_LOCATION ||= "#{Chef::Config.c_chef_dir}/client.log".freeze @@ -67,7 +67,7 @@ class Chef @service_signal = ConditionVariable.new reconfigure - Chef::Log.info("#{Chef::Dist::CLIENT} Service initialized") + Chef::Log.info("#{ChefUtils::Dist::Infra::CLIENT} Service initialized") end def service_main(*startup_parameters) @@ -79,7 +79,7 @@ class Chef # Grab the service_action_mutex to make a chef-client run @service_action_mutex.synchronize do - Chef::Log.info("Next #{Chef::Dist::CLIENT} run will happen in #{timeout} seconds") + Chef::Log.info("Next #{ChefUtils::Dist::Infra::CLIENT} run will happen in #{timeout} seconds") @service_signal.wait(@service_action_mutex, timeout) # Continue only if service is RUNNING @@ -96,7 +96,7 @@ class Chef # run chef-client only if service is in RUNNING state next if state != RUNNING - Chef::Log.info("#{Chef::Dist::CLIENT} service is starting a #{Chef::Dist::CLIENT} run...") + Chef::Log.info("#{ChefUtils::Dist::Infra::CLIENT} service is starting a #{ChefUtils::Dist::Infra::CLIENT} run...") run_chef_client rescue SystemExit => e # Do not raise any of the errors here in order to @@ -131,12 +131,12 @@ class Chef break else unless run_warning_displayed - Chef::Log.info("Currently a #{Chef::Dist::PRODUCT} run is happening on this system.") + Chef::Log.info("Currently a #{ChefUtils::Dist::Infra::PRODUCT} 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::Dist::PRODUCT} run...") + Chef::Log.trace("Waiting for #{ChefUtils::Dist::Infra::PRODUCT} run...") sleep 1 end end @@ -150,7 +150,7 @@ class Chef # since this is a PAUSE signal. if @service_action_mutex.locked? - Chef::Log.info("Currently a #{Chef::Dist::PRODUCT} run is happening.") + Chef::Log.info("Currently a #{ChefUtils::Dist::Infra::PRODUCT} run is happening.") Chef::Log.info("Service will pause once it's completed.") else Chef::Log.info("Service is pausing....") @@ -185,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::Dist::CLIENT} in a new process" + Chef::Log.info "Starting #{ChefUtils::Dist::Infra::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? @@ -197,20 +197,20 @@ class Chef # Starts a new process and waits till the process exits result = shell_out( - "#{Chef::Dist::CLIENT}.bat #{config_params}", + "#{ChefUtils::Dist::Infra::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::Dist::CLIENT} timed out\n(#{e})" + Chef::Log.error "#{ChefUtils::Dist::Infra::CLIENT} timed out\n(#{e})" Chef::Log.error(<<-EOF) - Your #{Chef::Dist::CLIENT} run timed out. You can increase the time #{Chef::Dist::CLIENT} is given + Your #{ChefUtils::Dist::Infra::CLIENT} run timed out. You can increase the time #{ChefUtils::Dist::Infra::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::Dist::CLIENT} in new process (#{e})" + Chef::Log.warn "Not able to start #{ChefUtils::Dist::Infra::CLIENT} in new process (#{e})" rescue => e Chef::Log.error e ensure diff --git a/lib/chef/application/windows_service_manager.rb b/lib/chef/application/windows_service_manager.rb index 25ac72e014..d28028bcc1 100644 --- a/lib/chef/application/windows_service_manager.rb +++ b/lib/chef/application/windows_service_manager.rb @@ -21,7 +21,7 @@ if RUBY_PLATFORM.match?(/mswin|mingw32|windows/) end require_relative "../config" require "mixlib/cli" unless defined?(Mixlib::CLI) -require_relative "../dist" +require "chef-utils" class Chef class Application @@ -41,18 +41,18 @@ class Chef short: "-a ACTION", long: "--action ACTION", default: "status", - description: "Action to carry out on #{Chef::Dist::SHORT}-service (install, uninstall, status, start, stop, pause, or resume)." + description: "Action to carry out on #{ChefUtils::Dist::Infra::SHORT}-service (install, uninstall, status, start, stop, pause, or resume)." option :config_file, short: "-c CONFIG", long: "--config CONFIG", default: "#{ChefConfig::Config.c_chef_dir}/client.rb", - description: "The configuration file to use for #{Chef::Dist::PRODUCT} runs." + description: "The configuration file to use for #{ChefUtils::Dist::Infra::PRODUCT} runs." option :log_location, short: "-L LOGLOCATION", long: "--logfile LOGLOCATION", - description: "Set the log file location for #{Chef::Dist::SHORT}-service." + description: "Set the log file location for #{ChefUtils::Dist::Infra::SHORT}-service." option :help, short: "-h", @@ -66,9 +66,9 @@ class Chef option :version, short: "-v", long: "--version", - description: "Show #{Chef::Dist::PRODUCT} version.", + description: "Show #{ChefUtils::Dist::Infra::PRODUCT} version.", boolean: true, - proc: lambda { |v| puts "#{Chef::Dist::PRODUCT}: #{::Chef::VERSION}" }, + proc: lambda { |v| puts "#{ChefUtils::Dist::Infra::PRODUCT}: #{::Chef::VERSION}" }, exit: 0 def initialize(service_options) diff --git a/lib/chef/chef_fs/knife.rb b/lib/chef/chef_fs/knife.rb index 1e5f786b1d..d1b3f3d64a 100644 --- a/lib/chef/chef_fs/knife.rb +++ b/lib/chef/chef_fs/knife.rb @@ -18,7 +18,7 @@ require_relative "../knife" require "pathname" unless defined?(Pathname) -require_relative "../dist" +require "chef-utils" class Chef module ChefFS @@ -49,7 +49,7 @@ class Chef option :chef_repo_path, long: "--chef-repo-path PATH", - description: "Overrides the location of #{Chef::Dist::PRODUCT} repo. Default is specified by chef_repo_path in the config" + description: "Overrides the location of #{ChefUtils::Dist::Infra::PRODUCT} repo. Default is specified by chef_repo_path in the config" option :concurrency, long: "--concurrency THREADS", diff --git a/lib/chef/client.rb b/lib/chef/client.rb index 1a6da64c8f..04d907634b 100644 --- a/lib/chef/client.rb +++ b/lib/chef/client.rb @@ -55,7 +55,6 @@ require_relative "mixin/deprecation" require "chef-utils" unless defined?(ChefUtils::CANARY) require "ohai" unless defined?(Ohai::System) require "rbconfig" unless defined?(RbConfig) -require_relative "dist" require "forwardable" unless defined?(Forwardable) class Chef @@ -245,11 +244,11 @@ class Chef events.run_start(Chef::VERSION, run_status) - logger.info("*** #{Chef::Dist::PRODUCT} #{Chef::VERSION} ***") + logger.info("*** #{ChefUtils::Dist::Infra::PRODUCT} #{Chef::VERSION} ***") logger.info("Platform: #{RUBY_PLATFORM}") - logger.info "#{Chef::Dist::CLIENT.capitalize} pid: #{Process.pid}" + logger.info "#{ChefUtils::Dist::Infra::CLIENT.capitalize} pid: #{Process.pid}" logger.info "Targeting node: #{Chef::Config.target_mode.host}" if Chef::Config.target_mode? - logger.debug("#{Chef::Dist::CLIENT.capitalize} request_id: #{request_id}") + logger.debug("#{ChefUtils::Dist::Infra::CLIENT.capitalize} request_id: #{request_id}") ENV["PATH"] = ChefUtils::DSL::DefaultPaths.default_paths if Chef::Config[:enforce_default_paths] || Chef::Config[:enforce_path_sanity] if Chef::Config.target_mode? @@ -273,7 +272,7 @@ class Chef build_node run_status.start_clock - logger.info("Starting #{Chef::Dist::PRODUCT} Run for #{node.name}") + logger.info("Starting #{ChefUtils::Dist::Infra::PRODUCT} Run for #{node.name}") run_started do_windows_admin_check @@ -288,7 +287,7 @@ class Chef converge_and_save(run_context) run_status.stop_clock - logger.info("#{Chef::Dist::PRODUCT} Run complete in #{run_status.elapsed_time} seconds") + logger.info("#{ChefUtils::Dist::Infra::PRODUCT} Run complete in #{run_status.elapsed_time} seconds") run_completed_successfully events.run_completed(node, run_status) @@ -334,7 +333,7 @@ class Chef eol_year = 2006 + Gem::Version.new(Chef::VERSION).segments.first if Time.now > Time.new(eol_year, 5, 01) - logger.warn("This release of #{Chef::Dist::PRODUCT} became end of life (EOL) on May 1st #{eol_year}. Please update to a supported release to receive new features, bug fixes, and security updates.") + logger.warn("This release of #{ChefUtils::Dist::Infra::PRODUCT} became end of life (EOL) on May 1st #{eol_year}. Please update to a supported release to receive new features, bug fixes, and security updates.") end end @@ -763,7 +762,7 @@ class Chef logger.trace("Checking for administrator privileges....") if !has_admin_privileges? - message = "#{Chef::Dist::CLIENT} doesn't have administrator privileges on node #{node_name}." + message = "#{ChefUtils::Dist::Infra::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.") @@ -772,7 +771,7 @@ class Chef logger.warn("#{message} This might cause unexpected resource failures.") end else - logger.trace("#{Chef::Dist::CLIENT} has administrator privileges on node #{node_name}.") + logger.trace("#{ChefUtils::Dist::Infra::CLIENT} has administrator privileges on node #{node_name}.") end end end diff --git a/lib/chef/cookbook/synchronizer.rb b/lib/chef/cookbook/synchronizer.rb index 4a2940fb1f..44aff4ab5a 100644 --- a/lib/chef/cookbook/synchronizer.rb +++ b/lib/chef/cookbook/synchronizer.rb @@ -17,7 +17,7 @@ require_relative "../client" require_relative "../util/threaded_job_queue" require_relative "../server_api" require "singleton" unless defined?(Singleton) -require_relative "../dist" +require "chef-utils" class Chef @@ -65,7 +65,7 @@ class Chef # manifest. cache.find(File.join(%w{cookbooks ** {*,.*}})).each do |cache_filename| unless @valid_cache_entries[cache_filename] - Chef::Log.info("Removing #{cache_filename} from the cache; it is no longer needed by #{Chef::Dist::CLIENT}.") + Chef::Log.info("Removing #{cache_filename} from the cache; it is no longer needed by #{ChefUtils::Dist::Infra::CLIENT}.") cache.delete(cache_filename) end end diff --git a/lib/chef/cookbook_site_streaming_uploader.rb b/lib/chef/cookbook_site_streaming_uploader.rb index 7de89f9ad8..dcb914eb6c 100644 --- a/lib/chef/cookbook_site_streaming_uploader.rb +++ b/lib/chef/cookbook_site_streaming_uploader.rb @@ -28,7 +28,7 @@ module Mixlib autoload :SignedHeaderAuth, "mixlib/authentication/signedheaderauth" end end -require_relative "dist" +require "chef-utils" class Chef # == Chef::CookbookSiteStreamingUploader @@ -43,7 +43,7 @@ class Chef class << self def create_build_dir(cookbook) - tmp_cookbook_path = Tempfile.new("#{Chef::Dist::SHORT}-#{cookbook.name}-build") + tmp_cookbook_path = Tempfile.new("#{ChefUtils::Dist::Infra::SHORT}-#{cookbook.name}-build") tmp_cookbook_path.close tmp_cookbook_dir = tmp_cookbook_path.path File.unlink(tmp_cookbook_dir) diff --git a/lib/chef/data_collector.rb b/lib/chef/data_collector.rb index e1d7d9b97b..a44ebf07bb 100644 --- a/lib/chef/data_collector.rb +++ b/lib/chef/data_collector.rb @@ -26,7 +26,7 @@ require_relative "data_collector/run_end_message" require_relative "data_collector/run_start_message" require_relative "data_collector/config_validation" require_relative "data_collector/error_handlers" -require_relative "dist" +require "chef-utils" class Chef class DataCollector @@ -197,7 +197,7 @@ class Chef else if code == "404" # Make the message non-scary for folks who don't have automate: - msg << " (This is normal if you do not have #{Chef::Dist::AUTOMATE})" + msg << " (This is normal if you do not have #{ChefUtils::Dist::Automate::PRODUCT})" Chef::Log.debug(msg) else Chef::Log.warn(msg) diff --git a/lib/chef/data_collector/config_validation.rb b/lib/chef/data_collector/config_validation.rb index a58472a82b..ec612e052d 100644 --- a/lib/chef/data_collector/config_validation.rb +++ b/lib/chef/data_collector/config_validation.rb @@ -86,7 +86,7 @@ class Chef false when running_mode == :client && Chef::Config[:data_collector][:token] Chef::Log.warn("Data collector token authentication is not recommended for client-server mode. " \ - "Please upgrade #{Chef::Dist::SERVER_PRODUCT} to 12.11 or later and remove the token from your config file " \ + "Please upgrade #{ChefUtils::Dist::Server::PRODUCT} to 12.11 or later and remove the token from your config file " \ "to use key based authentication instead") true when Chef::Config[:data_collector][:output_locations] && !valid_hash_with_keys?(Chef::Config[:data_collector][:output_locations], :urls) @@ -99,7 +99,7 @@ class Chef true when running_mode == :solo && !Chef::Config[:data_collector][:token] # we are in solo mode and are not logging to a file, so must have a token - Chef::Log.trace("Data collector token must be configured to use #{Chef::Dist::AUTOMATE} data collector with #{Chef::Dist::SOLO}") + Chef::Log.trace("Data collector token must be configured to use #{ChefUtils::Dist::Automate::PRODUCT} data collector with #{ChefUtils::Dist::Solo::PRODUCT}") false else true diff --git a/lib/chef/deprecation/warnings.rb b/lib/chef/deprecation/warnings.rb index 201158114f..35f1394757 100644 --- a/lib/chef/deprecation/warnings.rb +++ b/lib/chef/deprecation/warnings.rb @@ -21,12 +21,12 @@ class Chef module Warnings require_relative "../version" - require_relative "../dist" + require "chef-utils" def add_deprecation_warnings_for(method_names) method_names.each do |name| define_method(name) do |*args| - message = "Method '#{name}' of '#{self.class}' is deprecated. It will be removed in #{Chef::Dist::PRODUCT} #{Chef::VERSION.to_i.next}." + message = "Method '#{name}' of '#{self.class}' is deprecated. It will be removed in #{ChefUtils::Dist::Infra::PRODUCT} #{Chef::VERSION.to_i.next}." message << " Please update your cookbooks accordingly." Chef.deprecated(:internal_api, message) super(*args) diff --git a/lib/chef/dist.rb b/lib/chef/dist.rb deleted file mode 100644 index b706f2d28f..0000000000 --- a/lib/chef/dist.rb +++ /dev/null @@ -1,74 +0,0 @@ -class Chef - class Dist - require "chef-config/dist" - require "chef-config/config" - - # This class is not fully implemented, depending on it is not recommended! - # When referencing a product directly, like Chef (Now Chef Infra) - PRODUCT = "Chef Infra Client".freeze - - # A short designation for the product, used in Windows event logs - # and some nomenclature. - SHORT = ChefConfig::Dist::SHORT.freeze - - # The name of the server product - SERVER_PRODUCT = "Chef Infra Server".freeze - - # The client's alias (chef-client) - CLIENT = ChefConfig::Dist::CLIENT.freeze - - # name of the automate product - AUTOMATE = "Chef Automate".freeze - - # The chef executable, as in `chef gem install` or `chef generate cookbook` - EXEC = ChefConfig::Dist::EXEC.freeze - - # product website address - WEBSITE = "https://chef.io".freeze - - # product patents page - PATENTS = "https://www.chef.io/patents".freeze - - # knife documentation page - KNIFE_DOCS = "https://docs.chef.io/workstation/knife/".freeze - - # Chef-Zero's product name - ZERO = "Chef Infra Zero".freeze - - # Chef-Solo's product name - SOLO = "Chef Infra Solo".freeze - - # The chef-zero executable (local mode) - ZEROEXEC = "chef-zero".freeze - - # The chef-solo executable (legacy local mode) - SOLOEXEC = "chef-solo".freeze - - # The chef-shell executable - SHELL = "chef-shell".freeze - - # The chef-apply executable - APPLY = "chef-apply".freeze - - # Configuration related constants - # The chef-shell configuration file - SHELL_CONF = "chef_shell.rb".freeze - - # The configuration directory - CONF_DIR = ChefConfig::Config.etc_chef_dir.freeze - - # The user's configuration directory - USER_CONF_DIR = ChefConfig::Dist::USER_CONF_DIR.freeze - - # The suffix for Chef's /etc/chef, /var/chef and C:\\Chef directories - # "cinc" => /etc/cinc, /var/cinc, C:\\cinc - DIR_SUFFIX = ChefConfig::Dist::DIR_SUFFIX.freeze - - # The legacy conf folder: C:/opscode/chef. Specifically the "opscode" part - # DIR_SUFFIX is appended to it in code where relevant - LEGACY_CONF_DIR = ChefConfig::Dist::LEGACY_CONF_DIR.freeze - - # The server's configuration directory - SERVER_CONF_DIR = "/etc/chef-server".freeze - end -end diff --git a/lib/chef/encrypted_data_bag_item.rb b/lib/chef/encrypted_data_bag_item.rb index c36c6923c5..f267b1c537 100644 --- a/lib/chef/encrypted_data_bag_item.rb +++ b/lib/chef/encrypted_data_bag_item.rb @@ -20,7 +20,6 @@ require_relative "config" Chef.autoload :DataBagItem, File.expand_path("data_bag_item", __dir__) require_relative "encrypted_data_bag_item/decryptor" require_relative "encrypted_data_bag_item/encryptor" -require_relative "dist" # An EncryptedDataBagItem represents a read-only data bag item where # all values, except for the value associated with the id key, have @@ -131,7 +130,7 @@ class Chef::EncryptedDataBagItem require "open-uri" unless defined?(OpenURI) path ||= Chef::Config[:encrypted_data_bag_secret] unless path - raise ArgumentError, "No secret specified and no secret found at #{Chef::Config.platform_specific_path(Chef::Dist::CONF_DIR + "/encrypted_data_bag_secret")}" + raise ArgumentError, "No secret specified and no secret found at #{ChefConfig::Config.etc_chef_dir + "/encrypted_data_bag_secret"}" end secret = case path diff --git a/lib/chef/environment.rb b/lib/chef/environment.rb index 4f0c365443..b952076b2b 100644 --- a/lib/chef/environment.rb +++ b/lib/chef/environment.rb @@ -25,7 +25,7 @@ require_relative "mixin/params_validate" require_relative "mixin/from_file" require_relative "version_constraint" require_relative "server_api" -require_relative "dist" +require "chef-utils" class Chef class Environment @@ -308,7 +308,7 @@ class Chef def self.validate_cookbook_version(version) if Chef::Config[:solo_legacy_mode] raise Chef::Exceptions::IllegalVersionConstraint, - "Environment cookbook version constraints not allowed in #{Chef::Dist::SOLO}" + "Environment cookbook version constraints not allowed in #{ChefUtils::Dist::Solo::PRODUCT}" else Chef::VersionConstraint.new version true diff --git a/lib/chef/event_loggers/windows_eventlog.rb b/lib/chef/event_loggers/windows_eventlog.rb index 1b9037fdb3..da2e4dae8a 100644 --- a/lib/chef/event_loggers/windows_eventlog.rb +++ b/lib/chef/event_loggers/windows_eventlog.rb @@ -19,7 +19,7 @@ require_relative "base" require_relative "../platform/query_helpers" require_relative "../win32/eventlog" -require_relative "../dist" +require "chef-utils" class Chef module EventLoggers @@ -36,7 +36,7 @@ class Chef LOG_CATEGORY_ID = 11001 # Since we must install the event logger, this is not really configurable - SOURCE = Chef::Dist::SHORT.freeze + SOURCE = ChefUtils::Dist::Infra::SHORT.freeze def self.available? ChefUtils.windows? diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb index 52a2cc8439..93cda03e75 100644 --- a/lib/chef/exceptions.rb +++ b/lib/chef/exceptions.rb @@ -18,7 +18,7 @@ # limitations under the License. require "chef-config/exceptions" -require_relative "dist" +require "chef-utils" require_relative "constants" class Chef @@ -301,7 +301,7 @@ class Chef def client_run_failure(exception) set_backtrace(exception.backtrace) - @all_failures << [ "#{Chef::Dist::PRODUCT} run", exception ] + @all_failures << [ "#{ChefUtils::Dist::Infra::PRODUCT} run", exception ] end def notification_failure(exception) @@ -402,7 +402,7 @@ class Chef def initialize(response_length, content_length) super <<~EOF Response body length #{response_length} does not match HTTP Content-Length header #{content_length}. - This error is most often caused by network issues (proxies, etc) outside of #{Chef::Dist::CLIENT}. + This error is most often caused by network issues (proxies, etc) outside of #{ChefUtils::Dist::Infra::CLIENT}. EOF end end @@ -477,7 +477,7 @@ class Chef class CookbookChefVersionMismatch < RuntimeError def initialize(chef_version, cookbook_name, cookbook_version, *constraints) constraint_str = constraints.map { |c| c.requirement.as_list.to_s }.join(", ") - super "Cookbook '#{cookbook_name}' version '#{cookbook_version}' depends on #{Chef::Dist::PRODUCT} version #{constraint_str}, but the running #{Chef::Dist::PRODUCT} version is #{chef_version}" + super "Cookbook '#{cookbook_name}' version '#{cookbook_version}' depends on #{ChefUtils::Dist::Infra::PRODUCT} version #{constraint_str}, but the running #{ChefUtils::Dist::Infra::PRODUCT} version is #{chef_version}" end end diff --git a/lib/chef/formatters/doc.rb b/lib/chef/formatters/doc.rb index 557f2b3682..86bc6f7bba 100644 --- a/lib/chef/formatters/doc.rb +++ b/lib/chef/formatters/doc.rb @@ -1,6 +1,6 @@ require_relative "base" require_relative "../config" -require_relative "../dist" +require "chef-utils" class Chef module Formatters @@ -41,7 +41,7 @@ class Chef end def run_start(version, run_status) - puts_line "Starting #{Chef::Dist::PRODUCT}, version #{version}" + puts_line "Starting #{ChefUtils::Dist::Infra::PRODUCT}, version #{version}" puts_line "Patents: #{Chef::Dist::PATENTS}" puts_line "Targeting node: #{Chef::Config.target_mode.host}" if Chef::Config.target_mode? puts_line "OpenSSL FIPS 140 mode enabled" if Chef::Config[:fips] @@ -78,18 +78,18 @@ class Chef puts_line "" end if Chef::Config[:why_run] - puts_line "#{Chef::Dist::PRODUCT} finished, #{@updated_resources}/#{total_resources} resources would have been updated" + puts_line "#{ChefUtils::Dist::Infra::PRODUCT} finished, #{@updated_resources}/#{total_resources} resources would have been updated" else - puts_line "#{Chef::Dist::PRODUCT} finished, #{@updated_resources}/#{total_resources} resources updated in #{pretty_elapsed_time}" + puts_line "#{ChefUtils::Dist::Infra::PRODUCT} finished, #{@updated_resources}/#{total_resources} resources updated in #{pretty_elapsed_time}" end end def run_failed(exception) @end_time = Time.now if Chef::Config[:why_run] - puts_line "#{Chef::Dist::PRODUCT} failed. #{@updated_resources} resources would have been updated" + puts_line "#{ChefUtils::Dist::Infra::PRODUCT} failed. #{@updated_resources} resources would have been updated" else - puts_line "#{Chef::Dist::PRODUCT} failed. #{@updated_resources} resources updated in #{pretty_elapsed_time}" + puts_line "#{ChefUtils::Dist::Infra::PRODUCT} failed. #{@updated_resources} resources updated in #{pretty_elapsed_time}" end end diff --git a/lib/chef/formatters/error_inspectors/api_error_formatting.rb b/lib/chef/formatters/error_inspectors/api_error_formatting.rb index 47e8523323..d89503bc0d 100644 --- a/lib/chef/formatters/error_inspectors/api_error_formatting.rb +++ b/lib/chef/formatters/error_inspectors/api_error_formatting.rb @@ -17,7 +17,7 @@ # require_relative "../../http/authenticator" -require_relative "../../dist" +require "chef-utils" require "timeout" unless defined?(Timeout) class Chef @@ -41,7 +41,7 @@ class Chef def describe_eof_error(error_description) error_description.section("Authentication Error:", <<~E) Received an EOF on transport socket. This almost always indicates a network - error external to #{Chef::Dist::CLIENT}. Some causes include: + error external to #{ChefUtils::Dist::Infra::CLIENT}. Some causes include: - Blocking ICMP Dest Unreachable (breaking Path MTU Discovery) - IPsec or VPN tunnelling / TCP Encapsulation MTU issues @@ -115,8 +115,8 @@ class Chef error_description.section("Incompatible server API version:", <<~E) This version of the API that this request specified is not supported by the server you sent this request to. The server supports a min API version of #{min_server_version} and a max API version of #{max_server_version}. - #{Chef::Dist::PRODUCT} just made a request with an API version of #{client_api_version}. - Please either update your #{Chef::Dist::PRODUCT} or the server to be a compatible set. + #{ChefUtils::Dist::Infra::PRODUCT} just made a request with an API version of #{client_api_version}. + Please either update your #{ChefUtils::Dist::Infra::PRODUCT} or the server to be a compatible set. E else describe_http_error(error_description) @@ -131,7 +131,7 @@ class Chef end def describe_503_error(error_description) - error_description.section("Server Unavailable", "The #{Chef::Dist::SERVER_PRODUCT} is temporarily unavailable") + error_description.section("Server Unavailable", "The #{ChefUtils::Dist::Server::PRODUCT} is temporarily unavailable") error_description.section("Server Response:", format_rest_error) end diff --git a/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb b/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb index 3a3f602203..9f6902ed12 100644 --- a/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb +++ b/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb @@ -17,7 +17,7 @@ # require_relative "api_error_formatting" -require_relative "../../dist" +require "chef-utils" class Chef module Formatters @@ -46,7 +46,7 @@ class Chef when Chef::Exceptions::PrivateKeyMissing error_description.section("Private Key Not Found:", <<~E) Your private key could not be loaded. If the key file exists, ensure that it is - readable by #{Chef::Dist::PRODUCT}. + readable by #{ChefUtils::Dist::Infra::PRODUCT}. E error_description.section("Relevant Config Settings:", <<~E) client_key "#{api_key}" @@ -99,7 +99,7 @@ class Chef # redirect. def describe_404_error(error_description) error_description.section("Resource Not Found:", <<~E) - The #{Chef::Dist::SERVER_PRODUCT} returned a HTTP 404. This usually indicates that your chef_server_url is incorrect. + The #{ChefUtils::Dist::Server::PRODUCT} returned a HTTP 404. This usually indicates that your chef_server_url is incorrect. E error_description.section("Relevant Config Settings:", <<~E) chef_server_url "#{server_url}" diff --git a/lib/chef/formatters/error_inspectors/registration_error_inspector.rb b/lib/chef/formatters/error_inspectors/registration_error_inspector.rb index 565ea217b8..c62f59c072 100644 --- a/lib/chef/formatters/error_inspectors/registration_error_inspector.rb +++ b/lib/chef/formatters/error_inspectors/registration_error_inspector.rb @@ -1,4 +1,4 @@ -require_relative "../../dist" +require "chef-utils" class Chef module Formatters @@ -28,7 +28,7 @@ class Chef humanize_http_exception(error_description) when Errno::ECONNREFUSED, Timeout::Error, Errno::ETIMEDOUT, SocketError error_description.section("Network Error:", <<~E) - There was a network error connecting to the #{Chef::Dist::SERVER_PRODUCT}: + There was a network error connecting to the #{ChefUtils::Dist::Server::PRODUCT}: #{exception.message} E error_description.section("Relevant Config Settings:", <<~E) @@ -39,14 +39,14 @@ class Chef when Chef::Exceptions::PrivateKeyMissing error_description.section("Private Key Not Found:", <<~E) Your private key could not be loaded. If the key file exists, ensure that it is - readable by #{Chef::Dist::PRODUCT}. + readable by #{ChefUtils::Dist::Infra::PRODUCT}. E error_description.section("Relevant Config Settings:", <<~E) validation_key "#{api_key}" E when Chef::Exceptions::InvalidRedirect error_description.section("Invalid Redirect:", <<~E) - Change your #{Chef::Dist::SERVER_PRODUCT} location in client.rb to the #{Chef::Dist::SERVER_PRODUCT}'s FQDN to avoid unwanted redirections. + Change your #{ChefUtils::Dist::Server::PRODUCT} location in client.rb to the #{ChefUtils::Dist::Server::PRODUCT}'s FQDN to avoid unwanted redirections. E when EOFError describe_eof_error(error_description) @@ -61,13 +61,13 @@ class Chef when Net::HTTPUnauthorized if clock_skew? error_description.section("Authentication Error:", <<~E) - Failed to authenticate to the #{Chef::Dist::SERVER_PRODUCT} (http 401). + Failed to authenticate to the #{ChefUtils::Dist::Server::PRODUCT} (http 401). The request failed because your clock has drifted by more than 15 minutes. Syncing your clock to an NTP Time source should resolve the issue. E else error_description.section("Authentication Error:", <<~E) - Failed to authenticate to the #{Chef::Dist::SERVER_PRODUCT} (http 401). + Failed to authenticate to the #{ChefUtils::Dist::Server::PRODUCT} (http 401). E error_description.section("Server Response:", format_rest_error) @@ -81,7 +81,7 @@ class Chef end when Net::HTTPForbidden error_description.section("Authorization Error:", <<~E) - Your validation client is not authorized to create the client for this node on the #{Chef::Dist::SERVER_PRODUCT} (HTTP 403). + Your validation client is not authorized to create the client for this node on the #{ChefUtils::Dist::Server::PRODUCT} (HTTP 403). E error_description.section("Possible Causes:", <<~E) * There may already be a client named "#{config[:node_name]}" @@ -94,7 +94,7 @@ class Chef error_description.section("Server Response:", format_rest_error) when Net::HTTPNotFound error_description.section("Resource Not Found:", <<~E) - The #{Chef::Dist::SERVER_PRODUCT} returned a HTTP 404. This usually indicates that your chef_server_url configuration is incorrect. + The #{ChefUtils::Dist::Server::PRODUCT} returned a HTTP 404. This usually indicates that your chef_server_url configuration is incorrect. E error_description.section("Relevant Config Settings:", <<~E) chef_server_url "#{server_url}" @@ -107,7 +107,7 @@ class Chef E error_description.section("Server Response:", format_rest_error) when Net::HTTPBadGateway, Net::HTTPServiceUnavailable - error_description.section("Server Unavailable", "The #{Chef::Dist::SERVER_PRODUCT} is temporarily unavailable") + error_description.section("Server Unavailable", "The #{ChefUtils::Dist::Server::PRODUCT} is temporarily unavailable") error_description.section("Server Response:", format_rest_error) else error_description.section("Unexpected API Request Failure:", format_rest_error) diff --git a/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb b/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb index fa7580d2c3..04bc8ded65 100644 --- a/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +++ b/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb @@ -16,7 +16,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -require_relative "../../dist" +require "chef-utils" class Chef module Formatters @@ -56,7 +56,7 @@ class Chef require_relative "../../win32/security" unless Chef::ReservedNames::Win32::Security.has_admin_privileges? - error_description.section("Missing Windows Admin Privileges", "#{Chef::Dist::CLIENT} doesn't have administrator privileges. This can be a possible reason for the resource failure.") + error_description.section("Missing Windows Admin Privileges", "#{ChefUtils::Dist::Infra::CLIENT} doesn't have administrator privileges. This can be a possible reason for the resource failure.") end end end diff --git a/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb b/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb index ca3dec138b..c5f02402a4 100644 --- a/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb +++ b/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb @@ -18,7 +18,7 @@ # require_relative "api_error_formatting" -require_relative "../../dist" +require "chef-utils" class Chef module Formatters @@ -78,7 +78,7 @@ class Chef case response when Net::HTTPUnauthorized error_description.section("Authentication Error:", <<~E) - Failed to authenticate to the #{Chef::Dist::SERVER_PRODUCT} (http 401). + Failed to authenticate to the #{ChefUtils::Dist::Server::PRODUCT} (http 401). E error_description.section("Server Response:", format_rest_error) @@ -109,7 +109,7 @@ class Chef E error_description.section("Server Response:", format_rest_error) when Net::HTTPBadGateway, Net::HTTPServiceUnavailable - error_description.section("Server Unavailable", "The #{Chef::Dist::SERVER_PRODUCT} is temporarily unavailable") + error_description.section("Server Unavailable", "The #{ChefUtils::Dist::Server::PRODUCT} is temporarily unavailable") error_description.section("Server Response:", format_rest_error) else error_description.section("Unexpected API Request Failure:", format_rest_error) diff --git a/lib/chef/formatters/minimal.rb b/lib/chef/formatters/minimal.rb index ba616798ab..39fe93fc67 100644 --- a/lib/chef/formatters/minimal.rb +++ b/lib/chef/formatters/minimal.rb @@ -1,5 +1,5 @@ require_relative "base" -require_relative "../dist" +require "chef-utils" class Chef @@ -28,7 +28,7 @@ class Chef # Called at the very start of a Chef Run def run_start(version, run_status) - puts_line "Starting #{Chef::Dist::PRODUCT}, version #{version}" + puts_line "Starting #{ChefUtils::Dist::Infra::PRODUCT}, version #{version}" puts_line "Patents: #{Chef::Dist::PATENTS}" puts_line "Targeting node: #{Chef::Config.target_mode.host}" if Chef::Config.target_mode? puts_line "OpenSSL FIPS 140 mode enabled" if Chef::Config[:fips] @@ -36,12 +36,12 @@ class Chef # Called at the end of the Chef run. def run_completed(node) - puts "#{Chef::Dist::PRODUCT} finished, #{@updated_resources.size} resources updated" + puts "#{ChefUtils::Dist::Infra::PRODUCT} finished, #{@updated_resources.size} resources updated" end # called at the end of a failed run def run_failed(exception) - puts "#{Chef::Dist::PRODUCT} failed. #{@updated_resources.size} resources updated" + puts "#{ChefUtils::Dist::Infra::PRODUCT} failed. #{@updated_resources.size} resources updated" end # Called right after ohai runs. diff --git a/lib/chef/http/http_request.rb b/lib/chef/http/http_request.rb index dbb1e0ce70..ef12630045 100644 --- a/lib/chef/http/http_request.rb +++ b/lib/chef/http/http_request.rb @@ -25,7 +25,7 @@ autoload :CGI, "cgi" module Net autoload :HTTP, File.expand_path("../monkey_patches/net_http", __dir__) end -require_relative "../dist" +require "chef-utils" # To load faster, we only want ohai's version string. # However, in ohai before 0.6.0, the version is defined @@ -44,7 +44,7 @@ class Chef engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby" - UA_COMMON = "/#{::Chef::VERSION} (#{engine}-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}; ohai-#{Ohai::VERSION}; #{RUBY_PLATFORM}; +#{Chef::Dist::WEBSITE})".freeze + UA_COMMON = "/#{::Chef::VERSION} (#{engine}-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}; ohai-#{Ohai::VERSION}; #{RUBY_PLATFORM}; +#{ChefUtils::Dist::Org::WEBSITE})".freeze DEFAULT_UA = "Chef Client" << UA_COMMON USER_AGENT = "User-Agent".freeze diff --git a/lib/chef/http/socketless_chef_zero_client.rb b/lib/chef/http/socketless_chef_zero_client.rb index feebba5a2c..6f43390f8d 100644 --- a/lib/chef/http/socketless_chef_zero_client.rb +++ b/lib/chef/http/socketless_chef_zero_client.rb @@ -44,7 +44,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require "chef_zero/server" -require_relative "../dist" +require "chef-utils" module Net autoload :HTTPResponse, File.expand_path("../monkey_patches/net_http", __dir__) end @@ -67,7 +67,7 @@ class Chef # or else streaming-style responses won't work. def read_body(dest = nil, &block) if dest - raise "responses from socketless #{Chef::Dist::ZERO} can't be written to specific destination" + raise "responses from socketless #{ChefUtils::Dist::Zero::PRODUCT} can't be written to specific destination" end if block_given? diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb index e1f2d56aaf..c3163a3e4c 100644 --- a/lib/chef/knife.rb +++ b/lib/chef/knife.rb @@ -32,12 +32,12 @@ require_relative "http/authenticator" require_relative "http/http_request" require_relative "http" require "pp" unless defined?(PP) -require_relative "dist" +require "chef-utils" class Chef class Knife - Chef::HTTP::HTTPRequest.user_agent = "#{Chef::Dist::PRODUCT} Knife#{Chef::HTTP::HTTPRequest::UA_COMMON}" + Chef::HTTP::HTTPRequest.user_agent = "#{ChefUtils::Dist::Infra::PRODUCT} Knife#{Chef::HTTP::HTTPRequest::UA_COMMON}" include Mixlib::CLI include ChefUtils::DSL::DefaultPaths @@ -282,7 +282,7 @@ class Chef elsif 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::Dist::EXEC} gem install knife-#{args[0]}` to install the plugin into Chef Workstation") + ui.info("Use `#{ChefUtils::Dist::Infra::EXEC} gem install knife-#{args[0]}` to install the plugin into Chef Workstation") else list_commands end @@ -564,7 +564,7 @@ class Chef ui.error "The API version that Knife is using is not supported by the server you sent this request to." ui.info "The request that Knife sent was using API version #{client_api_version}." ui.info "The server you sent the request to supports a min API version of #{min_server_version} and a max API version of #{max_server_version}." - ui.info "Please either update your #{Chef::Dist::PRODUCT} or the server to be a compatible set." + ui.info "Please either update your #{ChefUtils::Dist::Infra::PRODUCT} or the 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.rb b/lib/chef/knife/bootstrap.rb index b78911e071..8fb4525d42 100644 --- a/lib/chef/knife/bootstrap.rb +++ b/lib/chef/knife/bootstrap.rb @@ -18,7 +18,7 @@ require_relative "../knife" require_relative "data_bag_secret_options" -require_relative "../dist" +require "chef-utils" require "license_acceptance/cli_flags/mixlib_cli" module LicenseAcceptance autoload :Acceptor, "license_acceptance/acceptor" @@ -146,7 +146,7 @@ class Chef # client.rb content via chef-full/bootstrap_context option :bootstrap_version, long: "--bootstrap-version VERSION", - description: "The version of #{Chef::Dist::PRODUCT} to install." + description: "The version of #{ChefUtils::Dist::Infra::PRODUCT} to install." option :channel, long: "--channel CHANNEL", @@ -178,7 +178,7 @@ class Chef option :bootstrap_template, short: "-t TEMPLATE", long: "--bootstrap-template TEMPLATE", - description: "Bootstrap #{Chef::Dist::PRODUCT} using a built-in or custom template. Set to the full path of an erb template or use one of the built-in templates." + description: "Bootstrap #{ChefUtils::Dist::Infra::PRODUCT} using a built-in or custom template. Set to the full path of an erb template or use one of the built-in templates." # client.rb content via bootstrap_context option :node_ssl_verify_mode, @@ -196,7 +196,7 @@ class Chef # bootstrap_context - client.rb option :node_verify_api_cert, long: "--[no-]node-verify-api-cert", - description: "Verify the SSL cert for HTTPS requests to the #{Chef::Dist::SERVER_PRODUCT} API.", + description: "Verify the SSL cert for HTTPS requests to the #{ChefUtils::Dist::Server::PRODUCT} API.", boolean: true # runtime - sudo settings (train handles sudo) @@ -254,14 +254,14 @@ class Chef option :first_boot_attributes, short: "-j JSON_ATTRIBS", long: "--json-attributes", - description: "A JSON string to be added to the first run of #{Chef::Dist::CLIENT}.", + description: "A JSON string to be added to the first run of #{ChefUtils::Dist::Infra::CLIENT}.", proc: lambda { |o| Chef::JSONCompat.parse(o) }, default: nil # bootstrap template option :first_boot_attributes_from_file, long: "--json-attribute-file FILE", - description: "A JSON file to be used to the first run of #{Chef::Dist::CLIENT}.", + description: "A JSON file to be used to the first run of #{ChefUtils::Dist::Infra::CLIENT}.", proc: lambda { |o| Chef::JSONCompat.parse(File.read(o)) }, default: nil @@ -292,28 +292,28 @@ class Chef option :msi_url, # Windows target only short: "-m URL", long: "--msi-url URL", - description: "Location of the #{Chef::Dist::PRODUCT} MSI. The default templates will prefer to download from this location. The MSI will be downloaded from #{Chef::Dist::WEBSITE} if not provided (Windows).", + description: "Location of the #{ChefUtils::Dist::Infra::PRODUCT} MSI. The default templates will prefer to download from this location. The MSI will be downloaded from #{ChefUtils::Dist::Org::WEBSITE} if not provided (Windows).", default: "" # bootstrap override: Do this instead of our own setup.sh from omnitruck. Causes bootstrap_url to be ignored. option :bootstrap_install_command, long: "--bootstrap-install-command COMMANDS", - description: "Custom command to install #{Chef::Dist::PRODUCT}." + description: "Custom command to install #{ChefUtils::Dist::Infra::PRODUCT}." # bootstrap template: Run this command first in the bootstrap script option :bootstrap_preinstall_command, long: "--bootstrap-preinstall-command COMMANDS", - description: "Custom commands to run before installing #{Chef::Dist::PRODUCT}." + description: "Custom commands to run before installing #{ChefUtils::Dist::Infra::PRODUCT}." # bootstrap template option :bootstrap_wget_options, long: "--bootstrap-wget-options OPTIONS", - description: "Add options to wget when installing #{Chef::Dist::PRODUCT}." + description: "Add options to wget when installing #{ChefUtils::Dist::Infra::PRODUCT}." # bootstrap template option :bootstrap_curl_options, long: "--bootstrap-curl-options OPTIONS", - description: "Add options to curl when install #{Chef::Dist::PRODUCT}." + description: "Add options to curl when install #{ChefUtils::Dist::Infra::PRODUCT}." # chef_vault_handler option :bootstrap_vault_file, diff --git a/lib/chef/knife/bootstrap/templates/chef-full.erb b/lib/chef/knife/bootstrap/templates/chef-full.erb index 5006009617..2e0c80eaef 100644 --- a/lib/chef/knife/bootstrap/templates/chef-full.erb +++ b/lib/chef/knife/bootstrap/templates/chef-full.erb @@ -172,8 +172,8 @@ do_download() { <%= @config[:bootstrap_install_command] %> <% else %> install_sh="<%= @config[:bootstrap_url] ? @config[:bootstrap_url] : "https://omnitruck.chef.io/chef/install.sh" %>" - if test -f /usr/bin/<%= Chef::Dist::CLIENT %>; then - echo "-----> Existing <%= Chef::Dist::PRODUCT %> installation detected" + if test -f /usr/bin/<%= ChefUtils::Dist::Infra::CLIENT %>; then + echo "-----> Existing <%= ChefUtils::Dist::Infra::PRODUCT %> installation detected" else echo "-----> Installing Chef Omnibus (<%= @config[:channel] %>/<%= version_to_install %>)" 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::Dist::PRODUCT %> Client run..." +echo "Starting the first <%= ChefUtils::Dist::Infra::PRODUCT %> Client run..." <%= start_chef %> diff --git a/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb b/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb index 9699c09b0e..9c8f5972d4 100644 --- a/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +++ b/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb @@ -109,13 +109,13 @@ goto Version10.0 goto chef_installed :chef_installed -@echo Checking for existing <%= Chef::Dist::PRODUCT %> installation -WHERE <%= Chef::Dist::CLIENT %> >nul 2>nul +@echo Checking for existing <%= ChefUtils::Dist::Infra::PRODUCT %> installation +WHERE <%= ChefUtils::Dist::Infra::CLIENT %> >nul 2>nul If !ERRORLEVEL!==0 ( - @echo Existing <%= Chef::Dist::PRODUCT %> installation detected, skipping download + @echo Existing <%= ChefUtils::Dist::Infra::PRODUCT %> installation detected, skipping download goto key_create ) else ( - @echo No existing installation of <%= Chef::Dist::PRODUCT %> detected + @echo No existing installation of <%= ChefUtils::Dist::Infra::PRODUCT %> detected goto install ) @@ -127,7 +127,7 @@ If !ERRORLEVEL!==0 ( @rem Install Chef using the MSI installer @set "LOCAL_DESTINATION_MSI_PATH=<%= local_download_path %>" - @set "CHEF_CLIENT_MSI_LOG_PATH=%TEMP%\<%= Chef::Dist::CLIENT %>-msi%RANDOM%.log" + @set "CHEF_CLIENT_MSI_LOG_PATH=%TEMP%\<%= ChefUtils::Dist::Infra::CLIENT %>-msi%RANDOM%.log" @rem Clear any pre-existing downloads @echo Checking for existing downloaded package at "%LOCAL_DESTINATION_MSI_PATH%" @@ -197,7 +197,7 @@ If !ERRORLEVEL!==0 ( <%= install_chef %> @if ERRORLEVEL 1 ( - echo <%= Chef::Dist::CLIENT %> package failed to install with status code !ERRORLEVEL!. > "&2" + echo <%= ChefUtils::Dist::Infra::CLIENT %> package failed to install with status code !ERRORLEVEL!. > "&2" echo See installation log for additional detail: %CHEF_CLIENT_MSI_LOG_PATH%. > "&2" ) else ( @echo Installation completed successfully @@ -274,5 +274,5 @@ echo Validation key written. <%= client_d %> <% end -%> -@echo Starting <%= Chef::Dist::CLIENT %> to bootstrap the node... +@echo Starting <%= ChefUtils::Dist::Infra::CLIENT %> to bootstrap the node... <%= start_chef %> diff --git a/lib/chef/knife/client_create.rb b/lib/chef/knife/client_create.rb index 9e9975ec0d..a30b76c10b 100644 --- a/lib/chef/knife/client_create.rb +++ b/lib/chef/knife/client_create.rb @@ -17,7 +17,7 @@ # require_relative "../knife" -require_relative "../dist" +require "chef-utils" class Chef class Knife @@ -30,7 +30,7 @@ class Chef option :file, short: "-f FILE", long: "--file FILE", - description: "Write the private key to a file if the #{Chef::Dist::SERVER_PRODUCT} generated one." + description: "Write the private key to a file if the #{ChefUtils::Dist::Server::PRODUCT} generated one." option :validator, long: "--validator", @@ -45,7 +45,7 @@ class Chef option :prevent_keygen, short: "-k", long: "--prevent-keygen", - description: "Prevent #{Chef::Dist::SERVER_PRODUCT} from generating a default key pair for you. Cannot be passed with --public-key.", + description: "Prevent #{ChefUtils::Dist::Server::PRODUCT} from generating a default key pair for you. Cannot be passed with --public-key.", boolean: true banner "knife client create CLIENTNAME (options)" diff --git a/lib/chef/knife/configure.rb b/lib/chef/knife/configure.rb index dc19e40d47..9bab33f005 100644 --- a/lib/chef/knife/configure.rb +++ b/lib/chef/knife/configure.rb @@ -17,7 +17,7 @@ # require_relative "../knife" -require_relative "../dist" +require "chef-utils" class Chef class Knife @@ -119,7 +119,7 @@ class Chef if config[:initial] @new_client_name = config[:node_name] || ask_question("Please enter a name for the new user: ", default: Etc.getlogin) @admin_client_name = config[:admin_client_name] || ask_question("Please enter the existing admin name: ", default: "admin") - @admin_client_key = config[:admin_client_key] || ask_question("Please enter the location of the existing admin's private key: ", default: "#{Chef::Dist::SERVER_CONF_DIR}/admin.pem") + @admin_client_key = config[:admin_client_key] || ask_question("Please enter the location of the existing admin's private key: ", default: "#{ChefUtils::Dist::Server::CONF_DIR}/admin.pem") @admin_client_key = File.expand_path(@admin_client_key) else @new_client_name = config[:node_name] || ask_question("Please enter an existing username or clientname for the API: ", default: Etc.getlogin) diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb index 12923f149a..de4d3e4841 100644 --- a/lib/chef/knife/core/bootstrap_context.rb +++ b/lib/chef/knife/core/bootstrap_context.rb @@ -19,7 +19,7 @@ require_relative "../../run_list" require_relative "../../util/path_helper" require "pathname" unless defined?(Pathname) -require_relative "../../dist" +require "chef-utils" class Chef class Knife @@ -184,7 +184,7 @@ class Chef def start_chef # If the user doesn't have a client path configure, let bash use the PATH for what it was designed for - client_path = chef_config[:chef_client_path] || Chef::Dist::CLIENT + client_path = chef_config[:chef_client_path] || ChefUtils::Dist::Infra::CLIENT s = "#{client_path} -j /etc/chef/first-boot.json" if config[:verbosity] && config[:verbosity] >= 3 s << " -l trace" diff --git a/lib/chef/knife/core/windows_bootstrap_context.rb b/lib/chef/knife/core/windows_bootstrap_context.rb index 7b4d517237..5af508f8dc 100644 --- a/lib/chef/knife/core/windows_bootstrap_context.rb +++ b/lib/chef/knife/core/windows_bootstrap_context.rb @@ -18,7 +18,7 @@ require_relative "bootstrap_context" require_relative "../../util/path_helper" -require_relative "../../dist" +require "chef-utils" class Chef class Knife @@ -175,7 +175,7 @@ class Chef bootstrap_environment_option = bootstrap_environment.nil? ? "" : " -E #{bootstrap_environment}" start_chef = "SET \"PATH=%SYSTEM32%;%SystemRoot%;%SYSTEM32%\\Wbem;%SYSTEM32%\\WindowsPowerShell\\v1.0\\;C:\\ruby\\bin;#{c_opscode_dir}\\bin;#{c_opscode_dir}\\embedded\\bin\;%PATH%\"\n" - start_chef << "#{Chef::Dist::CLIENT} -c #{client_rb} -j #{first_boot}#{bootstrap_environment_option}\n" + start_chef << "#{ChefUtils::Dist::Infra::CLIENT} -c #{client_rb} -j #{first_boot}#{bootstrap_environment_option}\n" end def win_wget @@ -288,7 +288,7 @@ class Chef end def local_download_path - "%TEMP%\\#{Chef::Dist::CLIENT}-latest.msi" + "%TEMP%\\#{ChefUtils::Dist::Infra::CLIENT}-latest.msi" end # Build a URL to query www.chef.io that will redirect to the correct @@ -365,7 +365,7 @@ class Chef <<~EOH @set MSIERRORCODE=!ERRORLEVEL! @if ERRORLEVEL 1 ( - @echo WARNING: Failed to install #{Chef::Dist::PRODUCT} MSI package in remote context with status code !MSIERRORCODE!. + @echo WARNING: Failed to install #{ChefUtils::Dist::Infra::PRODUCT} MSI package in remote context with status code !MSIERRORCODE!. @echo WARNING: This may be due to a defect in operating system update KB2918614: http://support.microsoft.com/kb/2918614 @set OLDLOGLOCATION="%CHEF_CLIENT_MSI_LOG_PATH%-fail.log" @move "%CHEF_CLIENT_MSI_LOG_PATH%" "!OLDLOGLOCATION!" > NUL @@ -374,26 +374,26 @@ class Chef @schtasks /create /f /sc once /st 00:00:00 /tn chefclientbootstraptask /ru SYSTEM /rl HIGHEST /tr \"cmd /c #{command} & sleep 2 & waitfor /s %computername% /si chefclientinstalldone\" @if ERRORLEVEL 1 ( - @echo ERROR: Failed to create #{Chef::Dist::PRODUCT} installation scheduled task with status code !ERRORLEVEL! > "&2" + @echo ERROR: Failed to create #{ChefUtils::Dist::Infra::PRODUCT} installation scheduled task with status code !ERRORLEVEL! > "&2" ) else ( - @echo Successfully created scheduled task to install #{Chef::Dist::PRODUCT}. + @echo Successfully created scheduled task to install #{ChefUtils::Dist::Infra::PRODUCT}. @schtasks /run /tn chefclientbootstraptask @if ERRORLEVEL 1 ( - @echo ERROR: Failed to execute #{Chef::Dist::PRODUCT} installation scheduled task with status code !ERRORLEVEL!. > "&2" + @echo ERROR: Failed to execute #{ChefUtils::Dist::Infra::PRODUCT} installation scheduled task with status code !ERRORLEVEL!. > "&2" ) else ( - @echo Successfully started #{Chef::Dist::PRODUCT} installation scheduled task. + @echo Successfully started #{ChefUtils::Dist::Infra::PRODUCT} installation scheduled task. @echo Waiting for installation to complete -- this may take a few minutes... waitfor chefclientinstalldone /t 600 if ERRORLEVEL 1 ( - @echo ERROR: Timed out waiting for #{Chef::Dist::PRODUCT} package to install + @echo ERROR: Timed out waiting for #{ChefUtils::Dist::Infra::PRODUCT} package to install ) else ( - @echo Finished waiting for #{Chef::Dist::PRODUCT} package to install. + @echo Finished waiting for #{ChefUtils::Dist::Infra::PRODUCT} package to install. ) @schtasks /delete /f /tn chefclientbootstraptask > NUL ) ) ) else ( - @echo Successfully installed #{Chef::Dist::PRODUCT} package. + @echo Successfully installed #{ChefUtils::Dist::Infra::PRODUCT} package. ) EOH end diff --git a/lib/chef/knife/exec.rb b/lib/chef/knife/exec.rb index 9286a91022..01f619e156 100644 --- a/lib/chef/knife/exec.rb +++ b/lib/chef/knife/exec.rb @@ -17,7 +17,7 @@ # require_relative "../knife" -require_relative "../dist" +require "chef-utils" class Chef::Knife::Exec < Chef::Knife @@ -30,7 +30,7 @@ class Chef::Knife::Exec < Chef::Knife option :exec, short: "-E CODE", long: "--exec CODE", - description: "A string of #{Chef::Dist::PRODUCT} code to execute." + description: "A string of #{ChefUtils::Dist::Infra::PRODUCT} code to execute." option :script_path, short: "-p PATH:PATH", diff --git a/lib/chef/knife/node_show.rb b/lib/chef/knife/node_show.rb index 801f0bbba9..bbcc38f39a 100644 --- a/lib/chef/knife/node_show.rb +++ b/lib/chef/knife/node_show.rb @@ -18,7 +18,7 @@ require_relative "../knife" require_relative "core/node_presenter" -require_relative "../dist" +require "chef-utils" class Chef class Knife @@ -42,7 +42,7 @@ class Chef option :environment, short: "-E", long: "--environment", - description: "Show only the #{Chef::Dist::PRODUCT} environment." + description: "Show only the #{ChefUtils::Dist::Infra::PRODUCT} environment." def run ui.use_presenter Knife::Core::NodePresenter diff --git a/lib/chef/knife/serve.rb b/lib/chef/knife/serve.rb index cce2ff6576..3741b3cf30 100644 --- a/lib/chef/knife/serve.rb +++ b/lib/chef/knife/serve.rb @@ -16,7 +16,7 @@ require_relative "../knife" require_relative "../local_mode" -require_relative "../dist" +require "chef-utils" class Chef class Knife @@ -30,11 +30,11 @@ class Chef option :chef_repo_path, long: "--chef-repo-path PATH", - description: "Overrides the location of #{Chef::Dist::PRODUCT} repo. Default is specified by chef_repo_path in the config." + description: "Overrides the location of #{ChefUtils::Dist::Infra::PRODUCT} repo. Default is specified by chef_repo_path in the config." option :chef_zero_host, long: "--chef-zero-host IP", - description: "Overrides the host upon which #{Chef::Dist::ZERO} listens. Default is 127.0.0.1." + description: "Overrides the host upon which #{ChefUtils::Dist::Zero::PRODUCT} listens. Default is 127.0.0.1." def configure_chef super diff --git a/lib/chef/knife/ssl_check.rb b/lib/chef/knife/ssl_check.rb index 65e8694497..29e8cedb5d 100644 --- a/lib/chef/knife/ssl_check.rb +++ b/lib/chef/knife/ssl_check.rb @@ -17,7 +17,7 @@ # require_relative "../knife" -require_relative "../dist" +require "chef-utils" class Chef class Knife @@ -190,7 +190,7 @@ class Chef #{ui.color("TO FIX THIS ERROR:", :bold)} If the server you are connecting to uses a self-signed certificate, you must - configure #{Chef::Dist::PRODUCT} to trust that server's certificate. + configure #{ChefUtils::Dist::Infra::PRODUCT} to trust that server's certificate. By default, the certificate is stored in the following location on the host where your chef-server runs: @@ -234,7 +234,7 @@ class Chef end def debug_chef_ssl_config - ui.err "#{Chef::Dist::PRODUCT} SSL Configuration:" + ui.err "#{ChefUtils::Dist::Infra::PRODUCT} SSL Configuration:" ui.err "* ssl_ca_path: #{configuration.ssl_ca_path.inspect}" ui.err "* ssl_ca_file: #{configuration.ssl_ca_file.inspect}" ui.err "* trusted_certs_dir: #{configuration.trusted_certs_dir.inspect}" diff --git a/lib/chef/knife/status.rb b/lib/chef/knife/status.rb index 530cf791f7..e318f37825 100644 --- a/lib/chef/knife/status.rb +++ b/lib/chef/knife/status.rb @@ -19,7 +19,7 @@ require_relative "../knife" require_relative "core/status_presenter" require_relative "core/node_presenter" -require_relative "../dist" +require "chef-utils" class Chef class Knife @@ -44,7 +44,7 @@ class Chef option :hide_by_mins, long: "--hide-by-mins MINS", - description: "Hide nodes that have run #{Chef::Dist::CLIENT} in the last MINS minutes" + description: "Hide nodes that have run #{ChefUtils::Dist::Infra::CLIENT} in the last MINS minutes" def append_to_query(term) @query << " AND " unless @query.empty? diff --git a/lib/chef/knife/user_create.rb b/lib/chef/knife/user_create.rb index 785020f5e3..bbd24d6706 100644 --- a/lib/chef/knife/user_create.rb +++ b/lib/chef/knife/user_create.rb @@ -18,7 +18,7 @@ # require_relative "../knife" -require_relative "../dist" +require "chef-utils" class Chef class Knife @@ -42,7 +42,7 @@ class Chef option :prevent_keygen, short: "-k", long: "--prevent-keygen", - description: "API V1 (#{Chef::Dist::SERVER_PRODUCT} 12.1+) only. Prevent server from generating a default key pair for you. Cannot be passed with --user-key.", + description: "API V1 (#{ChefUtils::Dist::Server::PRODUCT} 12.1+) only. Prevent server from generating a default key pair for you. Cannot be passed with --user-key.", boolean: true banner "knife user create USERNAME DISPLAY_NAME FIRST_NAME LAST_NAME EMAIL PASSWORD (options)" diff --git a/lib/chef/local_mode.rb b/lib/chef/local_mode.rb index b7816cdc89..df615df2b7 100644 --- a/lib/chef/local_mode.rb +++ b/lib/chef/local_mode.rb @@ -17,7 +17,7 @@ require_relative "config" require_relative "monkey_patches/webrick-utils" if ChefUtils.windows? -require_relative "dist" +require "chef-utils" class Chef module LocalMode @@ -79,7 +79,7 @@ class Chef local_mode_url = @chef_zero_server.local_mode_url - Chef::Log.info("Started #{Chef::Dist::ZERO} at #{local_mode_url} with #{@chef_fs.fs_description}") + Chef::Log.info("Started #{ChefUtils::Dist::Zero::PRODUCT} at #{local_mode_url} with #{@chef_fs.fs_description}") Chef::Config.chef_server_url = local_mode_url end end diff --git a/lib/chef/log/syslog.rb b/lib/chef/log/syslog.rb index 28c5bf8799..8c22fbf3da 100644 --- a/lib/chef/log/syslog.rb +++ b/lib/chef/log/syslog.rb @@ -19,7 +19,7 @@ require "logger" require "syslog-logger" require_relative "../mixin/unformatter" -require_relative "../dist" +require "chef-utils" class Chef class Log @@ -33,7 +33,7 @@ class Chef attr_accessor :sync, :formatter - def initialize(program_name = Chef::Dist::CLIENT, facility = ::Syslog::LOG_DAEMON, logopts = nil) + def initialize(program_name = ChefUtils::Dist::Infra::CLIENT, facility = ::Syslog::LOG_DAEMON, logopts = nil) super return if defined? ::Logger::Syslog::SYSLOG diff --git a/lib/chef/log/winevt.rb b/lib/chef/log/winevt.rb index 6aff6cccec..2b3e5c97a5 100644 --- a/lib/chef/log/winevt.rb +++ b/lib/chef/log/winevt.rb @@ -19,7 +19,7 @@ require_relative "../event_loggers/base" require_relative "../platform/query_helpers" require_relative "../mixin/unformatter" -require_relative "../dist" +require "chef-utils" class Chef class Log @@ -37,7 +37,7 @@ class Chef FATAL_EVENT_ID = 10104 # Since we must install the event logger, this is not really configurable - SOURCE = Chef::Dist::SHORT.freeze + SOURCE = ChefUtils::Dist::Infra::SHORT.freeze include Chef::Mixin::Unformatter diff --git a/lib/chef/policy_builder/policyfile.rb b/lib/chef/policy_builder/policyfile.rb index 0055f9d4b6..4beea10112 100644 --- a/lib/chef/policy_builder/policyfile.rb +++ b/lib/chef/policy_builder/policyfile.rb @@ -24,7 +24,7 @@ require_relative "../run_context" require_relative "../config" require_relative "../node" require_relative "../server_api" -require_relative "../dist" +require "chef-utils" class Chef module PolicyBuilder @@ -91,7 +91,7 @@ class Chef @node = nil if Chef::Config[:solo_legacy_mode] - raise UnsupportedFeature, "Policyfile does not support chef-solo. Use #{Chef::Dist::CLIENT} local mode instead." + raise UnsupportedFeature, "Policyfile does not support chef-solo. Use #{ChefUtils::Dist::Infra::CLIENT} local mode instead." end if override_runlist diff --git a/lib/chef/provider/file.rb b/lib/chef/provider/file.rb index 0de620bba1..dee85b96b2 100644 --- a/lib/chef/provider/file.rb +++ b/lib/chef/provider/file.rb @@ -31,7 +31,7 @@ require_relative "../util/backup" require_relative "../util/diff" require_relative "../util/selinux" require_relative "../file_content_management/deploy" -require_relative "../dist" +require "chef-utils" # The Tao of File Providers: # - the content provider must always return a tempfile that we can delete/mv @@ -394,7 +394,7 @@ class Chef return if tempfile.nil? # but a tempfile that has no path or doesn't exist should not happen if tempfile.path.nil? || !::File.exists?(tempfile.path) - raise "#{Chef::Dist::CLIENT} is confused, trying to deploy a file that has no path or does not exist..." + raise "#{ChefUtils::Dist::Infra::CLIENT} is confused, trying to deploy a file that has no path or does not exist..." end # the file? on the next line suppresses the case in why-run when we have a not-file here that would have otherwise been removed diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb index f9e89ead02..bab1413ef0 100644 --- a/lib/chef/provider/package/rubygems.rb +++ b/lib/chef/provider/package/rubygems.rb @@ -22,7 +22,7 @@ require_relative "../package" require_relative "../../resource/package" require_relative "../../mixin/get_source_from_package" require_relative "../../mixin/which" -require_relative "../../dist" +require "chef-utils" # Class methods on Gem are defined in rubygems autoload :Gem, "rubygems" @@ -404,8 +404,8 @@ class Chef if new_resource.options && new_resource.options.is_a?(Hash) msg = [ "Gem options must be passed to gem_package as a string instead of a hash when", - "using this installation of #{Chef::Dist::PRODUCT} because it runs with its own packaged Ruby. A hash", - "may only be used when installing a gem to the same Ruby installation that #{Chef::Dist::PRODUCT} is", + "using this installation of #{ChefUtils::Dist::Infra::PRODUCT} because it runs with its own packaged Ruby. A hash", + "may only be used when installing a gem to the same Ruby installation that #{ChefUtils::Dist::Infra::PRODUCT} is", "running under. See https://docs.chef.io/resources/gem_package/ for more information.", "Error raised at #{new_resource} from #{new_resource.source_line}", ].join("\n") diff --git a/lib/chef/provider/zypper_repository.rb b/lib/chef/provider/zypper_repository.rb index 6427a27746..1c557acda0 100644 --- a/lib/chef/provider/zypper_repository.rb +++ b/lib/chef/provider/zypper_repository.rb @@ -20,7 +20,7 @@ require_relative "../resource" require_relative "../dsl/declare_resource" require_relative "noop" require "shellwords" unless defined?(Shellwords) -require_relative "../dist" +require "chef-utils" class Chef class Provider @@ -110,7 +110,7 @@ class Chef logger.trace("Will use :cookbook_file resource to cache the gpg key locally") :cookbook_file else - raise Chef::Exceptions::FileNotFound, "Cannot determine location of gpgkey. Must start with 'http' or be a file managed by #{Chef::Dist::PRODUCT}." + raise Chef::Exceptions::FileNotFound, "Cannot determine location of gpgkey. Must start with 'http' or be a file managed by #{ChefUtils::Dist::Infra::PRODUCT}." end end diff --git a/lib/chef/resource/breakpoint.rb b/lib/chef/resource/breakpoint.rb index d1e6bbf179..4c03579136 100644 --- a/lib/chef/resource/breakpoint.rb +++ b/lib/chef/resource/breakpoint.rb @@ -17,7 +17,7 @@ # require_relative "../resource" -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -26,7 +26,7 @@ class Chef provides :breakpoint, target_mode: true - description "Use the **breakpoint** resource to add breakpoints to recipes. Run the #{Chef::Dist::SHELL} in #{Chef::Dist::PRODUCT} mode, and then use those breakpoints to debug recipes. Breakpoints are ignored by the #{Chef::Dist::CLIENT} during an actual #{Chef::Dist::CLIENT} run. That said, breakpoints are typically used to debug recipes only when running them in a non-production environment, after which they are removed from those recipes before the parent cookbook is uploaded to the Chef server." + description "Use the **breakpoint** resource to add breakpoints to recipes. Run the #{ChefUtils::Dist::Infra::SHELL} in #{ChefUtils::Dist::Infra::PRODUCT} mode, and then use those breakpoints to debug recipes. Breakpoints are ignored by the #{ChefUtils::Dist::Infra::CLIENT} during an actual #{ChefUtils::Dist::Infra::CLIENT} run. That said, breakpoints are typically used to debug recipes only when running them in a non-production environment, after which they are removed from those recipes before the parent cookbook is uploaded to the Chef server." introduced "12.0" default_action :break diff --git a/lib/chef/resource/chef_client_cron.rb b/lib/chef/resource/chef_client_cron.rb index ab435c39f8..a656027492 100644 --- a/lib/chef/resource/chef_client_cron.rb +++ b/lib/chef/resource/chef_client_cron.rb @@ -15,7 +15,7 @@ # require_relative "../resource" -require_relative "../dist" +require "chef-utils" require_relative "helpers/cron_validations" require "digest/md5" unless defined?(Digest::MD5) @@ -26,25 +26,25 @@ class Chef provides :chef_client_cron - description "Use the **chef_client_cron** resource to setup the #{Chef::Dist::PRODUCT} to run as a cron job. This resource will also create the specified log directory if it doesn't already exist." + description "Use the **chef_client_cron** resource to setup the #{ChefUtils::Dist::Infra::PRODUCT} to run as a cron job. This resource will also create the specified log directory if it doesn't already exist." introduced "16.0" examples <<~DOC - **Setup #{Chef::Dist::PRODUCT} to run using the default 30 minute cadence**: + **Setup #{ChefUtils::Dist::Infra::PRODUCT} to run using the default 30 minute cadence**: ```ruby - chef_client_cron "Run #{Chef::Dist::PRODUCT} as a cron job" + chef_client_cron "Run #{ChefUtils::Dist::Infra::PRODUCT} as a cron job" ``` - **Run #{Chef::Dist::PRODUCT} twice a day**: + **Run #{ChefUtils::Dist::Infra::PRODUCT} twice a day**: ```ruby - chef_client_cron "Run #{Chef::Dist::PRODUCT} every 12 hours" do + chef_client_cron "Run #{ChefUtils::Dist::Infra::PRODUCT} every 12 hours" do minute 0 hour "0,12" end ``` - **Run #{Chef::Dist::PRODUCT} with extra options passed to the client**: + **Run #{ChefUtils::Dist::Infra::PRODUCT} with extra options passed to the client**: ```ruby chef_client_cron "Run an override recipe" do @@ -56,42 +56,42 @@ class Chef extend Chef::ResourceHelpers::CronValidations property :job_name, String, - default: Chef::Dist::CLIENT, + default: ChefUtils::Dist::Infra::CLIENT, description: "The name of the cron job to create." property :comment, String, description: "A comment to place in the cron.d file." property :user, String, - description: "The name of the user that #{Chef::Dist::PRODUCT} runs as.", + description: "The name of the user that #{ChefUtils::Dist::Infra::PRODUCT} runs as.", default: "root" property :minute, [Integer, String], - description: "The minute at which #{Chef::Dist::PRODUCT} is to run (0 - 59) or a cron pattern such as '0,30'.", + description: "The minute at which #{ChefUtils::Dist::Infra::PRODUCT} is to run (0 - 59) or a cron pattern such as '0,30'.", default: "0,30", callbacks: { "should be a valid minute spec" => method(:validate_minute), } property :hour, [Integer, String], - description: "The hour at which #{Chef::Dist::PRODUCT} is to run (0 - 23) or a cron pattern such as '0,12'.", + description: "The hour at which #{ChefUtils::Dist::Infra::PRODUCT} is to run (0 - 23) or a cron pattern such as '0,12'.", default: "*", callbacks: { "should be a valid hour spec" => method(:validate_hour), } property :day, [Integer, String], - description: "The day of month at which #{Chef::Dist::PRODUCT} is to run (1 - 31) or a cron pattern such as '1,7,14,21,28'.", + description: "The day of month at which #{ChefUtils::Dist::Infra::PRODUCT} is to run (1 - 31) or a cron pattern such as '1,7,14,21,28'.", default: "*", callbacks: { "should be a valid day spec" => method(:validate_day), } property :month, [Integer, String], - description: "The month in the year on which #{Chef::Dist::PRODUCT} is to run (1 - 12, jan-dec, or *).", + description: "The month in the year on which #{ChefUtils::Dist::Infra::PRODUCT} is to run (1 - 12, jan-dec, or *).", default: "*", callbacks: { "should be a valid month spec" => method(:validate_month), } property :weekday, [Integer, String], - description: "The day of the week on which #{Chef::Dist::PRODUCT} is to run (0-7, mon-sun, or *), where Sunday is both 0 and 7.", + description: "The day of the week on which #{ChefUtils::Dist::Infra::PRODUCT} is to run (0-7, mon-sun, or *), where Sunday is both 0 and 7.", default: "*", callbacks: { "should be a valid weekday spec" => method(:validate_dow), } @@ -100,7 +100,7 @@ class Chef default: 300, coerce: proc { |x| Integer(x) }, callbacks: { "should be a positive number" => proc { |v| v > 0 } }, - description: "A random number of seconds between 0 and X to add to interval so that all #{Chef::Dist::CLIENT} commands don't execute at the same time." + description: "A random number of seconds between 0 and X to add to interval so that all #{ChefUtils::Dist::Infra::CLIENT} commands don't execute at the same time." property :mailto, String, description: "The e-mail address to e-mail any cron task failures to." @@ -110,12 +110,12 @@ class Chef default: false property :config_directory, String, - default: Chef::Dist::CONF_DIR, + default: ChefConfig::Config.etc_chef_dir, description: "The path of the config directory." property :log_directory, String, - default: lazy { platform?("mac_os_x") ? "/Library/Logs/#{Chef::Dist::DIR_SUFFIX.capitalize}" : "/var/log/#{Chef::Dist::DIR_SUFFIX}" }, - default_description: "/Library/Logs/#{Chef::Dist::DIR_SUFFIX.capitalize} on macOS and /var/log/#{Chef::Dist::DIR_SUFFIX} otherwise", + default: lazy { platform?("mac_os_x") ? "/Library/Logs/#{ChefUtils::Dist::Infra::DIR_SUFFIX.capitalize}" : "/var/log/#{ChefUtils::Dist::Infra::DIR_SUFFIX}" }, + default_description: "/Library/Logs/#{ChefUtils::Dist::Infra::DIR_SUFFIX.capitalize} on macOS and /var/log/#{ChefUtils::Dist::Infra::DIR_SUFFIX} otherwise", description: "The path of the directory to create the log file in." property :log_file_name, String, @@ -127,12 +127,12 @@ class Chef description: "Append to the log file instead of overwriting the log file on each run." property :chef_binary_path, String, - default: "/opt/#{Chef::Dist::DIR_SUFFIX}/bin/#{Chef::Dist::CLIENT}", - description: "The path to the #{Chef::Dist::CLIENT} binary." + default: "/opt/#{ChefUtils::Dist::Infra::DIR_SUFFIX}/bin/#{ChefUtils::Dist::Infra::CLIENT}", + description: "The path to the #{ChefUtils::Dist::Infra::CLIENT} binary." property :daemon_options, Array, default: lazy { [] }, - description: "An array of options to pass to the #{Chef::Dist::CLIENT} command." + description: "An array of options to pass to the #{ChefUtils::Dist::Infra::CLIENT} command." property :environment, Hash, default: lazy { {} }, @@ -202,7 +202,7 @@ class Chef cmd << "-c #{::File.join(new_resource.config_directory, "client.rb")} " cmd << "--chef-license accept " if new_resource.accept_chef_license cmd << log_command - cmd << " || echo \"#{Chef::Dist::PRODUCT} execution failed\"" if new_resource.mailto + cmd << " || echo \"#{ChefUtils::Dist::Infra::PRODUCT} execution failed\"" if new_resource.mailto cmd end diff --git a/lib/chef/resource/chef_client_scheduled_task.rb b/lib/chef/resource/chef_client_scheduled_task.rb index 7fde581763..c8c97bd865 100644 --- a/lib/chef/resource/chef_client_scheduled_task.rb +++ b/lib/chef/resource/chef_client_scheduled_task.rb @@ -15,7 +15,7 @@ # require_relative "../resource" -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -24,24 +24,24 @@ class Chef provides :chef_client_scheduled_task - description "Use the **chef_client_scheduled_task** resource to setup the #{Chef::Dist::PRODUCT} to run as a Windows scheduled task. This resource will also create the specified log directory if it doesn't already exist." + description "Use the **chef_client_scheduled_task** resource to setup the #{ChefUtils::Dist::Infra::PRODUCT} to run as a Windows scheduled task. This resource will also create the specified log directory if it doesn't already exist." introduced "16.0" examples <<~DOC - **Setup #{Chef::Dist::PRODUCT} to run using the default 30 minute cadence**: + **Setup #{ChefUtils::Dist::Infra::PRODUCT} to run using the default 30 minute cadence**: ```ruby - chef_client_scheduled_task "Run #{Chef::Dist::PRODUCT} as a scheduled task" + chef_client_scheduled_task "Run #{ChefUtils::Dist::Infra::PRODUCT} as a scheduled task" ``` - **Run #{Chef::Dist::PRODUCT} on system start**: + **Run #{ChefUtils::Dist::Infra::PRODUCT} on system start**: ```ruby - chef_client_scheduled_task '#{Chef::Dist::PRODUCT} on start' do + chef_client_scheduled_task '#{ChefUtils::Dist::Infra::PRODUCT} on start' do frequency 'onstart' end ``` - **Run #{Chef::Dist::PRODUCT} with extra options passed to the client**: + **Run #{ChefUtils::Dist::Infra::PRODUCT} with extra options passed to the client**: ```ruby chef_client_scheduled_task "Run an override recipe" do @@ -64,14 +64,14 @@ class Chef property :task_name, String, description: "The name of the scheduled task to create.", - default: Chef::Dist::CLIENT + default: ChefUtils::Dist::Infra::CLIENT property :user, String, - description: "The name of the user that #{Chef::Dist::PRODUCT} runs as.", + description: "The name of the user that #{ChefUtils::Dist::Infra::PRODUCT} runs as.", default: "System", sensitive: true property :password, String, - description: "The password for the user that #{Chef::Dist::PRODUCT} runs as.", + description: "The password for the user that #{ChefUtils::Dist::Infra::PRODUCT} runs as.", sensitive: true property :frequency, String, @@ -101,16 +101,16 @@ class Chef property :splay, [Integer, String], coerce: proc { |x| Integer(x) }, callbacks: { "should be a positive number" => proc { |v| v > 0 } }, - description: "A random number of seconds between 0 and X to add to interval so that all #{Chef::Dist::CLIENT} commands don't execute at the same time.", + description: "A random number of seconds between 0 and X to add to interval so that all #{ChefUtils::Dist::Infra::CLIENT} commands don't execute at the same time.", default: 300 property :run_on_battery, [true, false], - description: "Run the #{Chef::Dist::PRODUCT} task when the system is on batteries.", + description: "Run the #{ChefUtils::Dist::Infra::PRODUCT} task when the system is on batteries.", default: true property :config_directory, String, description: "The path of the config directory.", - default: Chef::Dist::CONF_DIR + default: ChefConfig::Config.etc_chef_dir property :log_directory, String, description: "The path of the directory to create the log file in.", @@ -122,11 +122,11 @@ class Chef default: "client.log" property :chef_binary_path, String, - description: "The path to the #{Chef::Dist::CLIENT} binary.", - default: "C:/#{Chef::Dist::LEGACY_CONF_DIR}/#{Chef::Dist::DIR_SUFFIX}/bin/#{Chef::Dist::CLIENT}" + description: "The path to the #{ChefUtils::Dist::Infra::CLIENT} binary.", + default: "C:/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/#{ChefUtils::Dist::Infra::DIR_SUFFIX}/bin/#{ChefUtils::Dist::Infra::CLIENT}" property :daemon_options, Array, - description: "An array of options to pass to the #{Chef::Dist::CLIENT} command.", + description: "An array of options to pass to the #{ChefUtils::Dist::Infra::CLIENT} command.", default: lazy { [] } action :add do diff --git a/lib/chef/resource/chef_client_systemd_timer.rb b/lib/chef/resource/chef_client_systemd_timer.rb index 71e05e9499..432f29703d 100644 --- a/lib/chef/resource/chef_client_systemd_timer.rb +++ b/lib/chef/resource/chef_client_systemd_timer.rb @@ -15,7 +15,7 @@ # require_relative "../resource" -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -24,24 +24,24 @@ class Chef provides :chef_client_systemd_timer - description "Use the **chef_client_systemd_timer** resource to setup the #{Chef::Dist::PRODUCT} to run as a systemd timer." + description "Use the **chef_client_systemd_timer** resource to setup the #{ChefUtils::Dist::Infra::PRODUCT} to run as a systemd timer." introduced "16.0" examples <<~DOC - **Setup #{Chef::Dist::PRODUCT} to run using the default 30 minute cadence**: + **Setup #{ChefUtils::Dist::Infra::PRODUCT} to run using the default 30 minute cadence**: ```ruby - chef_client_systemd_timer "Run #{Chef::Dist::PRODUCT} as a systemd timer" + chef_client_systemd_timer "Run #{ChefUtils::Dist::Infra::PRODUCT} as a systemd timer" ``` - **Run #{Chef::Dist::PRODUCT} every 1 hour**: + **Run #{ChefUtils::Dist::Infra::PRODUCT} every 1 hour**: ```ruby - chef_client_systemd_timer "Run #{Chef::Dist::PRODUCT} every 1 hour" do + chef_client_systemd_timer "Run #{ChefUtils::Dist::Infra::PRODUCT} every 1 hour" do interval "1hr" end ``` - **Run #{Chef::Dist::PRODUCT} with extra options passed to the client**: + **Run #{ChefUtils::Dist::Infra::PRODUCT} with extra options passed to the client**: ```ruby chef_client_systemd_timer "Run an override recipe" do @@ -52,14 +52,14 @@ class Chef property :job_name, String, description: "The name of the system timer to create.", - default: Chef::Dist::CLIENT + default: ChefUtils::Dist::Infra::CLIENT property :description, String, description: "The description to add to the systemd timer. This will be displayed when running `systemctl status` for the timer.", - default: "#{Chef::Dist::PRODUCT} periodic execution" + default: "#{ChefUtils::Dist::Infra::PRODUCT} periodic execution" property :user, String, - description: "The name of the user that #{Chef::Dist::PRODUCT} runs as.", + description: "The name of the user that #{ChefUtils::Dist::Infra::PRODUCT} runs as.", default: "root" property :delay_after_boot, String, @@ -71,7 +71,7 @@ class Chef default: "30min" property :splay, String, - description: "A interval between 0 and X to add to the interval so that all #{Chef::Dist::CLIENT} commands don't execute at the same time. This is expressed as a systemd time span such as `300seconds`, `1hr`, or `1m`. See <https://www.freedesktop.org/software/systemd/man/systemd.time.html> for a complete list of allowed time span values.", + description: "A interval between 0 and X to add to the interval so that all #{ChefUtils::Dist::Infra::CLIENT} commands don't execute at the same time. This is expressed as a systemd time span such as `300seconds`, `1hr`, or `1m`. See <https://www.freedesktop.org/software/systemd/man/systemd.time.html> for a complete list of allowed time span values.", default: "5min" property :accept_chef_license, [true, false], @@ -79,19 +79,19 @@ class Chef default: false property :run_on_battery, [true, false], - description: "Run the timer for #{Chef::Dist::PRODUCT} if the system is on battery.", + description: "Run the timer for #{ChefUtils::Dist::Infra::PRODUCT} if the system is on battery.", default: true property :config_directory, String, description: "The path of the config directory.", - default: Chef::Dist::CONF_DIR + default: ChefConfig::Config.etc_chef_dir property :chef_binary_path, String, - description: "The path to the #{Chef::Dist::CLIENT} binary.", - default: "/opt/#{Chef::Dist::DIR_SUFFIX}/bin/#{Chef::Dist::CLIENT}" + description: "The path to the #{ChefUtils::Dist::Infra::CLIENT} binary.", + default: "/opt/#{ChefUtils::Dist::Infra::DIR_SUFFIX}/bin/#{ChefUtils::Dist::Infra::CLIENT}" property :daemon_options, Array, - description: "An array of options to pass to the #{Chef::Dist::CLIENT} command.", + description: "An array of options to pass to the #{ChefUtils::Dist::Infra::CLIENT} command.", default: lazy { [] } property :environment, Hash, diff --git a/lib/chef/resource/chef_gem.rb b/lib/chef/resource/chef_gem.rb index b44f9e1771..23e603927d 100644 --- a/lib/chef/resource/chef_gem.rb +++ b/lib/chef/resource/chef_gem.rb @@ -18,7 +18,7 @@ require_relative "package" require_relative "gem_package" -require_relative "../dist" +require "chef-utils/dist/infra" class Chef class Resource @@ -84,8 +84,8 @@ class Chef property :gem_binary, String, default: "#{RbConfig::CONFIG["bindir"]}/gem", - default_description: "The `gem` binary included with #{Chef::Dist::PRODUCT}.", - description: "The path of a gem binary to use for the installation. By default, the same version of Ruby that is used by #{Chef::Dist::PRODUCT} will be used.", + default_description: "The `gem` binary included with #{ChefUtils::Dist::Infra::PRODUCT}.", + description: "The path of a gem binary to use for the installation. By default, the same version of Ruby that is used by #{ChefUtils::Dist::Infra::PRODUCT} will be used.", callbacks: { "The `chef_gem` resource is restricted to the current gem environment, use `gem_package` to install to other environments." => proc { |v| v == "#{RbConfig::CONFIG["bindir"]}/gem" }, diff --git a/lib/chef/resource/chef_handler.rb b/lib/chef/resource/chef_handler.rb index f2daab3d6e..9666f8e656 100644 --- a/lib/chef/resource/chef_handler.rb +++ b/lib/chef/resource/chef_handler.rb @@ -16,7 +16,7 @@ # require_relative "../resource" -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -50,7 +50,7 @@ class Chef # This action needs to find an rb file that presumably contains the indicated class in it and the # load that file. It then instantiates that class by name and registers it as a handler. action :enable do - description "Enables the handler for the current #{Chef::Dist::PRODUCT} run on the current node" + description "Enables the handler for the current #{ChefUtils::Dist::Infra::PRODUCT} run on the current node" class_name = new_resource.class_name new_resource.type.each do |type, enable| @@ -74,7 +74,7 @@ class Chef end action :disable do - description "Disables the handler for the current #{Chef::Dist::PRODUCT} run on the current node" + description "Disables the handler for the current #{ChefUtils::Dist::Infra::PRODUCT} run on the current node" new_resource.type.each_key do |type| unregister_handler(type, new_resource.class_name) diff --git a/lib/chef/resource/chef_sleep.rb b/lib/chef/resource/chef_sleep.rb index 828ce07bc9..501f8fbfa0 100644 --- a/lib/chef/resource/chef_sleep.rb +++ b/lib/chef/resource/chef_sleep.rb @@ -15,7 +15,7 @@ # require_relative "../resource" -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -24,7 +24,7 @@ class Chef unified_mode true - description "Use the **chef_sleep** resource to pause (sleep) for a number of seconds during a #{Chef::Dist::PRODUCT} run. Only use this resource when a command or service exits successfully but is not ready for the next step in a recipe." + description "Use the **chef_sleep** resource to pause (sleep) for a number of seconds during a #{ChefUtils::Dist::Infra::PRODUCT} run. Only use this resource when a command or service exits successfully but is not ready for the next step in a recipe." introduced "15.5" examples <<~DOC **Sleep for 10 seconds**: diff --git a/lib/chef/resource/cookbook_file.rb b/lib/chef/resource/cookbook_file.rb index 5981aab194..c0e33f80fb 100644 --- a/lib/chef/resource/cookbook_file.rb +++ b/lib/chef/resource/cookbook_file.rb @@ -21,7 +21,7 @@ require_relative "file" require_relative "../provider/cookbook_file" require_relative "../mixin/securable" -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -31,7 +31,7 @@ class Chef provides :cookbook_file - description "Use the **cookbook_file** resource to transfer files from a sub-directory of COOKBOOK_NAME/files/ to a specified path located on a host that is running the #{Chef::Dist::PRODUCT}. The file is selected according to file specificity, which allows different source files to be used based on the hostname, host platform (operating system, distro, or as appropriate), or platform version. Files that are located in the COOKBOOK_NAME/files/default sub-directory may be used on any platform.\n\nDuring a #{Chef::Dist::PRODUCT} run, the checksum for each local file is calculated and then compared against the checksum for the same file as it currently exists in the cookbook on the #{Chef::Dist::SERVER_PRODUCT}. A file is not transferred when the checksums match. Only files that require an update are transferred from the #{Chef::Dist::SERVER_PRODUCT} to a node." + description "Use the **cookbook_file** resource to transfer files from a sub-directory of COOKBOOK_NAME/files/ to a specified path located on a host that is running the #{ChefUtils::Dist::Infra::PRODUCT}. The file is selected according to file specificity, which allows different source files to be used based on the hostname, host platform (operating system, distro, or as appropriate), or platform version. Files that are located in the COOKBOOK_NAME/files/default sub-directory may be used on any platform.\n\nDuring a #{ChefUtils::Dist::Infra::PRODUCT} run, the checksum for each local file is calculated and then compared against the checksum for the same file as it currently exists in the cookbook on the #{ChefUtils::Dist::Server::PRODUCT}. A file is not transferred when the checksums match. Only files that require an update are transferred from the #{ChefUtils::Dist::Server::PRODUCT} to a node." property :source, [ String, Array ], description: "The name of the file in COOKBOOK_NAME/files/default or the path to a file located in COOKBOOK_NAME/files. The path must include the file name and its extension. This can be used to distribute specific files depending upon the platform used.", diff --git a/lib/chef/resource/cron/cron_d.rb b/lib/chef/resource/cron/cron_d.rb index 882544a8bc..681a923acc 100644 --- a/lib/chef/resource/cron/cron_d.rb +++ b/lib/chef/resource/cron/cron_d.rb @@ -18,7 +18,7 @@ require_relative "../../resource" require_relative "../helpers/cron_validations" require "shellwords" unless defined?(Shellwords) -require_relative "../../dist" +require "chef-utils" class Chef class Resource diff --git a/lib/chef/resource/dnf_package.rb b/lib/chef/resource/dnf_package.rb index b2401c797d..53f05f280d 100644 --- a/lib/chef/resource/dnf_package.rb +++ b/lib/chef/resource/dnf_package.rb @@ -18,7 +18,7 @@ require_relative "package" require_relative "../mixin/which" require_relative "../mixin/shell_out" -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -52,7 +52,7 @@ class Chef # Flush the in-memory available/installed cache, this does not flush the dnf caches on disk property :flush_cache, Hash, - description: "Flush the in-memory cache before or after a DNF operation that installs, upgrades, or removes a package. DNF automatically synchronizes remote metadata to a local cache. The #{Chef::Dist::CLIENT} creates a copy of the local cache, and then stores it in-memory during the #{Chef::Dist::CLIENT} run. The in-memory cache allows packages to be installed during the #{Chef::Dist::CLIENT} run without the need to continue synchronizing the remote metadata to the local cache while the #{Chef::Dist::CLIENT} run is in-progress.", + description: "Flush the in-memory cache before or after a DNF operation that installs, upgrades, or removes a package. DNF automatically synchronizes remote metadata to a local cache. The #{ChefUtils::Dist::Infra::CLIENT} creates a copy of the local cache, and then stores it in-memory during the #{ChefUtils::Dist::Infra::CLIENT} run. The in-memory cache allows packages to be installed during the #{ChefUtils::Dist::Infra::CLIENT} run without the need to continue synchronizing the remote metadata to the local cache while the #{ChefUtils::Dist::Infra::CLIENT} run is in-progress.", default: { before: false, after: false }, coerce: proc { |v| if v.is_a?(Hash) diff --git a/lib/chef/resource/dsc_resource.rb b/lib/chef/resource/dsc_resource.rb index 76d0b37b37..2aaf9c16a4 100644 --- a/lib/chef/resource/dsc_resource.rb +++ b/lib/chef/resource/dsc_resource.rb @@ -16,7 +16,7 @@ # limitations under the License. # require_relative "../dsl/powershell" -require_relative "../dist" +require "chef-utils" class Chef class Resource diff --git a/lib/chef/resource/dsc_script.rb b/lib/chef/resource/dsc_script.rb index 2a4392630b..5b574e3606 100644 --- a/lib/chef/resource/dsc_script.rb +++ b/lib/chef/resource/dsc_script.rb @@ -19,7 +19,7 @@ require_relative "../resource" require_relative "../exceptions" require_relative "../dsl/powershell" -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -29,7 +29,7 @@ class Chef unified_mode true provides :dsc_script - description "Many DSC resources are comparable to built-in #{Chef::Dist::PRODUCT} resources. For example, both DSC and #{Chef::Dist::PRODUCT} have file, package, and service resources. The dsc_script resource is most useful for those DSC resources that do not have a direct comparison to a resource in #{Chef::Dist::PRODUCT}, such as the Archive resource, a custom DSC resource, an existing DSC script that performs an important task, and so on. Use the dsc_script resource to embed the code that defines a DSC configuration directly within a #{Chef::Dist::PRODUCT} recipe." + description "Many DSC resources are comparable to built-in #{ChefUtils::Dist::Infra::PRODUCT} resources. For example, both DSC and #{ChefUtils::Dist::Infra::PRODUCT} have file, package, and service resources. The dsc_script resource is most useful for those DSC resources that do not have a direct comparison to a resource in #{ChefUtils::Dist::Infra::PRODUCT}, such as the Archive resource, a custom DSC resource, an existing DSC script that performs an important task, and so on. Use the dsc_script resource to embed the code that defines a DSC configuration directly within a #{ChefUtils::Dist::Infra::PRODUCT} recipe." default_action :run diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb index e8d74fa178..dfcb19d147 100644 --- a/lib/chef/resource/execute.rb +++ b/lib/chef/resource/execute.rb @@ -18,7 +18,7 @@ # require_relative "../resource" -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -533,7 +533,7 @@ class Chef description: "The group name or group ID that must be changed before running a command." property :live_stream, [ TrueClass, FalseClass ], default: false, - description: "Send the output of the command run by this execute resource block to the #{Chef::Dist::PRODUCT} event stream." + description: "Send the output of the command run by this execute resource block to the #{ChefUtils::Dist::Infra::PRODUCT} event stream." # default_env defaults to `false` so that the command execution more exactly matches what the user gets on the command line without magic property :default_env, [ TrueClass, FalseClass ], desired_state: false, default: false, @@ -553,7 +553,7 @@ class Chef property :domain, String, introduced: "12.21", - description: "Windows only: The domain of the user user specified by the user property. If not specified, the user name and password specified by the user and password properties will be used to resolve that user against the domain in which the system running #{Chef::Dist::PRODUCT} is joined, or if that system is not joined to a domain it will resolve the user as a local account on that system. An alternative way to specify the domain is to leave this property unspecified and specify the domain as part of the user property." + description: "Windows only: The domain of the user user specified by the user property. If not specified, the user name and password specified by the user and password properties will be used to resolve that user against the domain in which the system running #{ChefUtils::Dist::Infra::PRODUCT} is joined, or if that system is not joined to a domain it will resolve the user as a local account on that system. An alternative way to specify the domain is to leave this property unspecified and specify the domain as part of the user property." property :password, String, sensitive: true, introduced: "12.21", @@ -561,11 +561,11 @@ class Chef # lazy used to set default value of sensitive to true if password is set property :sensitive, [ TrueClass, FalseClass ], - description: "Ensure that sensitive resource data is not logged by the #{Chef::Dist::PRODUCT}.", + description: "Ensure that sensitive resource data is not logged by the #{ChefUtils::Dist::Infra::PRODUCT}.", default: lazy { password ? true : false }, default_description: "True if the password property is set. False otherwise." property :elevated, [ TrueClass, FalseClass ], default: false, - description: "Determines whether the script will run with elevated permissions to circumvent User Access Control (UAC) interactively blocking the process.\nThis will cause the process to be run under a batch login instead of an interactive login. The user running #{Chef::Dist::CLIENT} needs the 'Replace a process level token' and 'Adjust Memory Quotas for a process' permissions. The user that is running the command needs the 'Log on as a batch job' permission.\nBecause this requires a login, the user and password properties are required.", + description: "Determines whether the script will run with elevated permissions to circumvent User Access Control (UAC) interactively blocking the process.\nThis will cause the process to be run under a batch login instead of an interactive login. The user running #{ChefUtils::Dist::Infra::CLIENT} needs the 'Replace a process level token' and 'Adjust Memory Quotas for a process' permissions. The user that is running the command needs the 'Log on as a batch job' permission.\nBecause this requires a login, the user and password properties are required.", introduced: "13.3" property :input, [String], diff --git a/lib/chef/resource/file.rb b/lib/chef/resource/file.rb index eacddd02af..6cbb0fa523 100644 --- a/lib/chef/resource/file.rb +++ b/lib/chef/resource/file.rb @@ -22,7 +22,7 @@ require_relative "../platform/query_helpers" require_relative "../mixin/securable" require_relative "file/verification" require "pathname" unless defined?(Pathname) -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -56,7 +56,7 @@ class Chef allowed_actions :create, :delete, :touch, :create_if_missing property :path, String, name_property: true, - description: "The full path to the file, including the file name and its extension. For example: /files/file.txt. Default value: the name of the resource block. Microsoft Windows: A path that begins with a forward slash (/) will point to the root of the current working directory of the #{Chef::Dist::CLIENT} process. This path can vary from system to system. Therefore, using a path that begins with a forward slash (/) is not recommended." + description: "The full path to the file, including the file name and its extension. For example: /files/file.txt. Default value: the name of the resource block. Microsoft Windows: A path that begins with a forward slash (/) will point to the root of the current working directory of the #{ChefUtils::Dist::Infra::CLIENT} process. This path can vary from system to system. Therefore, using a path that begins with a forward slash (/) is not recommended." property :atomic_update, [ TrueClass, FalseClass ], desired_state: false, default: lazy { docker? && special_docker_files?(path) ? false : Chef::Config[:file_atomic_update] }, default_description: "False if modifying /etc/hosts, /etc/hostname, or /etc/resolv.conf within Docker containers. Otherwise default to the client.rb 'file_atomic_update' config value.", @@ -76,10 +76,10 @@ class Chef property :diff, [ String, nil ], desired_state: false, skip_docs: true property :force_unlink, [ TrueClass, FalseClass ], desired_state: false, default: false, - description: "How #{Chef::Dist::PRODUCT} handles certain situations when the target file turns out not to be a file. For example, when a target file is actually a symlink. Set to `true` for #{Chef::Dist::PRODUCT} to delete the non-file target and replace it with the specified file. Set to `false` for #{Chef::Dist::PRODUCT} to raise an error." + description: "How #{ChefUtils::Dist::Infra::PRODUCT} handles certain situations when the target file turns out not to be a file. For example, when a target file is actually a symlink. Set to `true` for #{ChefUtils::Dist::Infra::PRODUCT} to delete the non-file target and replace it with the specified file. Set to `false` for #{ChefUtils::Dist::Infra::PRODUCT} to raise an error." property :manage_symlink_source, [ TrueClass, FalseClass ], desired_state: false, - description: "Change the behavior of the file resource if it is pointed at a symlink. When this value is set to true, #{Chef::Dist::PRODUCT} will manage the symlink's permissions or will replace the symlink with a normal file if the resource has content. When this value is set to false, #{Chef::Dist::PRODUCT} will follow the symlink and will manage the permissions and content of symlink's target file. The default behavior is true but emits a warning that the default value will be changed to false in a future version; setting this explicitly to true or false suppresses this warning." + description: "Change the behavior of the file resource if it is pointed at a symlink. When this value is set to true, #{ChefUtils::Dist::Infra::PRODUCT} will manage the symlink's permissions or will replace the symlink with a normal file if the resource has content. When this value is set to false, #{ChefUtils::Dist::Infra::PRODUCT} will follow the symlink and will manage the permissions and content of symlink's target file. The default behavior is true but emits a warning that the default value will be changed to false in a future version; setting this explicitly to true or false suppresses this warning." property :verifications, Array, default: lazy { [] } diff --git a/lib/chef/resource/gem_package.rb b/lib/chef/resource/gem_package.rb index 05f8611233..8154b61ab3 100644 --- a/lib/chef/resource/gem_package.rb +++ b/lib/chef/resource/gem_package.rb @@ -17,7 +17,7 @@ # require_relative "package" -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -86,7 +86,7 @@ class Chef default: lazy { Chef::Config[:clear_gem_sources] }, desired_state: false property :gem_binary, String, desired_state: false, - description: "The path of a gem binary to use for the installation. By default, the same version of Ruby that is used by #{Chef::Dist::PRODUCT} will be used." + description: "The path of a gem binary to use for the installation. By default, the same version of Ruby that is used by #{ChefUtils::Dist::Infra::PRODUCT} will be used." property :include_default_source, [ TrueClass, FalseClass, nil ], description: "Set to `false` to not include `Chef::Config[:rubygems_url]` in the sources.", diff --git a/lib/chef/resource/homebrew_package.rb b/lib/chef/resource/homebrew_package.rb index fef0561e38..6113bf54b0 100644 --- a/lib/chef/resource/homebrew_package.rb +++ b/lib/chef/resource/homebrew_package.rb @@ -19,7 +19,7 @@ require_relative "../provider/package" require_relative "package" -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -62,7 +62,7 @@ class Chef DOC property :homebrew_user, [ String, Integer ], - description: "The name or uid of the Homebrew owner to be used by #{Chef::Dist::PRODUCT} when executing a command." + description: "The name or uid of the Homebrew owner to be used by #{ChefUtils::Dist::Infra::PRODUCT} when executing a command." end end diff --git a/lib/chef/resource/locale.rb b/lib/chef/resource/locale.rb index ea7f5098ab..f6878ba894 100644 --- a/lib/chef/resource/locale.rb +++ b/lib/chef/resource/locale.rb @@ -16,7 +16,7 @@ # require_relative "../resource" -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -71,7 +71,7 @@ class Chef # def lc_all(arg = nil) unless arg.nil? - Chef.deprecated(:locale_lc_all, "Changing LC_ALL can break #{Chef::Dist::PRODUCT}'s parsing of command output in unexpected ways.\n Use one of the more specific LC_ properties as needed.") + Chef.deprecated(:locale_lc_all, "Changing LC_ALL can break #{ChefUtils::Dist::Infra::PRODUCT}'s parsing of command output in unexpected ways.\n Use one of the more specific LC_ properties as needed.") end end diff --git a/lib/chef/resource/notify_group.rb b/lib/chef/resource/notify_group.rb index a8bc71527d..dc0ab71496 100644 --- a/lib/chef/resource/notify_group.rb +++ b/lib/chef/resource/notify_group.rb @@ -15,7 +15,7 @@ # require_relative "../resource" -require_relative "../dist" +require "chef-utils" class Chef class Resource diff --git a/lib/chef/resource/ohai.rb b/lib/chef/resource/ohai.rb index 93fdb82676..cfdf636299 100644 --- a/lib/chef/resource/ohai.rb +++ b/lib/chef/resource/ohai.rb @@ -19,7 +19,7 @@ # require_relative "../resource" -require_relative "../dist" +require "chef-utils" require "ohai" unless defined?(Ohai::System) class Chef @@ -29,10 +29,10 @@ class Chef provides :ohai - description "Use the **ohai** resource to reload the Ohai configuration on a node. This allows recipes that change system attributes (like a recipe that adds a user) to refer to those attributes later on during the #{Chef::Dist::CLIENT} run." + description "Use the **ohai** resource to reload the Ohai configuration on a node. This allows recipes that change system attributes (like a recipe that adds a user) to refer to those attributes later on during the #{ChefUtils::Dist::Infra::CLIENT} run." property :plugin, String, - description: "The name of an Ohai plugin to be reloaded. If this property is not specified, #{Chef::Dist::PRODUCT} will reload all plugins." + description: "The name of an Ohai plugin to be reloaded. If this property is not specified, #{ChefUtils::Dist::Infra::PRODUCT} will reload all plugins." def load_current_resource true diff --git a/lib/chef/resource/reboot.rb b/lib/chef/resource/reboot.rb index 38a493cfae..93ca2cdd5f 100644 --- a/lib/chef/resource/reboot.rb +++ b/lib/chef/resource/reboot.rb @@ -17,7 +17,7 @@ # require_relative "../resource" -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -36,7 +36,7 @@ class Chef property :reason, String, description: "A string that describes the reboot action.", - default: "Reboot by #{Chef::Dist::PRODUCT}" + default: "Reboot by #{ChefUtils::Dist::Infra::PRODUCT}" property :delay_mins, Integer, description: "The amount of time (in minutes) to delay a reboot request.", diff --git a/lib/chef/resource/rhsm_register.rb b/lib/chef/resource/rhsm_register.rb index 80cf62e169..c12b96106c 100644 --- a/lib/chef/resource/rhsm_register.rb +++ b/lib/chef/resource/rhsm_register.rb @@ -16,7 +16,7 @@ # require_relative "../resource" -require_relative "../dist" +require "chef-utils" require "shellwords" unless defined?(Shellwords) class Chef @@ -65,7 +65,7 @@ class Chef default: false, desired_state: false property :https_for_ca_consumer, [TrueClass, FalseClass], - description: "If true, #{Chef::Dist::PRODUCT} will fetch the katello-ca-consumer-latest.noarch.rpm from the satellite_host using HTTPS.", + description: "If true, #{ChefUtils::Dist::Infra::PRODUCT} will fetch the katello-ca-consumer-latest.noarch.rpm from the satellite_host using HTTPS.", default: false, desired_state: false, introduced: "15.9" diff --git a/lib/chef/resource/ruby_block.rb b/lib/chef/resource/ruby_block.rb index 1fcebe090a..1b738a6507 100644 --- a/lib/chef/resource/ruby_block.rb +++ b/lib/chef/resource/ruby_block.rb @@ -19,7 +19,7 @@ require_relative "../resource" require_relative "../provider/ruby_block" -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -28,7 +28,7 @@ class Chef provides :ruby_block, target_mode: true - description "Use the **ruby_block** resource to execute Ruby code during a #{Chef::Dist::PRODUCT} run. Ruby code in the ruby_block resource is evaluated with other resources during convergence, whereas Ruby code outside of a ruby_block resource is evaluated before other resources, as the recipe is compiled." + description "Use the **ruby_block** resource to execute Ruby code during a #{ChefUtils::Dist::Infra::PRODUCT} run. Ruby code in the ruby_block resource is evaluated with other resources during convergence, whereas Ruby code outside of a ruby_block resource is evaluated before other resources, as the recipe is compiled." default_action :run allowed_actions :create, :run diff --git a/lib/chef/resource/scm/subversion.rb b/lib/chef/resource/scm/subversion.rb index 14360e9816..273f505ae6 100644 --- a/lib/chef/resource/scm/subversion.rb +++ b/lib/chef/resource/scm/subversion.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require_relative "../../dist" +require "chef-utils" class Chef class Resource @@ -38,7 +38,7 @@ class Chef default: "--no-auth-cache" property :svn_info_args, [String, nil, FalseClass], - description: "Use when the `svn info` command is used by #{Chef::Dist::PRODUCT} and arguments need to be passed. The `svn_arguments` command does not work when the `svn info` command is used.", + description: "Use when the `svn info` command is used by #{ChefUtils::Dist::Infra::PRODUCT} and arguments need to be passed. The `svn_arguments` command does not work when the `svn info` command is used.", coerce: proc { |v| v == false ? nil : v }, # coerce false to nil default: "--no-auth-cache" diff --git a/lib/chef/resource/service.rb b/lib/chef/resource/service.rb index 9a6ad20ee8..f2e02b2b8d 100644 --- a/lib/chef/resource/service.rb +++ b/lib/chef/resource/service.rb @@ -20,7 +20,7 @@ require "chef-utils/dsl/service" unless defined?(ChefUtils::DSL::Service) require_relative "../resource" require "shellwords" unless defined?(Shellwords) -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -39,7 +39,7 @@ class Chef # this is a poor API please do not re-use this pattern property :supports, Hash, default: { restart: nil, reload: nil, status: nil }, - description: "A list of properties that controls how #{Chef::Dist::PRODUCT} is to attempt to manage a service: :restart, :reload, :status. For :restart, the init script or other service provider can use a restart command; if :restart is not specified, the #{Chef::Dist::CLIENT} attempts to stop and then start a service. For :reload, the init script or other service provider can use a reload command. For :status, the init script or other service provider can use a status command to determine if the service is running; if :status is not specified, the #{Chef::Dist::CLIENT} attempts to match the service_name against the process table as a regular expression, unless a pattern is specified as a parameter property. Default value: { restart: false, reload: false, status: false } for all platforms (except for the Red Hat platform family, which defaults to { restart: false, reload: false, status: true }.)", + description: "A list of properties that controls how #{ChefUtils::Dist::Infra::PRODUCT} is to attempt to manage a service: :restart, :reload, :status. For :restart, the init script or other service provider can use a restart command; if :restart is not specified, the #{ChefUtils::Dist::Infra::CLIENT} attempts to stop and then start a service. For :reload, the init script or other service provider can use a reload command. For :status, the init script or other service provider can use a status command to determine if the service is running; if :status is not specified, the #{ChefUtils::Dist::Infra::CLIENT} attempts to match the service_name against the process table as a regular expression, unless a pattern is specified as a parameter property. Default value: { restart: false, reload: false, status: false } for all platforms (except for the Red Hat platform family, which defaults to { restart: false, reload: false, status: true }.)", coerce: proc { |x| x.is_a?(Array) ? x.each_with_object({}) { |i, m| m[i] = true } : x } property :service_name, String, @@ -82,7 +82,7 @@ class Chef # specify overrides for the start_command, stop_command and # restart_command properties. property :init_command, String, - description: "The path to the init script that is associated with the service. Use init_command to prevent the need to specify overrides for the start_command, stop_command, and restart_command properties. When this property is not specified, the #{Chef::Dist::PRODUCT} will use the default init command for the service provider being used.", + description: "The path to the init script that is associated with the service. Use init_command to prevent the need to specify overrides for the start_command, stop_command, and restart_command properties. When this property is not specified, the #{ChefUtils::Dist::Infra::PRODUCT} will use the default init command for the service provider being used.", desired_state: false # if the service is enabled or not diff --git a/lib/chef/resource/ssh_known_hosts_entry.rb b/lib/chef/resource/ssh_known_hosts_entry.rb index 533cb42279..f810ac9604 100644 --- a/lib/chef/resource/ssh_known_hosts_entry.rb +++ b/lib/chef/resource/ssh_known_hosts_entry.rb @@ -18,7 +18,7 @@ # limitations under the License. require_relative "../resource" -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -130,7 +130,7 @@ class Chef # all this does is send an immediate run_action(:create) to the template resource action :flush do - description "Immediately flush the entries to the config file. Without this the actual writing of the file is delayed in the #{Chef::Dist::PRODUCT} run so all entries can be accumulated before writing the file out." + description "Immediately flush the entries to the config file. Without this the actual writing of the file is delayed in the #{ChefUtils::Dist::Infra::PRODUCT} run so all entries can be accumulated before writing the file out." with_run_context :root do # if you haven't ever called ssh_known_hosts_entry before you're definitely doing it wrong so we blow up hard. diff --git a/lib/chef/resource/support/cron.d.erb b/lib/chef/resource/support/cron.d.erb index a00b541cd1..579e64f405 100644 --- a/lib/chef/resource/support/cron.d.erb +++ b/lib/chef/resource/support/cron.d.erb @@ -1,4 +1,4 @@ -# Generated by <%= Chef::Dist::PRODUCT %>. Changes will be overwritten. +# Generated by <%= ChefUtils::Dist::Infra::PRODUCT %>. Changes will be overwritten. <% if @mailto -%> MAILTO=<%= @mailto %> <% end -%> diff --git a/lib/chef/resource/support/cron_access.erb b/lib/chef/resource/support/cron_access.erb index 5e5813457c..1f4e74ab23 100644 --- a/lib/chef/resource/support/cron_access.erb +++ b/lib/chef/resource/support/cron_access.erb @@ -1,4 +1,4 @@ -# Generated by <%= Chef::Dist::PRODUCT %>. Changes will be overwritten. +# Generated by <%= ChefUtils::Dist::Infra::PRODUCT %>. Changes will be overwritten. <% @users.sort.uniq.each do |user| -%> <%= user %> <% end -%> diff --git a/lib/chef/resource/support/sudoer.erb b/lib/chef/resource/support/sudoer.erb index 8c570affdc..f8c9760d94 100644 --- a/lib/chef/resource/support/sudoer.erb +++ b/lib/chef/resource/support/sudoer.erb @@ -1,4 +1,4 @@ -# This file is managed by <%= Chef::Dist::PRODUCT %>. Changes will be overwritten. +# This file is managed by <%= ChefUtils::Dist::Infra::PRODUCT %>. Changes will be overwritten. <% @command_aliases.each do |a| -%> Cmnd_Alias <%= a[:name].upcase %> = <%= a[:command_list].join(', ') %> diff --git a/lib/chef/resource/support/ulimit.erb b/lib/chef/resource/support/ulimit.erb index 6abfc14e07..25ac0fde5c 100644 --- a/lib/chef/resource/support/ulimit.erb +++ b/lib/chef/resource/support/ulimit.erb @@ -1,4 +1,4 @@ -# Generated by <%= Chef::Dist::PRODUCT %>. Changes will be overwritten. +# Generated by <%= ChefUtils::Dist::Infra::PRODUCT %>. Changes will be overwritten. # Limits settings for <%= @ulimit_user %> diff --git a/lib/chef/resource/systemd_unit.rb b/lib/chef/resource/systemd_unit.rb index 8bb14be636..7ddf71069c 100644 --- a/lib/chef/resource/systemd_unit.rb +++ b/lib/chef/resource/systemd_unit.rb @@ -17,7 +17,7 @@ # require_relative "../resource" -require_relative "../dist" +require "chef-utils" require "iniparse" class Chef @@ -52,7 +52,7 @@ class Chef description: "The user account that the systemd unit process is run under. The path to the unit for that user would be something like '/etc/systemd/user/sshd.service'. If no user account is specified, the systemd unit will run under a 'system' account, with the path to the unit being something like '/etc/systemd/system/sshd.service'." property :content, [String, Hash], - description: "A string or hash that contains a systemd [unit file](https://www.freedesktop.org/software/systemd/man/systemd.unit.html) definition that describes the properties of systemd-managed entities, such as services, sockets, devices, and so on. In #{Chef::Dist::PRODUCT} 14.4 or later, repeatable options can be implemented with an array." + description: "A string or hash that contains a systemd [unit file](https://www.freedesktop.org/software/systemd/man/systemd.unit.html) definition that describes the properties of systemd-managed entities, such as services, sockets, devices, and so on. In #{ChefUtils::Dist::Infra::PRODUCT} 14.4 or later, repeatable options can be implemented with an array." property :triggers_reload, [TrueClass, FalseClass], description: "Specifies whether to trigger a daemon reload when creating or deleting a unit.", diff --git a/lib/chef/resource/template.rb b/lib/chef/resource/template.rb index 0ffa2194d8..51f0613a21 100644 --- a/lib/chef/resource/template.rb +++ b/lib/chef/resource/template.rb @@ -20,7 +20,7 @@ require_relative "file" require_relative "../mixin/securable" -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -69,7 +69,7 @@ class Chef property :local, [ TrueClass, FalseClass ], default: false, desired_state: false, - description: "Load a template from a local path. By default, the #{Chef::Dist::CLIENT} loads templates from a cookbook's /templates directory. When this property is set to true, use the source property to specify the path to a template on the local node." + description: "Load a template from a local path. By default, the #{ChefUtils::Dist::Infra::CLIENT} loads templates from a cookbook's /templates directory. When this property is set to true, use the source property to specify the path to a template on the local node." # Declares a helper method to be defined in the template context when # rendering. diff --git a/lib/chef/resource/windows_ad_join.rb b/lib/chef/resource/windows_ad_join.rb index d46a5399e5..2a8250d012 100644 --- a/lib/chef/resource/windows_ad_join.rb +++ b/lib/chef/resource/windows_ad_join.rb @@ -16,7 +16,7 @@ # require_relative "../resource" -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -76,8 +76,8 @@ class Chef property :reboot, Symbol, equal_to: %i{immediate delayed never request_reboot reboot_now}, - validation_message: "The reboot property accepts :immediate (reboot as soon as the resource completes), :delayed (reboot once the #{Chef::Dist::PRODUCT} run completes), and :never (Don't reboot)", - description: "Controls the system reboot behavior post domain joining. Reboot immediately, after the #{Chef::Dist::PRODUCT} run completes, or never. Note that a reboot is necessary for changes to take effect.", + validation_message: "The reboot property accepts :immediate (reboot as soon as the resource completes), :delayed (reboot once the #{ChefUtils::Dist::Infra::PRODUCT} run completes), and :never (Don't reboot)", + description: "Controls the system reboot behavior post domain joining. Reboot immediately, after the #{ChefUtils::Dist::Infra::PRODUCT} run completes, or never. Note that a reboot is necessary for changes to take effect.", default: :immediate property :reboot_delay, Integer, diff --git a/lib/chef/resource/windows_certificate.rb b/lib/chef/resource/windows_certificate.rb index 215f87d9c3..624ba4e795 100644 --- a/lib/chef/resource/windows_certificate.rb +++ b/lib/chef/resource/windows_certificate.rb @@ -23,7 +23,7 @@ module Win32 autoload :Certstore, "win32-certstore" if Chef::Platform.windows? end autoload :OpenSSL, "openssl" -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -84,7 +84,7 @@ class Chef # lazy used to set default value of sensitive to true if password is set property :sensitive, [TrueClass, FalseClass], - description: "Ensure that sensitive resource data is not logged by the #{Chef::Dist::CLIENT}.", + description: "Ensure that sensitive resource data is not logged by the #{ChefUtils::Dist::Infra::CLIENT}.", default: lazy { pfx_password ? true : false }, skip_docs: true action :create do diff --git a/lib/chef/resource/windows_package.rb b/lib/chef/resource/windows_package.rb index b11567311f..d702fa4d24 100644 --- a/lib/chef/resource/windows_package.rb +++ b/lib/chef/resource/windows_package.rb @@ -20,7 +20,7 @@ require_relative "../mixin/uris" require_relative "package" require_relative "../provider/package/windows" require_relative "../win32/error" if RUBY_PLATFORM.match?(/mswin|mingw|windows/) -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -162,7 +162,7 @@ class Chef property :checksum, String, desired_state: false, coerce: (proc { |c| c.downcase }), - description: "The SHA-256 checksum of the file. Use to prevent a file from being re-downloaded. When the local file matches the checksum, #{Chef::Dist::PRODUCT} does not download it. Use when a URL is specified by the `source` property." + description: "The SHA-256 checksum of the file. Use to prevent a file from being re-downloaded. When the local file matches the checksum, #{ChefUtils::Dist::Infra::PRODUCT} does not download it. Use when a URL is specified by the `source` property." property :remote_file_attributes, Hash, desired_state: false, diff --git a/lib/chef/resource/windows_workgroup.rb b/lib/chef/resource/windows_workgroup.rb index ce6129c4f7..244f622861 100644 --- a/lib/chef/resource/windows_workgroup.rb +++ b/lib/chef/resource/windows_workgroup.rb @@ -16,7 +16,7 @@ # require_relative "../resource" -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -59,8 +59,8 @@ class Chef property :reboot, Symbol, equal_to: %i{never request_reboot reboot_now}, - validation_message: "The reboot property accepts :immediate (reboot as soon as the resource completes), :delayed (reboot once the #{Chef::Dist::PRODUCT} run completes), and :never (Don't reboot)", - description: "Controls the system reboot behavior post workgroup joining. Reboot immediately, after the #{Chef::Dist::PRODUCT} run completes, or never. Note that a reboot is necessary for changes to take effect.", + validation_message: "The reboot property accepts :immediate (reboot as soon as the resource completes), :delayed (reboot once the #{ChefUtils::Dist::Infra::PRODUCT} run completes), and :never (Don't reboot)", + description: "Controls the system reboot behavior post workgroup joining. Reboot immediately, after the #{ChefUtils::Dist::Infra::PRODUCT} run completes, or never. Note that a reboot is necessary for changes to take effect.", coerce: proc { |x| clarify_reboot(x) }, default: :immediate, desired_state: false diff --git a/lib/chef/resource/yum_package.rb b/lib/chef/resource/yum_package.rb index 7db8bcc948..75c9c5e152 100644 --- a/lib/chef/resource/yum_package.rb +++ b/lib/chef/resource/yum_package.rb @@ -17,7 +17,7 @@ # require_relative "package" -require_relative "../dist" +require "chef-utils" class Chef class Resource @@ -135,7 +135,7 @@ class Chef coerce: proc { |x| x.is_a?(Array) ? x.to_a : x } property :flush_cache, Hash, - description: "Flush the in-memory cache before or after a Yum operation that installs, upgrades, or removes a package. Accepts a Hash in the form: { :before => true/false, :after => true/false } or an Array in the form [ :before, :after ].\nYum automatically synchronizes remote metadata to a local cache. The #{Chef::Dist::CLIENT} creates a copy of the local cache, and then stores it in-memory during the #{Chef::Dist::CLIENT} run. The in-memory cache allows packages to be installed during the #{Chef::Dist::CLIENT} run without the need to continue synchronizing the remote metadata to the local cache while the #{Chef::Dist::CLIENT} run is in-progress.", + description: "Flush the in-memory cache before or after a Yum operation that installs, upgrades, or removes a package. Accepts a Hash in the form: { :before => true/false, :after => true/false } or an Array in the form [ :before, :after ].\nYum automatically synchronizes remote metadata to a local cache. The #{ChefUtils::Dist::Infra::CLIENT} creates a copy of the local cache, and then stores it in-memory during the #{ChefUtils::Dist::Infra::CLIENT} run. The in-memory cache allows packages to be installed during the #{ChefUtils::Dist::Infra::CLIENT} run without the need to continue synchronizing the remote metadata to the local cache while the #{ChefUtils::Dist::Infra::CLIENT} run is in-progress.", default: { before: false, after: false }, coerce: proc { |v| if v.is_a?(Hash) diff --git a/lib/chef/run_lock.rb b/lib/chef/run_lock.rb index a7c66837d5..8dec24ca8c 100644 --- a/lib/chef/run_lock.rb +++ b/lib/chef/run_lock.rb @@ -23,7 +23,7 @@ end require_relative "config" require_relative "exceptions" require "timeout" unless defined?(Timeout) -require_relative "dist" +require "chef-utils" class Chef @@ -96,7 +96,7 @@ class Chef # Waits until acquiring the system-wide lock. # def wait - Chef::Log.warn("#{Chef::Dist::PRODUCT} #{runpid} is running, will wait for it to finish and then run.") + Chef::Log.warn("#{ChefUtils::Dist::Infra::PRODUCT} #{runpid} is running, will wait for it to finish and then run.") if ChefUtils.windows? mutex.wait else diff --git a/lib/chef/shell.rb b/lib/chef/shell.rb index 1a012144ed..16ebff6f04 100644 --- a/lib/chef/shell.rb +++ b/lib/chef/shell.rb @@ -30,7 +30,7 @@ require_relative "version" require_relative "client" require_relative "config" require_relative "config_fetcher" -require_relative "dist" +require "chef-utils" require_relative "shell/shell_session" require_relative "workstation_config_loader" @@ -131,11 +131,11 @@ module Shell irb_conf[:IRB_RC] = lambda do |conf| m = conf.main - conf.prompt_c = "#{Chef::Dist::EXEC}#{leader(m)} > " + conf.prompt_c = "#{ChefUtils::Dist::Infra::EXEC}#{leader(m)} > " conf.return_format = " => %s \n" - conf.prompt_i = "#{Chef::Dist::EXEC}#{leader(m)} (#{Chef::VERSION})> " - conf.prompt_n = "#{Chef::Dist::EXEC}#{leader(m)} ?> " - conf.prompt_s = "#{Chef::Dist::EXEC}#{leader(m)}%l> " + conf.prompt_i = "#{ChefUtils::Dist::Infra::EXEC}#{leader(m)} (#{Chef::VERSION})> " + conf.prompt_n = "#{ChefUtils::Dist::Infra::EXEC}#{leader(m)} ?> " + conf.prompt_s = "#{ChefUtils::Dist::Infra::EXEC}#{leader(m)}%l> " conf.use_tracer = false conf.instance_variable_set(:@use_multiline, false) conf.instance_variable_set(:@use_singleline, false) @@ -217,17 +217,17 @@ module Shell @footer end - banner("#{Chef::Dist::SHELL} #{Chef::VERSION}\n\nUsage: #{Chef::Dist::SHELL} [NAMED_CONF] (OPTIONS)") + banner("#{ChefUtils::Dist::Infra::SHELL} #{Chef::VERSION}\n\nUsage: #{ChefUtils::Dist::Infra::SHELL} [NAMED_CONF] (OPTIONS)") footer(<<~FOOTER) - When no CONFIG is specified, #{Chef::Dist::SHELL} attempts to load a default configuration file: - * If a NAMED_CONF is given, #{Chef::Dist::SHELL} will load ~/#{Chef::Dist::USER_CONF_DIR}/NAMED_CONF/#{Chef::Dist::SHELL_CONF} - * If no NAMED_CONF is given #{Chef::Dist::SHELL} will load ~/#{Chef::Dist::USER_CONF_DIR}/#{Chef::Dist::SHELL_CONF} if it exists - * If no #{Chef::Dist::SHELL_CONF} can be found, #{Chef::Dist::SHELL} falls back to load: - #{Chef::Dist::CONF_DIR}/client.rb if -z option is given. - #{Chef::Dist::CONF_DIR}/solo.rb if --solo-legacy-mode option is given. - #{Chef::Dist::USER_CONF_DIR}/config.rb if -s option is given. - #{Chef::Dist::USER_CONF_DIR}/knife.rb if -s option is given. + When no CONFIG is specified, #{ChefUtils::Dist::Infra::SHELL} attempts to load a default configuration file: + * If a NAMED_CONF is given, #{ChefUtils::Dist::Infra::SHELL} will load ~/#{ChefUtils::Dist::Infra::USER_CONF_DIR}/NAMED_CONF/#{ChefUtils::Dist::Infra::SHELL_CONF} + * If no NAMED_CONF is given #{ChefUtils::Dist::Infra::SHELL} will load ~/#{ChefUtils::Dist::Infra::USER_CONF_DIR}/#{ChefUtils::Dist::Infra::SHELL_CONF} if it exists + * If no #{ChefUtils::Dist::Infra::SHELL_CONF} can be found, #{ChefUtils::Dist::Infra::SHELL} falls back to load: + #{ChefConfig::Config.etc_chef_dir}/client.rb if -z option is given. + #{ChefConfig::Config.etc_chef_dir}/solo.rb if --solo-legacy-mode option is given. + #{ChefUtils::Dist::Infra::USER_CONF_DIR}/config.rb if -s option is given. + #{ChefUtils::Dist::Infra::USER_CONF_DIR}/knife.rb if -s option is given. FOOTER option :use_multiline, @@ -274,19 +274,19 @@ module Shell option :solo_shell, short: "-s", long: "--solo", - description: "#{Chef::Dist::SOLO} session", + description: "#{ChefUtils::Dist::Solo::PRODUCT} session", boolean: true, proc: proc { Chef::Config[:solo] = true } option :client, short: "-z", long: "--client", - description: "#{Chef::Dist::PRODUCT} session", + description: "#{ChefUtils::Dist::Infra::PRODUCT} session", boolean: true option :solo_legacy_shell, long: "--solo-legacy-mode", - description: "#{Chef::Dist::SOLO} legacy session", + description: "#{ChefUtils::Dist::Solo::PRODUCT} legacy session", boolean: true, proc: proc { Chef::Config[:solo_legacy_mode] = true } @@ -299,15 +299,15 @@ module Shell option :chef_server_url, short: "-S CHEFSERVERURL", long: "--server CHEFSERVERURL", - description: "The #{Chef::Dist::SERVER_PRODUCT} URL", + description: "The #{ChefUtils::Dist::Server::PRODUCT} URL", proc: nil option :version, short: "-v", long: "--version", - description: "Show #{Chef::Dist::PRODUCT} version", + description: "Show #{ChefUtils::Dist::Infra::PRODUCT} version", boolean: true, - proc: lambda { |v| puts "#{Chef::Dist::PRODUCT}: #{::Chef::VERSION}" }, + proc: lambda { |v| puts "#{ChefUtils::Dist::Infra::PRODUCT}: #{::Chef::VERSION}" }, exit: 0 option :override_runlist, @@ -356,18 +356,18 @@ module Shell config[:config_file] elsif environment Shell.env = environment - config_file_to_try = ::File.join(dot_chef_dir, environment, Chef::Dist::SHELL_CONF) + config_file_to_try = ::File.join(dot_chef_dir, environment, ChefUtils::Dist::Infra::SHELL_CONF) unless ::File.exist?(config_file_to_try) - puts "could not find #{Chef::Dist::SHELL} config for environment #{environment} at #{config_file_to_try}" + puts "could not find #{ChefUtils::Dist::Infra::SHELL} config for environment #{environment} at #{config_file_to_try}" exit 1 end config_file_to_try - elsif dot_chef_dir && ::File.exist?(File.join(dot_chef_dir, Chef::Dist::SHELL_CONF)) - File.join(dot_chef_dir, Chef::Dist::SHELL_CONF) + elsif dot_chef_dir && ::File.exist?(File.join(dot_chef_dir, ChefUtils::Dist::Infra::SHELL_CONF)) + File.join(dot_chef_dir, ChefUtils::Dist::Infra::SHELL_CONF) elsif config[:solo_legacy_shell] - Chef::Config.platform_specific_path("#{Chef::Dist::CONF_DIR}/solo.rb") + "#{ChefConfig::Config.etc_chef_dir}/solo.rb" elsif config[:client] - Chef::Config.platform_specific_path("#{Chef::Dist::CONF_DIR}/client.rb") + "#{ChefConfig::Config.etc_chef_dir}/client.rb" elsif config[:solo_shell] Chef::WorkstationConfigLoader.new(nil, Chef::Log).config_location else diff --git a/lib/chef/shell/ext.rb b/lib/chef/shell/ext.rb index f8b8d2e0e3..6175bab492 100644 --- a/lib/chef/shell/ext.rb +++ b/lib/chef/shell/ext.rb @@ -25,7 +25,7 @@ require_relative "shell_session" require_relative "model_wrapper" require_relative "../server_api" require_relative "../json_compat" -require_relative "../dist" +require "chef-utils" module Shell module Extensions @@ -69,7 +69,7 @@ module Shell def help_banner banner = [] banner << "" - banner << "#{Chef::Dist::SHELL} Help" + banner << "#{ChefUtils::Dist::Infra::SHELL} Help" banner << "".ljust(80, "=") banner << "| " + "Command".ljust(25) + "| " + "Description" banner << "".ljust(80, "=") @@ -194,7 +194,7 @@ module Shell explain(<<~E) ## SUMMARY ## When called with no argument, +help+ prints a table of all - #{Chef::Dist::SHELL} commands. When called with an argument COMMAND, +help+ + #{ChefUtils::Dist::Infra::SHELL} commands. When called with an argument COMMAND, +help+ prints a detailed explanation of the command if available, or the description if no explanation is available. E @@ -208,9 +208,9 @@ module Shell end alias :halp :help - desc "prints information about #{Chef::Dist::PRODUCT}" + desc "prints information about #{ChefUtils::Dist::Infra::PRODUCT}" def version - puts "Welcome to the #{Chef::Dist::SHELL} #{::Chef::VERSION}\n" + + puts "Welcome to the #{ChefUtils::Dist::Infra::SHELL} #{::Chef::VERSION}\n" + "For usage see https://docs.chef.io/chef_shell/" :ucanhaz_automation end @@ -228,7 +228,7 @@ module Shell :attributes end - desc "run #{Chef::Dist::PRODUCT} using the current recipe" + desc "run #{ChefUtils::Dist::Infra::PRODUCT} using the current recipe" def run_chef Chef::Log.level = :debug session = Shell.session @@ -237,8 +237,8 @@ module Shell runrun end - desc "returns an object to control a paused #{Chef::Dist::PRODUCT} run" - subcommands resume: "resume the #{Chef::Dist::PRODUCT} run", + desc "returns an object to control a paused #{ChefUtils::Dist::Infra::PRODUCT} run" + subcommands resume: "resume the #{ChefUtils::Dist::Infra::PRODUCT} run", step: "run only the next resource", skip_back: "move back in the run list", skip_forward: "move forward in the run list" @@ -309,9 +309,9 @@ module Shell new_node = edit(existing_node) ## EDITOR SELECTION ## - #{Chef::Dist::SHELL} looks for an editor using the following logic + #{ChefUtils::Dist::Infra::SHELL} looks for an editor using the following logic 1. Looks for an EDITOR set by Shell.editor = "EDITOR" - 2. Looks for an EDITOR configured in your #{Chef::Dist::SHELL} config file + 2. Looks for an EDITOR configured in your #{ChefUtils::Dist::Infra::SHELL} config file 3. Uses the value of the EDITOR environment variable E def edit(object) @@ -320,7 +320,7 @@ module Shell return :failburger end - filename = "#{Chef::Dist::SHELL}-edit-#{object.class.name}-" + filename = "#{ChefUtils::Dist::Infra::SHELL}-edit-#{object.class.name}-" if object.respond_to?(:name) filename += object.name elsif object.respond_to?(:id) diff --git a/lib/chef/shell/shell_session.rb b/lib/chef/shell/shell_session.rb index a1957c6667..ca3d84cea9 100644 --- a/lib/chef/shell/shell_session.rb +++ b/lib/chef/shell/shell_session.rb @@ -28,7 +28,7 @@ require_relative "../run_list/run_list_expansion" require_relative "../formatters/base" require_relative "../formatters/doc" require_relative "../formatters/minimal" -require_relative "../dist" +require "chef-utils" module Shell class ShellSession @@ -90,7 +90,7 @@ module Shell end def save_node - raise "Not Supported! #{self.class.name} doesn't support #save_node, maybe you need to run #{Chef::Dist::SHELL} in client mode?" + raise "Not Supported! #{self.class.name} doesn't support #save_node, maybe you need to run #{ChefUtils::Dist::Infra::SHELL} in client mode?" end def rebuild_context diff --git a/lib/chef/train_transport.rb b/lib/chef/train_transport.rb index a4f311fc51..ba935f637f 100644 --- a/lib/chef/train_transport.rb +++ b/lib/chef/train_transport.rb @@ -17,7 +17,7 @@ require "chef-config/mixin/credentials" autoload :Train, "train" -require_relative "dist" +require "chef-utils" class Chef class TrainTransport @@ -77,8 +77,8 @@ class Chef credentials_file = if tm_config.credentials_file && File.exist?(tm_config.credentials_file) tm_config.credentials_file - elsif File.exist?(Chef::Config.platform_specific_path("#{Chef::Dist::CONF_DIR}/#{profile}/credentials")) - Chef::Config.platform_specific_path("#{Chef::Dist::CONF_DIR}/#{profile}/credentials") + elsif File.exist?("#{ChefConfig::Config.etc_chef_dir}/#{profile}/credentials") + "#{ChefConfig::Config.etc_chef_dir}/#{profile}/credentials" else super end @@ -102,7 +102,7 @@ class Chef tm_config = Chef::Config.target_mode protocol = tm_config.protocol train_config = tm_config.to_hash.select { |k| Train.options(protocol).key?(k) } - Chef::Log.trace("Using target mode options from #{Chef::Dist::PRODUCT} config file: #{train_config.keys.join(", ")}") if train_config + Chef::Log.trace("Using target mode options from #{ChefUtils::Dist::Infra::PRODUCT} config file: #{train_config.keys.join(", ")}") if train_config # Load the credentials file, and place any valid settings into the train configuration credentials = load_credentials(tm_config.host) diff --git a/spec/functional/event_loggers/windows_eventlog_spec.rb b/spec/functional/event_loggers/windows_eventlog_spec.rb index 2ebf45fb84..0579728b47 100644 --- a/spec/functional/event_loggers/windows_eventlog_spec.rb +++ b/spec/functional/event_loggers/windows_eventlog_spec.rb @@ -49,7 +49,7 @@ describe Chef::EventLoggers::WindowsEventLogger, :windows_only do logger.run_start(version, run_status) expect(event_log.read(flags, offset).any? do |e| - e.source == Chef::Dist::SHORT && e.event_id == 10000 && + e.source == ChefUtils::Dist::Infra::SHORT && e.event_id == 10000 && e.string_inserts[0].include?(version) end ).to be_truthy end @@ -58,7 +58,7 @@ describe Chef::EventLoggers::WindowsEventLogger, :windows_only do logger.run_started(run_status) expect(event_log.read(flags, offset).any? do |e| - e.source == Chef::Dist::SHORT && e.event_id == 10001 && + e.source == ChefUtils::Dist::Infra::SHORT && e.event_id == 10001 && e.string_inserts[0].include?(run_id) end ).to be_truthy end @@ -68,7 +68,7 @@ describe Chef::EventLoggers::WindowsEventLogger, :windows_only do logger.run_completed(node) expect(event_log.read(flags, offset).any? do |e| - e.source == Chef::Dist::SHORT && e.event_id == 10002 && + e.source == ChefUtils::Dist::Infra::SHORT && e.event_id == 10002 && e.string_inserts[0].include?(run_id) && e.string_inserts[1].include?(elapsed_time.to_s) end).to be_truthy @@ -79,7 +79,7 @@ describe Chef::EventLoggers::WindowsEventLogger, :windows_only do logger.run_failed(mock_exception) expect(event_log.read(flags, offset).any? do |e| - e.source == Chef::Dist::SHORT && e.event_id == 10003 && + e.source == ChefUtils::Dist::Infra::SHORT && e.event_id == 10003 && e.string_inserts[0].include?(run_id) && e.string_inserts[1].include?(elapsed_time.to_s) && e.string_inserts[2].include?(mock_exception.class.name) && @@ -93,7 +93,7 @@ describe Chef::EventLoggers::WindowsEventLogger, :windows_only do logger.run_failed(mock_exception) expect(event_log.read(flags, offset).any? do |e| - e.source == Chef::Dist::SHORT && e.event_id == 10003 && + e.source == ChefUtils::Dist::Infra::SHORT && e.event_id == 10003 && e.string_inserts[0].include?("UNKNOWN") && e.string_inserts[1].include?("UNKNOWN") && e.string_inserts[2].include?(mock_exception.class.name) && diff --git a/spec/functional/resource/windows_task_spec.rb b/spec/functional/resource/windows_task_spec.rb index 196e627272..3fe661a550 100644 --- a/spec/functional/resource/windows_task_spec.rb +++ b/spec/functional/resource/windows_task_spec.rb @@ -18,7 +18,7 @@ require "spec_helper" require "chef/provider/windows_task" -require "chef/dist" +require "chef-utils" describe Chef::Resource::WindowsTask, :windows_only do # resource.task.application_name will default to task_name unless resource.command is set @@ -47,37 +47,37 @@ describe Chef::Resource::WindowsTask, :windows_only do context "With Arguments" do it "creates scheduled task and sets command arguments" do - subject.command "#{Chef::Dist::CLIENT} -W" + subject.command "#{ChefUtils::Dist::Infra::CLIENT} -W" call_for_create_action # loading current resource again to check new task is creted and it matches task parameters current_resource = call_for_load_current_resource expect(current_resource.exists).to eq(true) - expect(current_resource.task.application_name).to eq(Chef::Dist::CLIENT) + expect(current_resource.task.application_name).to eq(ChefUtils::Dist::Infra::CLIENT) expect(current_resource.task.parameters).to eq("-W") end it "does not converge the resource if it is already converged" do - subject.command "#{Chef::Dist::CLIENT} -W" + subject.command "#{ChefUtils::Dist::Infra::CLIENT} -W" subject.run_action(:create) - subject.command "#{Chef::Dist::CLIENT} -W" + subject.command "#{ChefUtils::Dist::Infra::CLIENT} -W" subject.run_action(:create) expect(subject).not_to be_updated_by_last_action end it "creates scheduled task and sets command arguments when arguments inclusive single quotes" do - subject.command "#{Chef::Dist::CLIENT} -W -L 'C:\\chef\\chef-ad-join.log'" + subject.command "#{ChefUtils::Dist::Infra::CLIENT} -W -L 'C:\\chef\\chef-ad-join.log'" call_for_create_action # loading current resource again to check new task is creted and it matches task parameters current_resource = call_for_load_current_resource expect(current_resource.exists).to eq(true) - expect(current_resource.task.application_name).to eq(Chef::Dist::CLIENT) + expect(current_resource.task.application_name).to eq(ChefUtils::Dist::Infra::CLIENT) expect(current_resource.task.parameters).to eq("-W -L 'C:\\chef\\chef-ad-join.log'") end it "does not converge the resource if it is already converged" do - subject.command "#{Chef::Dist::CLIENT} -W -L 'C:\\chef\\chef-ad-join.log'" + subject.command "#{ChefUtils::Dist::Infra::CLIENT} -W -L 'C:\\chef\\chef-ad-join.log'" subject.run_action(:create) - subject.command "#{Chef::Dist::CLIENT} -W -L 'C:\\chef\\chef-ad-join.log'" + subject.command "#{ChefUtils::Dist::Infra::CLIENT} -W -L 'C:\\chef\\chef-ad-join.log'" subject.run_action(:create) expect(subject).not_to be_updated_by_last_action end @@ -137,19 +137,19 @@ describe Chef::Resource::WindowsTask, :windows_only do context "Without Arguments" do it "creates scheduled task and sets command arguments" do - subject.command Chef::Dist::CLIENT + subject.command ChefUtils::Dist::Infra::CLIENT call_for_create_action # loading current resource again to check new task is creted and it matches task parameters current_resource = call_for_load_current_resource expect(current_resource.exists).to eq(true) - expect(current_resource.task.application_name).to eq(Chef::Dist::CLIENT) + expect(current_resource.task.application_name).to eq(ChefUtils::Dist::Infra::CLIENT) expect(current_resource.task.parameters).to be_empty end it "does not converge the resource if it is already converged" do - subject.command Chef::Dist::CLIENT + subject.command ChefUtils::Dist::Infra::CLIENT subject.run_action(:create) - subject.command Chef::Dist::CLIENT + subject.command ChefUtils::Dist::Infra::CLIENT subject.run_action(:create) expect(subject).not_to be_updated_by_last_action end diff --git a/spec/functional/version_spec.rb b/spec/functional/version_spec.rb index 294df7542c..5f4f9f79e0 100644 --- a/spec/functional/version_spec.rb +++ b/spec/functional/version_spec.rb @@ -19,13 +19,13 @@ require "spec_helper" require "chef/mixin/shell_out" require "chef/version" require "ohai/version" -require "chef/dist" +require "chef-utils" describe "Chef Versions", :executables do include Chef::Mixin::ShellOut let(:chef_dir) { File.join(__dir__, "..", "..") } - binaries = [ Chef::Dist::CLIENT, "chef-shell", "chef-apply", "knife", Chef::Dist::SOLOEXEC ] + binaries = [ ChefUtils::Dist::Infra::CLIENT, "chef-shell", "chef-apply", "knife", ChefUtils::Dist::Solo::EXEC ] binaries.each do |binary| it "#{binary} version should be sane" do diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb index a33f84610d..b7455c4b80 100644 --- a/spec/integration/client/client_spec.rb +++ b/spec/integration/client/client_spec.rb @@ -3,7 +3,7 @@ require "support/shared/integration/integration_helper" require "chef/mixin/shell_out" require "tiny_server" require "tmpdir" -require "chef/dist" +require "chef-utils" describe "chef-client" do @@ -45,8 +45,8 @@ describe "chef-client" do # machine that has omnibus chef installed. In that case we need to ensure # we're running `chef-client` from the source tree and not the external one. # cf. CHEF-4914 - let(:chef_client) { "bundle exec #{Chef::Dist::CLIENT} --minimal-ohai" } - let(:chef_solo) { "bundle exec #{Chef::Dist::SOLOEXEC} --legacy-mode --minimal-ohai" } + let(:chef_client) { "bundle exec #{ChefUtils::Dist::Infra::CLIENT} --minimal-ohai" } + let(:chef_solo) { "bundle exec #{ChefUtils::Dist::Solo::EXEC} --legacy-mode --minimal-ohai" } when_the_repository "has a cookbook with a no-op recipe" do before { file "cookbooks/x/recipes/default.rb", "" } diff --git a/spec/integration/client/exit_code_spec.rb b/spec/integration/client/exit_code_spec.rb index c2f0c2fb45..3b0c7d5a8e 100644 --- a/spec/integration/client/exit_code_spec.rb +++ b/spec/integration/client/exit_code_spec.rb @@ -22,7 +22,7 @@ describe "chef-client" do # machine that has omnibus chef installed. In that case we need to ensure # we're running `chef-client` from the source tree and not the external one. # cf. CHEF-4914 - let(:chef_client) { "bundle exec #{Chef::Dist::CLIENT} --no-fork --minimal-ohai" } + let(:chef_client) { "bundle exec #{ChefUtils::Dist::Infra::CLIENT} --no-fork --minimal-ohai" } let(:critical_env_vars) { %w{PATH RUBYOPT BUNDLE_GEMFILE GEM_PATH}.map { |o| "#{o}=#{ENV[o]}" } .join(" ") } diff --git a/spec/integration/solo/solo_spec.rb b/spec/integration/solo/solo_spec.rb index 75a13b57e4..6c9e2a6f9d 100644 --- a/spec/integration/solo/solo_spec.rb +++ b/spec/integration/solo/solo_spec.rb @@ -6,9 +6,9 @@ require "chef/config" require "timeout" require "fileutils" require "chef/win32/security" if ChefUtils.windows? -require "chef/dist" +require "chef-utils" -describe Chef::Dist::SOLOEXEC do +describe ChefUtils::Dist::Solo::EXEC do include IntegrationSupport include Chef::Mixin::ShellOut @@ -18,7 +18,7 @@ describe Chef::Dist::SOLOEXEC do let(:cookbook_ancient_100_metadata_rb) { cb_metadata("ancient", "1.0.0") } - let(:chef_solo) { "bundle exec #{Chef::Dist::SOLOEXEC} --legacy-mode --minimal-ohai" } + let(:chef_solo) { "bundle exec #{ChefUtils::Dist::Solo::EXEC} --legacy-mode --minimal-ohai" } when_the_repository "creates nodes" do let(:nodes_dir) { File.join(@repository_dir, "nodes") } diff --git a/spec/unit/cookbook/synchronizer_spec.rb b/spec/unit/cookbook/synchronizer_spec.rb index a1d312836b..22dd211f5b 100644 --- a/spec/unit/cookbook/synchronizer_spec.rb +++ b/spec/unit/cookbook/synchronizer_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" require "chef/cookbook/synchronizer" require "chef/cookbook_version" -require "chef/dist" +require "chef-utils" describe Chef::CookbookCacheCleaner do describe "when cleaning up unused cookbook components" do @@ -50,7 +50,7 @@ describe Chef::CookbookCacheCleaner do cleaner.cleanup_file_cache end - it "does not remove anything on #{Chef::Dist::SOLOEXEC}" do + it "does not remove anything on #{ChefUtils::Dist::Solo::EXEC}" do Chef::Config[:solo_legacy_mode] = true allow(cleaner.cache).to receive(:find).and_return(%w{cookbooks/valid1/recipes/default.rb cookbooks/valid2/recipes/default.rb}) expect(cleaner.cache).not_to receive(:delete) |