chef-solo (executable)
chef-solo is a command that executes Chef Infra Client in a way that doesn’t require the Chef Infra Server to converge cookbooks. chef-solo uses Chef Infra Client’s Chef local mode, and doesn’t support the following functionality present in Chef Infra Client / server configurations:
- Centralized distribution of cookbooks
- A centralized API that interacts with and integrates infrastructure components
- Authentication or authorization
Note
chef-solo can be run as a daemon.
The chef-solo executable is run as a command-line tool.
Options
This command has the following syntax:
chef-solo OPTION VALUE OPTION VALUE ...
This command has the following options:
-c CONFIG,--config CONFIGThe configuration file to use.
-d,--daemonizeRun the executable as a daemon. This option may not be used in the same command with the
--[no-]forkoption. This option is only available on machines that run in UNIX or Linux environments. For machines that are running Windows that require similar functionality, use thechef-client::servicerecipe in thechef-clientcookbook: https://supermarket.chef.io/cookbooks/chef-client. This will install a Chef Infra Client service under Windows using the Windows Service Wrapper.-E ENVIRONMENT_NAME,--environment ENVIRONMENT_NAMEThe name of the environment.
-f,--[no-]forkContains Chef Infra Client runs in a secondary process with dedicated RAM. When a Chef Infra Client run is complete, the RAM is returned to the master process. This option helps ensure that a Chef Infra Client uses a steady amount of RAM over time because the master process doesn’t run recipes. This option also helps prevent memory leaks such as those that can be introduced by the code contained within a poorly designed cookbook. Use
--no-forkto disable running Chef Infra Client in fork node. Default value:--fork. This option may not be used in the same command with the--daemonizeand--intervaloptions.-F FORMAT,--format FORMATThe output format:
doc(default) ormin.- Use
docto print the progress of a Chef Infra Client run using full strings that display a summary of updates as they occur. - Use
minto print the progress of a Chef Infra Client run using single characters.
A summary of updates is printed at the end of a Chef Infra Client run. A dot (
.) is printed for events that do not have meaningful status information, such as loading a file or synchronizing a cookbook. For resources, a dot (.) is printed when the resource is up to date, anSis printed when the resource is skipped bynot_iforonly_if, and aUis printed when the resource is updated.Other formatting options are available when those formatters are configured in the client.rb file using the
add_formatteroption.- Use
--force-formatterShow formatter output instead of logger output.
--force-loggerShow logger output instead of formatter output.
-g GROUP,--group GROUPThe name of the group that owns a process. This is required when starting any executable as a daemon.
-h,--helpShow help for the command.
-i SECONDS,--interval SECONDSThe frequency (in seconds) at which Chef Infra Client runs. When running Chef Infra Client at intervals, apply
--splayand--intervalvalues before a Chef Infra Client run. This option may not be used in the same command with the--[no-]forkoption.-j PATH,--json-attributes PATHThe path to a file that contains JSON data.
Use this option to define a
run_listobject. For example, a JSON file similar to:"run_list": [ "recipe[base]", "recipe[foo]", "recipe[bar]", "role[webserver]" ],may be used by running
chef-client -j path/to/file.json.In certain situations this option may be used to update
normalattributes.Warning
Any other attribute type that’s contained in this JSON file will be treated as a
normalattribute. Setting attributes at other precedence levels isn’t possible. For example, attempting to updateoverrideattributes using the-joption:{ "name": "dev-99", "description": "Install some stuff", "override_attributes": { "apptastic": { "enable_apptastic": "false", "apptastic_tier_name": "dev-99.bomb.com" } } }will result in a node object similar to:
{ "name": "maybe-dev-99", "normal": { "name": "dev-99", "description": "Install some stuff", "override_attributes": { "apptastic": { "enable_apptastic": "false", "apptastic_tier_name": "dev-99.bomb.com" } } } }-l LEVEL,--log_level LEVELThe level of logging to be stored in a log file. Possible levels:
auto(default),debug,error,fatal,info,trace, orwarn. Default value:warn(when a terminal is available) orinfo(when a terminal isn’t available).-L LOGLOCATION,--logfile cThe location of the log file. This is recommended when starting any executable as a daemon.
--legacy-modeCause Chef Infra Client to use the original chef-solo mode instead of chef local mode. This isn’t recommended. Removed in Chef Infra Client 14.
--minimal-ohaiRun the Ohai plugins for name detection and resource/provider selection and no other Ohai plugins. Set to
trueduring integration testing to speed up test cycles.--[no-]colorView colored output. Default setting:
--color.-N NODE_NAME,--node-name NODE_NAMEThe unique identifier of the node.
-o RUN_LIST_ITEM,--override-runlist RUN_LIST_ITEMReplace the current run-list with the specified items.
-r RECIPE_URL,--recipe-url RECIPE_URLThe URL of the remote cookbook
tar.gzfile that you want to download.In Chef Infra Client 14, the short
-rform will be removed, as it conflicts with the ability to specify a run list.--run-lock-timeout SECONDSThe amount of time (in seconds) to wait for a Chef Infra Client lock file to be deleted. Default value: not set (indefinite). Set to
0to cause a second Chef Infra Client to exit immediately.-s SECONDS,--splay SECONDSA random number between zero and
splaythat’s added tointerval. Use splay to help balance the load on the Chef Infra Server by ensuring that many Chef Infra Client runs aren’t occurring at the same interval. When running Chef Infra Client at intervals, apply--splayand--intervalvalues before a Chef Infra Client run.-u USER,--user USERThe user that owns a process. This is required when starting any executable as a daemon.
-v,--versionThe Chef Infra Client version.
-W,--why-runRun the executable in why-run mode, which is a type of Chef Infra Client run that does everything except modify the system. Use why-run mode to understand the decisions that Chef Infra Client makes during a run and to learn more about the current and proposed state of the system.
Run as Non-root User
Warning
This configuration for the chef user provides root-level access through Chef script files that call system commands with sudo privileges.
Use an alternative approach if your security profile forbids the chef user from having built-in root level access.
chef-solo may be run as a non-root user. For example, you can update the sudoers file:
# chef-solo privilege specification
chef ALL=(ALL) NOPASSWD: /usr/bin/chef-solo
where chef is the name of the non-root user. This would allow chef-solo to run any command on the node without requiring a password.
Examples
Run chef-solo using solo.rb settings
chef-solo -c ~/chef/solo.rb
Use a URL
chef-solo -c ~/solo.rb -j ~/node.json -r http://www.example.com/chef-solo.tar.gz
The tar.gz is archived into the file_cache_path, and then extracted to
cookbooks_path.
Use a directory
chef-solo -c ~/solo.rb -j ~/node.json
chef-solo will look in the solo.rb file to determine the directory in which cookbooks are located.
Use a URL for cookbook and JSON data
chef-solo -c ~/solo.rb -j http://www.example.com/node.json --recipe-url http://www.example.com/chef-solo.tar.gz
where --recipe-url corresponds to recipe_url and -j corresponds to json_attribs, both of which are configuration options in solo.rb.