diff options
author | Marc Chamberland <chamberland.marc@gmail.com> | 2020-05-09 22:58:18 -0400 |
---|---|---|
committer | Lance Albertson <lance@osuosl.org> | 2020-09-15 14:04:36 -0700 |
commit | ed48186831835be81b436a160bcf190a7756d473 (patch) | |
tree | d4ae8196171c57dc2e773e610997e5894e5cf019 /lib/chef/knife | |
parent | f5bbe608321ce3bcfd2d4f17292cf8c1ff042893 (diff) | |
download | chef-ed48186831835be81b436a160bcf190a7756d473.tar.gz |
move dist implementation into chef-utils
Signed-off-by: Marc Chamberland <chamberland.marc@gmail.com>
Signed-off-by: Lance Albertson <lance@osuosl.org>
Diffstat (limited to 'lib/chef/knife')
-rw-r--r-- | lib/chef/knife/bootstrap.rb | 22 | ||||
-rw-r--r-- | lib/chef/knife/bootstrap/templates/chef-full.erb | 6 | ||||
-rw-r--r-- | lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb | 14 | ||||
-rw-r--r-- | lib/chef/knife/client_create.rb | 6 | ||||
-rw-r--r-- | lib/chef/knife/configure.rb | 4 | ||||
-rw-r--r-- | lib/chef/knife/core/bootstrap_context.rb | 4 | ||||
-rw-r--r-- | lib/chef/knife/core/windows_bootstrap_context.rb | 22 | ||||
-rw-r--r-- | lib/chef/knife/exec.rb | 4 | ||||
-rw-r--r-- | lib/chef/knife/node_show.rb | 4 | ||||
-rw-r--r-- | lib/chef/knife/serve.rb | 6 | ||||
-rw-r--r-- | lib/chef/knife/ssl_check.rb | 6 | ||||
-rw-r--r-- | lib/chef/knife/status.rb | 4 | ||||
-rw-r--r-- | lib/chef/knife/user_create.rb | 4 |
13 files changed, 53 insertions, 53 deletions
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)" |