summaryrefslogtreecommitdiff
path: root/lib/chef/application
diff options
context:
space:
mode:
authorNoah Kantrowitz <noah@coderanger.net>2018-07-02 16:20:22 -0700
committerNoah Kantrowitz <noah@coderanger.net>2018-07-02 16:20:22 -0700
commit5b2be9fdde75ddaffa3447bc354806b2efb4b095 (patch)
treea078e952e444ac5d5be69779e5414e99ac66df85 /lib/chef/application
parenta4b8940d2690eb92d54d7d56a0c638fca6f3808f (diff)
parentf23bc124f577ee628879079754331724593a82a3 (diff)
downloadchef-5b2be9fdde75ddaffa3447bc354806b2efb4b095.tar.gz
Merge branch 'master' into yet-more-creds
Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
Diffstat (limited to 'lib/chef/application')
-rw-r--r--lib/chef/application/apply.rb112
-rw-r--r--lib/chef/application/client.rb325
-rw-r--r--lib/chef/application/knife.rb154
-rw-r--r--lib/chef/application/solo.rb238
-rw-r--r--lib/chef/application/windows_service.rb38
-rw-r--r--lib/chef/application/windows_service_manager.rb70
6 files changed, 468 insertions, 469 deletions
diff --git a/lib/chef/application/apply.rb b/lib/chef/application/apply.rb
index ec627ada2e..7325d89e1e 100644
--- a/lib/chef/application/apply.rb
+++ b/lib/chef/application/apply.rb
@@ -32,86 +32,86 @@ class Chef::Application::Apply < Chef::Application
banner "Usage: chef-apply [RECIPE_FILE | -e RECIPE_TEXT | -s] [OPTIONS]"
option :execute,
- :short => "-e RECIPE_TEXT",
- :long => "--execute RECIPE_TEXT",
- :description => "Execute resources supplied in a string",
- :proc => nil
+ short: "-e RECIPE_TEXT",
+ long: "--execute RECIPE_TEXT",
+ description: "Execute resources supplied in a string",
+ proc: nil
option :stdin,
- :short => "-s",
- :long => "--stdin",
- :description => "Execute resources read from STDIN",
- :boolean => true
+ short: "-s",
+ long: "--stdin",
+ description: "Execute resources read from STDIN",
+ boolean: true
option :json_attribs,
- :short => "-j JSON_ATTRIBS",
- :long => "--json-attributes JSON_ATTRIBS",
- :description => "Load attributes from a JSON file or URL",
- :proc => nil
+ short: "-j JSON_ATTRIBS",
+ long: "--json-attributes JSON_ATTRIBS",
+ description: "Load attributes from a JSON file or URL",
+ proc: nil
option :force_logger,
- :long => "--force-logger",
- :description => "Use logger output instead of formatter output",
- :boolean => true,
- :default => false
+ long: "--force-logger",
+ description: "Use logger output instead of formatter output",
+ boolean: true,
+ default: false
option :force_formatter,
- :long => "--force-formatter",
- :description => "Use formatter output instead of logger output",
- :boolean => true,
- :default => false
+ long: "--force-formatter",
+ description: "Use formatter output instead of logger output",
+ boolean: true,
+ default: false
option :formatter,
- :short => "-F FORMATTER",
- :long => "--format FORMATTER",
- :description => "output format to use",
- :proc => lambda { |format| Chef::Config.add_formatter(format) }
+ short: "-F FORMATTER",
+ long: "--format FORMATTER",
+ description: "output format to use",
+ proc: lambda { |format| Chef::Config.add_formatter(format) }
option :log_level,
- :short => "-l LEVEL",
- :long => "--log_level LEVEL",
- :description => "Set the log level (trace, debug, info, warn, error, fatal)",
- :proc => lambda { |l| l.to_sym }
+ short: "-l LEVEL",
+ long: "--log_level LEVEL",
+ description: "Set the log level (trace, debug, info, warn, error, fatal)",
+ proc: lambda { |l| l.to_sym }
option :help,
- :short => "-h",
- :long => "--help",
- :description => "Show this message",
- :on => :tail,
- :boolean => true,
- :show_options => true,
- :exit => 0
+ short: "-h",
+ long: "--help",
+ description: "Show this message",
+ on: :tail,
+ boolean: true,
+ show_options: true,
+ exit: 0
option :version,
- :short => "-v",
- :long => "--version",
- :description => "Show chef version",
- :boolean => true,
- :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" },
- :exit => 0
+ short: "-v",
+ long: "--version",
+ description: "Show chef version",
+ boolean: true,
+ proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" },
+ exit: 0
option :why_run,
- :short => "-W",
- :long => "--why-run",
- :description => "Enable whyrun mode",
- :boolean => true
+ short: "-W",
+ long: "--why-run",
+ description: "Enable whyrun mode",
+ boolean: true
option :profile_ruby,
- :long => "--[no-]profile-ruby",
- :description => "Dump complete Ruby call graph stack of entire Chef run (expert only)",
- :boolean => true,
- :default => false
+ long: "--[no-]profile-ruby",
+ description: "Dump complete Ruby call graph stack of entire Chef run (expert only)",
+ boolean: true,
+ default: false
option :color,
- :long => "--[no-]color",
- :boolean => true,
- :default => true,
- :description => "Use colored output, defaults to enabled"
+ long: "--[no-]color",
+ boolean: true,
+ default: true,
+ description: "Use colored output, defaults to enabled"
option :minimal_ohai,
- :long => "--minimal-ohai",
- :description => "Only run the bare minimum ohai plugins chef needs to function",
- :boolean => true
+ long: "--minimal-ohai",
+ description: "Only run the bare minimum ohai plugins chef needs to function",
+ boolean: true
attr_reader :json_attribs
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index ffb997f187..6e574e682f 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -38,172 +38,171 @@ class Chef::Application::Client < Chef::Application
SELF_PIPE = []
option :config_file,
- :short => "-c CONFIG",
- :long => "--config CONFIG",
- :description => "The configuration file to use"
+ short: "-c CONFIG",
+ long: "--config CONFIG",
+ description: "The configuration file to use"
option :config_option,
- :long => "--config-option OPTION=VALUE",
- :description => "Override a single configuration option",
- :proc => lambda { |option, existing|
+ long: "--config-option OPTION=VALUE",
+ description: "Override a single configuration option",
+ proc: lambda { |option, existing|
(existing ||= []) << option
existing
}
option :formatter,
- :short => "-F FORMATTER",
- :long => "--format FORMATTER",
- :description => "output format to use",
- :proc => lambda { |format| Chef::Config.add_formatter(format) }
+ short: "-F FORMATTER",
+ long: "--format FORMATTER",
+ description: "output format to use",
+ proc: lambda { |format| Chef::Config.add_formatter(format) }
option :force_logger,
- :long => "--force-logger",
- :description => "Use logger output instead of formatter output",
- :boolean => true,
- :default => false
+ long: "--force-logger",
+ description: "Use logger output instead of formatter output",
+ boolean: true,
+ default: false
option :force_formatter,
- :long => "--force-formatter",
- :description => "Use formatter output instead of logger output",
- :boolean => true,
- :default => false
+ long: "--force-formatter",
+ description: "Use formatter output instead of logger output",
+ boolean: true,
+ default: false
option :profile_ruby,
- :long => "--[no-]profile-ruby",
- :description => "Dump complete Ruby call graph stack of entire Chef run (expert only)",
- :boolean => true,
- :default => false
+ long: "--[no-]profile-ruby",
+ description: "Dump complete Ruby call graph stack of entire Chef run (expert only)",
+ boolean: true,
+ default: false
option :color,
- :long => "--[no-]color",
- :boolean => true,
- :default => true,
- :description => "Use colored output, defaults to enabled"
+ long: "--[no-]color",
+ boolean: true,
+ default: true,
+ description: "Use colored output, defaults to enabled"
option :log_level,
- :short => "-l LEVEL",
- :long => "--log_level LEVEL",
- :description => "Set the log level (auto, trace, debug, info, warn, error, fatal)",
- :proc => lambda { |l| l.to_sym }
+ short: "-l LEVEL",
+ long: "--log_level LEVEL",
+ description: "Set the log level (auto, trace, debug, info, warn, error, fatal)",
+ proc: lambda { |l| l.to_sym }
option :log_location,
- :short => "-L LOGLOCATION",
- :long => "--logfile LOGLOCATION",
- :description => "Set the log file location, defaults to STDOUT - recommended for daemonizing",
- :proc => nil
+ short: "-L LOGLOCATION",
+ long: "--logfile LOGLOCATION",
+ description: "Set the log file location, defaults to STDOUT - recommended for daemonizing",
+ proc: nil
option :help,
- :short => "-h",
- :long => "--help",
- :description => "Show this message",
- :on => :tail,
- :boolean => true,
- :show_options => true,
- :exit => 0
+ short: "-h",
+ long: "--help",
+ description: "Show this message",
+ on: :tail,
+ boolean: true,
+ show_options: true,
+ exit: 0
option :user,
- :short => "-u USER",
- :long => "--user USER",
- :description => "User to set privilege to",
- :proc => nil
+ short: "-u USER",
+ long: "--user USER",
+ description: "User to set privilege to",
+ proc: nil
option :group,
- :short => "-g GROUP",
- :long => "--group GROUP",
- :description => "Group to set privilege to",
- :proc => nil
+ short: "-g GROUP",
+ long: "--group GROUP",
+ description: "Group to set privilege to",
+ proc: nil
unless Chef::Platform.windows?
option :daemonize,
- :short => "-d [WAIT]",
- :long => "--daemonize [WAIT]",
- :description =>
- "Daemonize the process. Accepts an optional integer which is the " \
+ short: "-d [WAIT]",
+ long: "--daemonize [WAIT]",
+ description: "Daemonize the process. Accepts an optional integer which is the " \
"number of seconds to wait before the first daemonized run.",
- :proc => lambda { |wait| wait =~ /^\d+$/ ? wait.to_i : true }
+ proc: lambda { |wait| wait =~ /^\d+$/ ? wait.to_i : true }
end
option :pid_file,
- :short => "-P PID_FILE",
- :long => "--pid PIDFILE",
- :description => "Set the PID file location, for the chef-client daemon process. Defaults to /tmp/chef-client.pid",
- :proc => nil
+ short: "-P PID_FILE",
+ long: "--pid PIDFILE",
+ description: "Set the PID file location, for the chef-client daemon process. Defaults to /tmp/chef-client.pid",
+ proc: nil
option :lockfile,
- :long => "--lockfile LOCKFILE",
- :description => "Set the lockfile location. Prevents multiple client processes from converging at the same time",
- :proc => nil
+ long: "--lockfile LOCKFILE",
+ description: "Set the lockfile location. Prevents multiple client processes from converging at the same time",
+ proc: nil
option :interval,
- :short => "-i SECONDS",
- :long => "--interval SECONDS",
- :description => "Run chef-client periodically, in seconds",
- :proc => lambda { |s| s.to_i }
+ short: "-i SECONDS",
+ long: "--interval SECONDS",
+ description: "Run chef-client periodically, in seconds",
+ proc: lambda { |s| s.to_i }
option :once,
- :long => "--once",
- :description => "Cancel any interval or splay options, run chef once and exit",
- :boolean => true
+ long: "--once",
+ description: "Cancel any interval or splay options, run chef once and exit",
+ boolean: true
option :json_attribs,
- :short => "-j JSON_ATTRIBS",
- :long => "--json-attributes JSON_ATTRIBS",
- :description => "Load attributes from a JSON file or URL",
- :proc => nil
+ short: "-j JSON_ATTRIBS",
+ long: "--json-attributes JSON_ATTRIBS",
+ description: "Load attributes from a JSON file or URL",
+ proc: nil
option :node_name,
- :short => "-N NODE_NAME",
- :long => "--node-name NODE_NAME",
- :description => "The node name for this client",
- :proc => nil
+ short: "-N NODE_NAME",
+ long: "--node-name NODE_NAME",
+ description: "The node name for this client",
+ proc: nil
option :splay,
- :short => "-s SECONDS",
- :long => "--splay SECONDS",
- :description => "The splay time for running at intervals, in seconds",
- :proc => lambda { |s| s.to_i }
+ short: "-s SECONDS",
+ long: "--splay SECONDS",
+ description: "The splay time for running at intervals, in seconds",
+ proc: lambda { |s| s.to_i }
option :chef_server_url,
- :short => "-S CHEFSERVERURL",
- :long => "--server CHEFSERVERURL",
- :description => "The chef server URL",
- :proc => nil
+ short: "-S CHEFSERVERURL",
+ long: "--server CHEFSERVERURL",
+ description: "The chef server URL",
+ proc: nil
option :validation_key,
- :short => "-K KEY_FILE",
- :long => "--validation_key KEY_FILE",
- :description => "Set the validation key file location, used for registering new clients",
- :proc => nil
+ short: "-K KEY_FILE",
+ long: "--validation_key KEY_FILE",
+ description: "Set the validation key file location, used for registering new clients",
+ proc: nil
option :client_key,
- :short => "-k KEY_FILE",
- :long => "--client_key KEY_FILE",
- :description => "Set the client key file location",
- :proc => nil
+ short: "-k KEY_FILE",
+ long: "--client_key KEY_FILE",
+ description: "Set the client key file location",
+ proc: nil
option :named_run_list,
- :short => "-n NAMED_RUN_LIST",
- :long => "--named-run-list NAMED_RUN_LIST",
- :description => "Use a policyfile's named run list instead of the default run list"
+ short: "-n NAMED_RUN_LIST",
+ long: "--named-run-list NAMED_RUN_LIST",
+ description: "Use a policyfile's named run list instead of the default run list"
option :environment,
- :short => "-E ENVIRONMENT",
- :long => "--environment ENVIRONMENT",
- :description => "Set the Chef Environment on the node"
+ short: "-E ENVIRONMENT",
+ long: "--environment ENVIRONMENT",
+ description: "Set the Chef Environment on the node"
option :version,
- :short => "-v",
- :long => "--version",
- :description => "Show chef version",
- :boolean => true,
- :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" },
- :exit => 0
+ short: "-v",
+ long: "--version",
+ description: "Show chef version",
+ boolean: true,
+ proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" },
+ exit: 0
option :override_runlist,
- :short => "-o RunlistItem,RunlistItem...",
- :long => "--override-runlist RunlistItem,RunlistItem...",
- :description => "Replace current run list with specified items for a single run",
- :proc => lambda { |items|
+ short: "-o RunlistItem,RunlistItem...",
+ long: "--override-runlist RunlistItem,RunlistItem...",
+ description: "Replace current run list with specified items for a single run",
+ proc: lambda { |items|
items = items.split(",")
items.compact.map do |item|
Chef::RunList::RunListItem.new(item)
@@ -211,97 +210,97 @@ class Chef::Application::Client < Chef::Application
}
option :runlist,
- :short => "-r RunlistItem,RunlistItem...",
- :long => "--runlist RunlistItem,RunlistItem...",
- :description => "Permanently replace current run list with specified items",
- :proc => lambda { |items|
+ short: "-r RunlistItem,RunlistItem...",
+ long: "--runlist RunlistItem,RunlistItem...",
+ description: "Permanently replace current run list with specified items",
+ proc: lambda { |items|
items = items.split(",")
items.compact.map do |item|
Chef::RunList::RunListItem.new(item)
end
}
option :why_run,
- :short => "-W",
- :long => "--why-run",
- :description => "Enable whyrun mode",
- :boolean => true
+ short: "-W",
+ long: "--why-run",
+ description: "Enable whyrun mode",
+ boolean: true
option :client_fork,
- :short => "-f",
- :long => "--[no-]fork",
- :description => "Fork client"
+ short: "-f",
+ long: "--[no-]fork",
+ description: "Fork client"
option :recipe_url,
- :long => "--recipe-url=RECIPE_URL",
- :description => "Pull down a remote archive of recipes and unpack it to the cookbook cache. Only used in local mode."
+ long: "--recipe-url=RECIPE_URL",
+ description: "Pull down a remote archive of recipes and unpack it to the cookbook cache. Only used in local mode."
option :enable_reporting,
- :short => "-R",
- :long => "--enable-reporting",
- :description => "Enable reporting data collection for chef runs",
- :boolean => true
+ short: "-R",
+ long: "--enable-reporting",
+ description: "Enable reporting data collection for chef runs",
+ boolean: true
option :local_mode,
- :short => "-z",
- :long => "--local-mode",
- :description => "Point chef-client at local repository",
- :boolean => true
+ short: "-z",
+ long: "--local-mode",
+ description: "Point chef-client at local repository",
+ boolean: true
option :chef_zero_host,
- :long => "--chef-zero-host HOST",
- :description => "Host to start chef-zero on"
+ long: "--chef-zero-host HOST",
+ description: "Host to start chef-zero on"
option :chef_zero_port,
- :long => "--chef-zero-port PORT",
- :description => "Port (or port range) to start chef-zero on. Port ranges like 1000,1010 or 8889-9999 will try all given ports until one works."
+ long: "--chef-zero-port PORT",
+ description: "Port (or port range) to start chef-zero on. Port ranges like 1000,1010 or 8889-9999 will try all given ports until one works."
option :disable_config,
- :long => "--disable-config",
- :description => "Refuse to load a config file and use defaults. This is for development and not a stable API",
- :boolean => true
+ long: "--disable-config",
+ description: "Refuse to load a config file and use defaults. This is for development and not a stable API",
+ boolean: true
option :run_lock_timeout,
- :long => "--run-lock-timeout SECONDS",
- :description => "Set maximum duration to wait for another client run to finish, default is indefinitely.",
- :proc => lambda { |s| s.to_i }
+ long: "--run-lock-timeout SECONDS",
+ description: "Set maximum duration to wait for another client run to finish, default is indefinitely.",
+ proc: lambda { |s| s.to_i }
if Chef::Platform.windows?
option :fatal_windows_admin_check,
- :short => "-A",
- :long => "--fatal-windows-admin-check",
- :description => "Fail the run when chef-client doesn't have administrator privileges on Windows",
- :boolean => true
+ short: "-A",
+ long: "--fatal-windows-admin-check",
+ description: "Fail the run when chef-client doesn't have administrator privileges on Windows",
+ boolean: true
end
option :audit_mode,
- :long => "--audit-mode MODE",
- :description => "Enable audit-mode with `enabled`. Disable audit-mode with `disabled`. Skip converge and only perform audits with `audit-only`",
- :proc => lambda { |mo| mo.tr("-", "_").to_sym }
+ long: "--audit-mode MODE",
+ description: "Enable audit-mode with `enabled`. Disable audit-mode with `disabled`. Skip converge and only perform audits with `audit-only`",
+ proc: lambda { |mo| mo.tr("-", "_").to_sym }
option :minimal_ohai,
- :long => "--minimal-ohai",
- :description => "Only run the bare minimum ohai plugins chef needs to function",
- :boolean => true
+ long: "--minimal-ohai",
+ description: "Only run the bare minimum ohai plugins chef needs to function",
+ boolean: true
option :listen,
- :long => "--[no-]listen",
- :description => "Whether a local mode (-z) server binds to a port",
- :boolean => false
+ long: "--[no-]listen",
+ description: "Whether a local mode (-z) server binds to a port",
+ boolean: false
option :fips,
- :long => "--[no-]fips",
- :description => "Enable fips mode",
- :boolean => true
+ long: "--[no-]fips",
+ description: "Enable fips mode",
+ boolean: true
option :delete_entire_chef_repo,
- :long => "--delete-entire-chef-repo",
- :description => "DANGEROUS: does what it says, only useful with --recipe-url",
- :boolean => true
+ long: "--delete-entire-chef-repo",
+ description: "DANGEROUS: does what it says, only useful with --recipe-url",
+ boolean: true
option :skip_cookbook_sync,
- :long => "--[no-]skip-cookbook-sync",
- :description => "Use cached cookbooks without overwriting local differences from the server",
- :boolean => false
+ long: "--[no-]skip-cookbook-sync",
+ description: "Use cached cookbooks without overwriting local differences from the server",
+ boolean: false
IMMEDIATE_RUN_SIGNAL = "1".freeze
RECONFIGURE_SIGNAL = "H".freeze
@@ -338,7 +337,7 @@ class Chef::Application::Client < Chef::Application
else
if Chef::Config[:delete_entire_chef_repo]
Chef::Log.trace "Cleanup path #{Chef::Config.chef_repo_path} before extract recipes into it"
- FileUtils.rm_rf(recipes_path, :secure => true)
+ FileUtils.rm_rf(recipes_path, secure: true)
end
Chef::Log.trace "Creating path #{Chef::Config.chef_repo_path} to extract recipes into"
FileUtils.mkdir_p(Chef::Config.chef_repo_path)
@@ -518,7 +517,7 @@ class Chef::Application::Client < Chef::Application
def unforked_interval_error_message
"Unforked chef-client interval runs are disabled in Chef 12." +
"\nConfiguration settings:" +
- "#{"\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]}" +
+ ("\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]).to_s +
"\nEnable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
end
diff --git a/lib/chef/application/knife.rb b/lib/chef/application/knife.rb
index fe0159873c..9a735a1249 100644
--- a/lib/chef/application/knife.rb
+++ b/lib/chef/application/knife.rb
@@ -28,129 +28,129 @@ class Chef::Application::Knife < Chef::Application
banner "Usage: knife sub-command (options)"
option :config_file,
- :short => "-c CONFIG",
- :long => "--config CONFIG",
- :description => "The configuration file to use",
- :proc => lambda { |path| File.expand_path(path, Dir.pwd) }
+ short: "-c CONFIG",
+ long: "--config CONFIG",
+ description: "The configuration file to use",
+ proc: lambda { |path| File.expand_path(path, Dir.pwd) }
option :config_option,
- :long => "--config-option OPTION=VALUE",
- :description => "Override a single configuration option",
- :proc => lambda { |option, existing|
+ long: "--config-option OPTION=VALUE",
+ description: "Override a single configuration option",
+ proc: lambda { |option, existing|
(existing ||= []) << option
existing
}
verbosity_level = 0
option :verbosity,
- :short => "-V",
- :long => "--verbose",
- :description => "More verbose output. Use twice for max verbosity",
- :proc => Proc.new { verbosity_level += 1 },
- :default => 0
+ short: "-V",
+ long: "--verbose",
+ description: "More verbose output. Use twice for max verbosity",
+ proc: Proc.new { verbosity_level += 1 },
+ default: 0
option :color,
- :long => "--[no-]color",
- :boolean => true,
- :default => true,
- :description => "Use colored output, defaults to enabled"
+ long: "--[no-]color",
+ boolean: true,
+ default: true,
+ description: "Use colored output, defaults to enabled"
option :environment,
- :short => "-E ENVIRONMENT",
- :long => "--environment ENVIRONMENT",
- :description => "Set the Chef environment (except for in searches, where this will be flagrantly ignored)"
+ short: "-E ENVIRONMENT",
+ long: "--environment ENVIRONMENT",
+ description: "Set the Chef environment (except for in searches, where this will be flagrantly ignored)"
option :editor,
- :short => "-e EDITOR",
- :long => "--editor EDITOR",
- :description => "Set the editor to use for interactive commands",
- :default => ENV["EDITOR"]
+ short: "-e EDITOR",
+ long: "--editor EDITOR",
+ description: "Set the editor to use for interactive commands",
+ default: ENV["EDITOR"]
option :disable_editing,
- :short => "-d",
- :long => "--disable-editing",
- :description => "Do not open EDITOR, just accept the data as is",
- :boolean => true,
- :default => false
+ short: "-d",
+ long: "--disable-editing",
+ description: "Do not open EDITOR, just accept the data as is",
+ boolean: true,
+ default: false
option :help,
- :short => "-h",
- :long => "--help",
- :description => "Show this message",
- :on => :tail,
- :boolean => true
+ short: "-h",
+ long: "--help",
+ description: "Show this message",
+ on: :tail,
+ boolean: true
option :node_name,
- :short => "-u USER",
- :long => "--user USER",
- :description => "API Client Username"
+ short: "-u USER",
+ long: "--user USER",
+ description: "API Client Username"
option :client_key,
- :short => "-k KEY",
- :long => "--key KEY",
- :description => "API Client Key",
- :proc => lambda { |path| File.expand_path(path, Dir.pwd) }
+ short: "-k KEY",
+ long: "--key KEY",
+ description: "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 Server URL"
+ short: "-s URL",
+ long: "--server-url URL",
+ description: "Chef Server URL"
option :yes,
- :short => "-y",
- :long => "--yes",
- :description => "Say yes to all prompts for confirmation"
+ short: "-y",
+ long: "--yes",
+ description: "Say yes to all prompts for confirmation"
option :defaults,
- :long => "--defaults",
- :description => "Accept default values for all questions"
+ long: "--defaults",
+ description: "Accept default values for all questions"
option :print_after,
- :long => "--print-after",
- :description => "Show the data after a destructive operation"
+ long: "--print-after",
+ description: "Show the data after a destructive operation"
option :format,
- :short => "-F FORMAT",
- :long => "--format FORMAT",
- :description => "Which format to use for output",
- :default => "summary"
+ short: "-F FORMAT",
+ long: "--format FORMAT",
+ description: "Which format to use for output",
+ default: "summary"
option :local_mode,
- :short => "-z",
- :long => "--local-mode",
- :description => "Point knife commands at local repository instead of server",
- :boolean => true
+ short: "-z",
+ long: "--local-mode",
+ description: "Point knife commands at local repository instead of server",
+ boolean: true
option :chef_zero_host,
- :long => "--chef-zero-host HOST",
- :description => "Host to start chef-zero on"
+ long: "--chef-zero-host HOST",
+ description: "Host to start chef-zero on"
option :chef_zero_port,
- :long => "--chef-zero-port PORT",
- :description => "Port (or port range) to start chef-zero on. Port ranges like 1000,1010 or 8889-9999 will try all given ports until one works."
+ long: "--chef-zero-port PORT",
+ description: "Port (or port range) to start chef-zero on. Port ranges like 1000,1010 or 8889-9999 will try all given ports until one works."
option :listen,
- :long => "--[no-]listen",
- :description => "Whether a local mode (-z) server binds to a port",
- :boolean => false
+ long: "--[no-]listen",
+ description: "Whether a local mode (-z) server binds to a port",
+ boolean: false
option :version,
- :short => "-v",
- :long => "--version",
- :description => "Show chef version",
- :boolean => true,
- :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" },
- :exit => 0
+ short: "-v",
+ long: "--version",
+ description: "Show chef version",
+ boolean: true,
+ proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" },
+ exit: 0
option :fips,
- :long => "--[no-]fips",
- :description => "Enable fips mode",
- :boolean => true,
- :default => nil
+ long: "--[no-]fips",
+ description: "Enable fips mode",
+ boolean: true,
+ default: nil
option :profile,
- :long => "--profile PROFILE",
- :description => "The credentials profile to select"
+ long: "--profile PROFILE",
+ description: "The credentials profile to select"
# Run knife
def run
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index 646d68182c..cd364dc6ae 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -35,137 +35,137 @@ class Chef::Application::Solo < Chef::Application
include ChefConfig::Mixin::DotD
option :config_file,
- :short => "-c CONFIG",
- :long => "--config CONFIG",
- :default => Chef::Config.platform_specific_path("/etc/chef/solo.rb"),
- :description => "The configuration file to use"
+ short: "-c CONFIG",
+ long: "--config CONFIG",
+ default: Chef::Config.platform_specific_path("/etc/chef/solo.rb"),
+ description: "The configuration file to use"
option :config_option,
- :long => "--config-option OPTION=VALUE",
- :description => "Override a single configuration option",
- :proc => lambda { |option, existing|
+ long: "--config-option OPTION=VALUE",
+ description: "Override a single configuration option",
+ proc: lambda { |option, existing|
(existing ||= []) << option
existing
}
option :formatter,
- :short => "-F FORMATTER",
- :long => "--format FORMATTER",
- :description => "output format to use",
- :proc => lambda { |format| Chef::Config.add_formatter(format) }
+ short: "-F FORMATTER",
+ long: "--format FORMATTER",
+ description: "output format to use",
+ proc: lambda { |format| Chef::Config.add_formatter(format) }
option :force_logger,
- :long => "--force-logger",
- :description => "Use logger output instead of formatter output",
- :boolean => true,
- :default => false
+ long: "--force-logger",
+ description: "Use logger output instead of formatter output",
+ boolean: true,
+ default: false
option :force_formatter,
- :long => "--force-formatter",
- :description => "Use formatter output instead of logger output",
- :boolean => true,
- :default => false
+ long: "--force-formatter",
+ description: "Use formatter output instead of logger output",
+ boolean: true,
+ default: false
option :profile_ruby,
- :long => "--[no-]profile-ruby",
- :description => "Dump complete Ruby call graph stack of entire Chef run (expert only)",
- :boolean => true,
- :default => false
+ long: "--[no-]profile-ruby",
+ description: "Dump complete Ruby call graph stack of entire Chef run (expert only)",
+ boolean: true,
+ default: false
option :color,
- :long => "--[no-]color",
- :boolean => true,
- :default => !Chef::Platform.windows?,
- :description => "Use colored output, defaults to enabled"
+ long: "--[no-]color",
+ boolean: true,
+ default: !Chef::Platform.windows?,
+ description: "Use colored output, defaults to enabled"
option :log_level,
- :short => "-l LEVEL",
- :long => "--log_level LEVEL",
- :description => "Set the log level (trace, debug, info, warn, error, fatal)",
- :proc => lambda { |l| l.to_sym }
+ short: "-l LEVEL",
+ long: "--log_level LEVEL",
+ description: "Set the log level (trace, debug, info, warn, error, fatal)",
+ proc: lambda { |l| l.to_sym }
option :log_location,
- :short => "-L LOGLOCATION",
- :long => "--logfile LOGLOCATION",
- :description => "Set the log file location, defaults to STDOUT",
- :proc => nil
+ short: "-L LOGLOCATION",
+ long: "--logfile LOGLOCATION",
+ description: "Set the log file location, defaults to STDOUT",
+ proc: nil
option :help,
- :short => "-h",
- :long => "--help",
- :description => "Show this message",
- :on => :tail,
- :boolean => true,
- :show_options => true,
- :exit => 0
+ short: "-h",
+ long: "--help",
+ description: "Show this message",
+ on: :tail,
+ boolean: true,
+ show_options: true,
+ exit: 0
option :user,
- :short => "-u USER",
- :long => "--user USER",
- :description => "User to set privilege to",
- :proc => nil
+ short: "-u USER",
+ long: "--user USER",
+ description: "User to set privilege to",
+ proc: nil
option :group,
- :short => "-g GROUP",
- :long => "--group GROUP",
- :description => "Group to set privilege to",
- :proc => nil
+ short: "-g GROUP",
+ long: "--group GROUP",
+ description: "Group to set privilege to",
+ proc: nil
unless Chef::Platform.windows?
option :daemonize,
- :short => "-d",
- :long => "--daemonize",
- :description => "Daemonize the process",
- :proc => lambda { |p| true }
+ short: "-d",
+ long: "--daemonize",
+ description: "Daemonize the process",
+ proc: lambda { |p| true }
end
option :lockfile,
- :long => "--lockfile LOCKFILE",
- :description => "Set the lockfile location. Prevents multiple processes from converging at the same time",
- :proc => nil
+ long: "--lockfile LOCKFILE",
+ description: "Set the lockfile location. Prevents multiple processes from converging at the same time",
+ proc: nil
option :interval,
- :short => "-i SECONDS",
- :long => "--interval SECONDS",
- :description => "Run chef-client periodically, in seconds",
- :proc => lambda { |s| s.to_i }
+ short: "-i SECONDS",
+ long: "--interval SECONDS",
+ description: "Run chef-client periodically, in seconds",
+ proc: lambda { |s| s.to_i }
option :json_attribs,
- :short => "-j JSON_ATTRIBS",
- :long => "--json-attributes JSON_ATTRIBS",
- :description => "Load attributes from a JSON file or URL",
- :proc => nil
+ short: "-j JSON_ATTRIBS",
+ long: "--json-attributes JSON_ATTRIBS",
+ description: "Load attributes from a JSON file or URL",
+ proc: nil
option :node_name,
- :short => "-N NODE_NAME",
- :long => "--node-name NODE_NAME",
- :description => "The node name for this client",
- :proc => nil
+ short: "-N NODE_NAME",
+ long: "--node-name NODE_NAME",
+ description: "The node name for this client",
+ proc: nil
option :splay,
- :short => "-s SECONDS",
- :long => "--splay SECONDS",
- :description => "The splay time for running at intervals, in seconds",
- :proc => lambda { |s| s.to_i }
+ short: "-s SECONDS",
+ long: "--splay SECONDS",
+ description: "The splay time for running at intervals, in seconds",
+ proc: lambda { |s| s.to_i }
option :recipe_url,
- :short => "-r RECIPE_URL",
- :long => "--recipe-url RECIPE_URL",
- :description => "Pull down a remote gzipped tarball of recipes and untar it to the cookbook cache."
+ short: "-r RECIPE_URL",
+ long: "--recipe-url RECIPE_URL",
+ description: "Pull down a remote gzipped tarball of recipes and untar it to the cookbook cache."
option :version,
- :short => "-v",
- :long => "--version",
- :description => "Show chef version",
- :boolean => true,
- :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" },
- :exit => 0
+ short: "-v",
+ long: "--version",
+ description: "Show chef version",
+ boolean: true,
+ proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" },
+ exit: 0
option :override_runlist,
- :short => "-o RunlistItem,RunlistItem...",
- :long => "--override-runlist RunlistItem,RunlistItem...",
- :description => "Replace current run list with specified items",
- :proc => lambda { |items|
+ short: "-o RunlistItem,RunlistItem...",
+ long: "--override-runlist RunlistItem,RunlistItem...",
+ description: "Replace current run list with specified items",
+ proc: lambda { |items|
items = items.split(",")
items.compact.map do |item|
Chef::RunList::RunListItem.new(item)
@@ -173,45 +173,45 @@ class Chef::Application::Solo < Chef::Application
}
option :client_fork,
- :short => "-f",
- :long => "--[no-]fork",
- :description => "Fork client"
+ short: "-f",
+ long: "--[no-]fork",
+ description: "Fork client"
option :why_run,
- :short => "-W",
- :long => "--why-run",
- :description => "Enable whyrun mode",
- :boolean => true
+ short: "-W",
+ long: "--why-run",
+ description: "Enable whyrun mode",
+ boolean: true
option :ez,
- :long => "--ez",
- :description => "A memorial for Ezra Zygmuntowicz",
- :boolean => true
+ long: "--ez",
+ description: "A memorial for Ezra Zygmuntowicz",
+ boolean: true
option :environment,
- :short => "-E ENVIRONMENT",
- :long => "--environment ENVIRONMENT",
- :description => "Set the Chef Environment on the node"
+ short: "-E ENVIRONMENT",
+ long: "--environment ENVIRONMENT",
+ description: "Set the Chef Environment on the node"
option :run_lock_timeout,
- :long => "--run-lock-timeout SECONDS",
- :description => "Set maximum duration to wait for another client run to finish, default is indefinitely.",
- :proc => lambda { |s| s.to_i }
+ long: "--run-lock-timeout SECONDS",
+ description: "Set maximum duration to wait for another client run to finish, default is indefinitely.",
+ proc: lambda { |s| s.to_i }
option :minimal_ohai,
- :long => "--minimal-ohai",
- :description => "Only run the bare minimum ohai plugins chef needs to function",
- :boolean => true
+ long: "--minimal-ohai",
+ description: "Only run the bare minimum ohai plugins chef needs to function",
+ boolean: true
option :delete_entire_chef_repo,
- :long => "--delete-entire-chef-repo",
- :description => "DANGEROUS: does what it says, only useful with --recipe-url",
- :boolean => true
+ long: "--delete-entire-chef-repo",
+ description: "DANGEROUS: does what it says, only useful with --recipe-url",
+ boolean: true
option :solo_legacy_mode,
- :long => "--legacy-mode",
- :description => "Run chef-solo in legacy mode",
- :boolean => true
+ long: "--legacy-mode",
+ description: "Run chef-solo in legacy mode",
+ boolean: true
attr_reader :chef_client_json
@@ -273,7 +273,7 @@ class Chef::Application::Solo < Chef::Application
if Chef::Config[:delete_entire_chef_repo]
Chef::Log.trace "Cleanup path #{recipes_path} before extract recipes into it"
- FileUtils.rm_rf(recipes_path, :secure => true)
+ FileUtils.rm_rf(recipes_path, secure: true)
end
Chef::Log.trace "Creating path #{recipes_path} to extract recipes into"
FileUtils.mkdir_p(recipes_path)
@@ -315,12 +315,12 @@ class Chef::Application::Solo < Chef::Application
private
def for_ezra
- puts <<-EOH
-For Ezra Zygmuntowicz:
- The man who brought you Chef Solo
- Early contributor to Chef
- Kind hearted open source advocate
- Rest in peace, Ezra.
+ puts <<~EOH
+ For Ezra Zygmuntowicz:
+ The man who brought you Chef Solo
+ Early contributor to Chef
+ Kind hearted open source advocate
+ Rest in peace, Ezra.
EOH
end
@@ -370,7 +370,7 @@ EOH
def unforked_interval_error_message
"Unforked chef-client interval runs are disabled in Chef 12." +
"\nConfiguration settings:" +
- "#{"\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]}" +
+ ("\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]).to_s +
"\nEnable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
end
end
diff --git a/lib/chef/application/windows_service.rb b/lib/chef/application/windows_service.rb
index 41dcc55d70..5fe4dbb9b7 100644
--- a/lib/chef/application/windows_service.rb
+++ b/lib/chef/application/windows_service.rb
@@ -37,27 +37,27 @@ class Chef
include Chef::Mixin::ShellOut
option :config_file,
- :short => "-c CONFIG",
- :long => "--config CONFIG",
- :default => "#{ENV['SYSTEMDRIVE']}/chef/client.rb",
- :description => ""
+ short: "-c CONFIG",
+ long: "--config CONFIG",
+ default: "#{ENV['SYSTEMDRIVE']}/chef/client.rb",
+ description: ""
option :log_location,
- :short => "-L LOGLOCATION",
- :long => "--logfile LOGLOCATION",
- :description => "Set the log file location"
+ short: "-L LOGLOCATION",
+ long: "--logfile LOGLOCATION",
+ description: "Set the log file location"
option :splay,
- :short => "-s SECONDS",
- :long => "--splay SECONDS",
- :description => "The splay time for running at intervals, in seconds",
- :proc => lambda { |s| s.to_i }
+ short: "-s SECONDS",
+ long: "--splay SECONDS",
+ description: "The splay time for running at intervals, in seconds",
+ proc: lambda { |s| s.to_i }
option :interval,
- :short => "-i SECONDS",
- :long => "--interval SECONDS",
- :description => "Set the number of seconds to wait between chef-client runs",
- :proc => lambda { |s| s.to_i }
+ short: "-i SECONDS",
+ long: "--interval SECONDS",
+ description: "Set the number of seconds to wait between chef-client runs",
+ proc: lambda { |s| s.to_i }
DEFAULT_LOG_LOCATION ||= "#{ENV['SYSTEMDRIVE']}/chef/client.log"
@@ -197,11 +197,11 @@ class Chef
result = shell_out(
"chef-client.bat #{config_params}",
- :timeout => Chef::Config[:windows_service][:watchdog_timeout],
- :logger => Chef::Log
+ timeout: Chef::Config[:windows_service][:watchdog_timeout],
+ logger: Chef::Log
)
- Chef::Log.trace "#{result.stdout}"
- Chef::Log.trace "#{result.stderr}"
+ Chef::Log.trace (result.stdout).to_s
+ Chef::Log.trace (result.stderr).to_s
rescue Mixlib::ShellOut::CommandTimeout => e
Chef::Log.error "chef-client timed out\n(#{e})"
Chef::Log.error(<<-EOF)
diff --git a/lib/chef/application/windows_service_manager.rb b/lib/chef/application/windows_service_manager.rb
index 5c572bc260..bff4a7511a 100644
--- a/lib/chef/application/windows_service_manager.rb
+++ b/lib/chef/application/windows_service_manager.rb
@@ -37,38 +37,38 @@ class Chef
include Mixlib::CLI
option :action,
- :short => "-a ACTION",
- :long => "--action ACTION",
- :default => "status",
- :description => "Action to carry out on chef-service (install, uninstall, status, start, stop, pause, or resume)"
+ short: "-a ACTION",
+ long: "--action ACTION",
+ default: "status",
+ description: "Action to carry out on chef-service (install, uninstall, status, start, stop, pause, or resume)"
option :config_file,
- :short => "-c CONFIG",
- :long => "--config CONFIG",
- :default => "#{ENV['SYSTEMDRIVE']}/chef/client.rb",
- :description => "The configuration file to use for chef runs"
+ short: "-c CONFIG",
+ long: "--config CONFIG",
+ default: "#{ENV['SYSTEMDRIVE']}/chef/client.rb",
+ description: "The configuration file to use for chef runs"
option :log_location,
- :short => "-L LOGLOCATION",
- :long => "--logfile LOGLOCATION",
- :description => "Set the log file location for chef-service"
+ short: "-L LOGLOCATION",
+ long: "--logfile LOGLOCATION",
+ description: "Set the log file location for chef-service"
option :help,
- :short => "-h",
- :long => "--help",
- :description => "Show this message",
- :on => :tail,
- :boolean => true,
- :show_options => true,
- :exit => 0
+ short: "-h",
+ long: "--help",
+ description: "Show this message",
+ on: :tail,
+ boolean: true,
+ show_options: true,
+ exit: 0
option :version,
- :short => "-v",
- :long => "--version",
- :description => "Show chef version",
- :boolean => true,
- :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" },
- :exit => 0
+ short: "-v",
+ long: "--version",
+ description: "Show chef version",
+ boolean: true,
+ proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" },
+ exit: 0
def initialize(service_options)
# having to call super in initialize is the most annoying
@@ -114,22 +114,22 @@ class Chef
cmd = "\"#{ruby}\" \"#{@service_file_path}\" #{opts}".gsub(File::SEPARATOR, File::ALT_SEPARATOR)
::Win32::Service.new(
- :service_name => @service_name,
- :display_name => @service_display_name,
- :description => @service_description,
+ service_name: @service_name,
+ display_name: @service_display_name,
+ description: @service_description,
# Prior to 0.8.5, win32-service creates interactive services by default,
# and we don't want that, so we need to override the service type.
- :service_type => ::Win32::Service::SERVICE_WIN32_OWN_PROCESS,
- :start_type => ::Win32::Service::SERVICE_AUTO_START,
- :binary_path_name => cmd,
- :service_start_name => @service_start_name,
- :password => @password,
- :dependencies => @dependencies
+ service_type: ::Win32::Service::SERVICE_WIN32_OWN_PROCESS,
+ start_type: ::Win32::Service::SERVICE_AUTO_START,
+ binary_path_name: cmd,
+ service_start_name: @service_start_name,
+ password: @password,
+ dependencies: @dependencies
)
unless @delayed_start.nil?
::Win32::Service.configure(
- :service_name => @service_name,
- :delayed_start => @delayed_start
+ service_name: @service_name,
+ delayed_start: @delayed_start
)
end
puts "Service '#{@service_name}' has successfully been installed."