client.rb
The client.rb file specifies how Chef Infra Client is configured on a node and has the following characteristics:
- This file is loaded every time the chef-client executable is run.
- On Microsoft Windows machines, the default location for this file is
C:\chef\client.rb. On all other systems the default location for this file is/etc/chef/client.rb. - Use the
--configoption from the command line to override the default location of the configuration file. - This file is not created by default
Settings
This configuration file has the following settings:
add_formatterA 3rd-party formatter. (See nyan-cat for an example of a 3rd-party formatter.) Each formatter requires its own entry.
authentication_protocol_version-
Sets the authentication protocol that is used to communicate with Chef Infra Server. For example, specify protocol version 1.3 to enable support for SHA-256 algorithms:
knife[:authentication_protocol_version] = '1.3'Note
Authentication protocol 1.3 is only supported on Chef Server versions 12.4.0 and above. automatic_attribute_blacklistA hash that blacklists
automaticattributes, preventing blacklisted attributes from being saved.automatic_attribute_whitelistA hash that whitelists
automaticattributes, preventing non-whitelisted attributes from being saved.cache_pathThe home directory for the user that runs Chef Infra Client as a non-root user.
checksum_pathThe location in which checksum files are stored. These are used to validate individual cookbook files, such as recipes. The checksum itself is stored in the Chef Infra Server database and is then compared to a file in the checksum path that has a filename identical to the checksum.
chef_guidThe node UUID used by Automate. Setting this allows the node UUID to be specified, and can be carried across instances of a node.
chef_licenseUsed to accept the Chef license. Can be set to
acceptoraccept-no-persist, which persists the license acceptance to disk. If passed to versions where the license is not required this configuration option is a no-op.chef_repo_pathThe path to the chef-repo containing cookbooks and other files, such as environments or data bags, when running Chef Infra Client in local mode.
chef_server_url-
The URL for the Chef Infra Server. For example:
https://localhost/organizations/ORG_NAME chef_zero.enabledEnable chef-zero. This setting requires
local_modeto be set totrue. Default value:trueif running in local-mode, otherwisefalse.chef_zero.portThe port on which chef-zero is to listen. If specified as a range, Chef Infra Client will take the first available port in the range. For example
10,20,30or10000-20000. Default value:8889-9999.clear_gem_sourcesGlobally sets the default of the
clear_sourcesproperty on thegem_packageandchef_gemresources. Default value:false.client_fork-
Contain 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 setting helps ensure that a Chef Infra Client uses a steady amount of RAM over time because the master process does not run recipes. This setting also helps prevent memory leaks such as those that can be introduced by the code contained within a poorly designed cookbook. Default value:
true. Set tofalseto disable running Chef Infra Client in fork node.Note
Must be set tofalseup to Chef Client 13.11.3 to gather the standard return code offered byexit_status true. Later versions run as expected without changes to the configuration file. client_keyThe location of the file that contains the client key. Default value:
/etc/chef/client.pem.client_registration_retriesThe number of times a Chef Infra Client will attempt to register with a Chef Infra Server. Default value:
5.client_d_dirA directory that contains additional configuration files for Chef Infra Client.
cookbook_pathThe sub-directory for Chef Infra Client cookbooks. This value can be a string or an array of file system locations, processed in the specified order. The last cookbook is considered to override local modifications.
cookbook_sync_threadsThe number of helper threads available for parallel cookbook synchronization. Increasing this value may increase the frequency of gateway errors from the Chef Infra Server (503 and 504 errors). Decreasing this number reduces the frequency of gateway errors, if present. Default value:
10.data_bag_decrypt_minimum_versionThe minimum required version of data bag encryption. Possible values:
1,2, and3. It is recommended to use the default value of3for additional encrypted data bag security.data_bag_pathThe location from which a data bag is loaded. Default value:
/var/chef/data_bags.data_collector.server_urlThe fully qualified URL to the data collector server API.
data_collector.tokenThe shared data collector security token. When configured, the token will be passed as an HTTP header named
x-data-collector-tokenwhich the server can choose to accept or reject.data_collector.modeThe Chef Infra Client mode in which the Data Collector will be enabled. Possible values:
:solo,:client, or:both. The:solovalue is used for Chef Infra Client operating in Chef Solo Mode or Chef Solo Legacy Mode. Default value:both.data_collector.raise_on_failureWhen enabled, Chef Infra Client raises an error if it cannot successfully POST to the data collector server. Default value:
false.default_attribute_blacklistA hash that blacklists
defaultattributes, preventing blacklisted attributes from being saved.default_attribute_whitelistA hash that whitelists
defaultattributes, preventing non-whitelisted attributes from being saved.diff_disabledCause Chef Infra Client to create a diff when changes are made to a file. Default value:
false.diff_filesize_thresholdThe maximum size (in bytes) of a file for which Chef Infra Client can create a diff. Default value:
10000000.diff_output_thresholdThe maximum size (in bytes) of a diff file Chef Infra Client can create. Default value:
1000000.disable_event_loggerEnable or disable sending events to the Microsoft Windows “Application” event log. When
false, events are sent to the Microsoft Windows “Application” event log at the start and end of a Chef Infra Client run, and also if a Chef Infra Client run fails. Set totrueto disable event logging. Default value:false.enable_reportingCause Chef Infra Client to send run data to the Automate server.
enable_reporting_url_fatalsCause a Chef Infra Client run to fail when run data cannot be sent to the Automate server (for any reason).
enable_selinux_file_permission_fixupSELinux environments only. Cause Chef Infra Client to attempt to apply the correct file permissions to an updated file via the
restoreconcommand. Set this value tofalseto prevent Chef Infra Client from attempting this action.encrypted_data_bag_secretThe subdirectory in which encrypted data bag secrets are located.
enforce_path_sanityTurn on path sanity in resources that shellout so that expected paths like /sbin or /bin are added to the PATH. Disabled by default.
environmentThe name of the Chef Infra environment.
environment_pathThe path to the environment file. Default value:
/var/chef/environments.exit_statusWhen set to
:enabled, Chef Infra Client will use standardized exit codes for the Chef Infra Client run status, and any non-standard exit codes will be converted to1orGENERIC_FAILURE. This setting can also be set to:disabledto use the pre-Chef Infra Client 13 exit code behavior. Default value:nil.file_atomic_update-
Apply atomic file updates to all resources. Set to
truefor global atomic file updates. Set tofalsefor global non-atomic file updates. (Use theatomic_updatesetting on a per-resource basis to override this setting.) Default value:true.Warning
Changing this setting tofalsemay cause file corruption, data loss, or instability. Use theatomic_updateproperty on the cookbook_file, file, remote_file, and template resources to tune this behavior at the recipe level. file_backup_pathThe location in which backup files are stored. If this value is empty, backup files are stored in the directory of the target file. Default value:
/var/chef/backup.file_cache_pathThe location in which cookbooks (and other transient data) files are stored when they are synchronized. This value can also be used in recipes to download files with the remote_file resource.
file_staging_uses_destdirHow file staging (via temporary files) is done. When
true, temporary files are created in the directory in which files will reside. Whenfalse, temporary files are created underENV['TMP']. Default value:true.fipsAllows OpenSSL to enforce FIPS-validated security during a Chef Infra Client run. Set to
trueto enable FIPS-validated security.force_formatterUsing force_formatter causes chef to default to formatter output when STDOUT is not a tty
force_loggerUsing force_logger causes chef to default to logger output when STDOUT is a tty
ftp_proxyThe proxy server for FTP connections.
ftp_proxy_passThe password for the proxy server when the proxy server is using an FTP connection. Default value:
nil.ftp_proxy_userThe user name for the proxy server when the proxy server is using an FTP connection. Default value:
nil.groupThe group that owns a process. This is required when starting any executable as a daemon. Default value:
nil.gem_installer_bundler_options-
Additional options to pass to bundler when installing metadata for cookbook. Default value:
nil. For examplegem_installer_bundler_options = [ "--local", "--clean" ]or
gem_installer_bundler_options = "--local" http_proxyThe proxy server for HTTP connections. Default value:
nil.http_proxy_passThe password for the proxy server when the proxy server is using an HTTP connection. Default value:
nil.http_proxy_userThe user name for the proxy server when the proxy server is using an HTTP connection. Default value:
nil.http_retry_countThe number of retry attempts. Default value:
5.http_retry_delayThe delay (in seconds) between retry attempts. Default value:
5.https_proxyThe proxy server for HTTPS connections. Default value:
nil.https_proxy_passThe password for the proxy server when the proxy server is using an HTTPS connection. Default value:
nil.https_proxy_userThe user name for the proxy server when the proxy server is using an HTTPS connection. Default value:
nil.intervalThe frequency (in seconds) at which Chef Infra Client runs when running in daemonized mode. We do not recommend running in daemonized mode. Instead you should rely on scheduled execution from system schedulers like systemd timers, cron jobs, or Windows Scheduled Tasks. Default value:
1800.json_attribsThe path to a file that contains JSON data.
listenRun chef-zero in socketless mode. Set to
falseto disable port binding and HTTP requests on localhost.local_key_generationWhether the Chef Infra Server or Chef Infra Client generates the private/public key pair. When
true, Chef Infra Client generates the key pair, and then sends the public key to the Chef Infra Server. Default value:true.local_modeRun Chef Infra Client in local mode. This allows all commands that work against the Chef Infra Server to also work against the local chef-repo.
lockfileThe location of the Chef Infra Client lock file. This value is typically platform dependent, so it should be a location defined by
file_cache_path. The default location of a lock file should not be on an NFS mount. Default value: a location defined byfile_cache_path.log_levelThe level of logging to be stored in a log file. Possible levels:
:auto(default),:trace,:debug,:info,:warn,:error, or:fatal. The:autolevel will use:warnwhen a terminal is available or:infowhen a terminal is not available.log_locationThe location of the log file. Possible values:
/path/to/log_location,STDOUT,STDERR,:win_evt(Windows Event Logger), or:syslog(writes to the syslog daemon facility with the originator set aschef-client). The application log will specify the source asChef. Default value:STDOUT.minimal_ohaiRun a minimal set of Ohai plugins providing data necessary for the execution of Chef Infra Client’s built-in resources. Setting this to true will skip many large and time consuming plugins such as
cloudorpackages. Setting this to true may break cookbooks that assume all Ohai data will be present.named_run_listA specific named runlist defined in the node’s applied Policyfile which should be used when running Chef Infra Client.
no_lazy_loadDownload all cookbook files and templates at the beginning of a Chef Infra Client run. Default value:
true.no_proxyA comma-separated list of URLs that do not need a proxy. Default value:
nil.node_nameThe unique identifier of the node. This determines which configuration should be applied and sets the
client_name, which is the name used when authenticating to a Chef Infra Server. By default, Chef Infra Client will use the system’s FQDN as the node name. In general, Chef recommends that you leave this setting blank and let the client assign the FQDN of the node as thenode_nameduring each Chef Infra Client run.node_pathThe location in which nodes are stored during a Chef Infra Client run in local mode. Default value:
/var/chef/node.normal_attribute_blacklistA hash that blacklists
normalattributes, preventing blacklisted attributes from being saved.override_attribute_blacklistA hash that blacklists
overrideattributes, preventing blacklisted attributes from being saved.normal_attribute_whitelistA hash that whitelists
normalattributes, preventing non-whitelisted attributes from being saved.override_attribute_whitelistA hash that whitelists
overrideattributes, preventing non-whitelisted attributes from being saved.pid_fileThe location in which a process identification number (pid) is saved. An executable, when started as a daemon, writes the pid to the specified file. Default value:
/tmp/name-of-executable.pid.policy_groupThe name of a policy group that exists on the Chef Infra Server.
policy_namemust also be specified.policy_group_pathThe location of policy_groups on disk.
policy_nameThe name of a policy, as identified by the
namesetting in a Policyfile.rb file.policy_groupmust also be specified.policy_pathThe location of policies on disk.
recipe_urlA URL to download recipes from when running in local mode.
rest_timeoutThe time (in seconds) after which an HTTP REST request is to time out. Default value:
300.role_pathThe location in which role files are located. Default value:
/var/chef/roles.rubygems_urlThe location to source rubygems. It can be set to a string or array of strings for URIs to set as rubygems sources. This allows individuals to setup an internal mirror of rubygems for “airgapped” environments. Default value:
https://www.rubygems.org. If asourceis specified in eithergem_packageofchef_gemresources it will be added to the values provided here.run_lock_timeoutThe amount of time (in seconds) to wait for a Chef Infra Client lock file to be deleted. A Chef Infra Client run will not start when a lock file is present. If a lock file is not deleted before this time expires, the pending Chef Infra Client run will exit. Default value: not set (indefinite). Set to
0to cause a second Chef Infra Client to exit immediately.script_pathAn array of paths to search for knife exec scripts if they aren’t in the current directory
skip_gem_metadata_installationwhen
skip_gem_metadata_installationis set to true, cookbook gem installation will be skipped. Default value:falsesplayA random number between zero and
splaythat is added tointerval. Use splay to help balance the load on the Chef Infra Server by ensuring that many Chef Infra Client runs are not occurring at the same interval. Default value:nil.stream_execute_outputAlways stream the output of
executeresources even if thelive_streamproperty isn’t set to true. Default value:falseshow_download_progressUsing show_download_progress will display the overall progress of a
remote_filedownload. Default value:falsedownload_progress_intervalWhen
show_download_progressis set to true this is the interval in seconds to write out download progress. Default value:10ssl_ca_fileThe file in which the OpenSSL key is saved. Chef Infra Client generates this setting automatically and most users do not need to modify it.
ssl_ca_pathThe path to where the OpenSSL key is located. Chef Infra Client generates this setting automatically and most users do not need to modify it.
ssl_client_certThe OpenSSL X.509 certificate used for mutual certificate validation. This setting is only necessary when mutual certificate validation is configured on the Chef Infra Server. Default value:
nil.ssl_client_keyThe OpenSSL X.509 key used for mutual certificate validation. This setting is only necessary when mutual certificate validation is configured on the Chef Infra Server. Default value:
nil.ssl_verify_mode-
Set the verify mode for HTTPS requests.
- Use
:verify_nonefor no validation of SSL certificates. - Use
:verify_peerfor validation of all SSL certificates, including the Chef Infra Server connections, S3 connections, and any HTTPS remote_file resource URLs used in Chef Infra Client runs. This is the recommended setting.
Depending on how OpenSSL is configured, the
ssl_ca_pathmay need to be specified. Default value::verify_peer. - Use
trusted_certs_dirA directory that contains additional SSL certificates to trust. Any certificates in this directory will be added to whatever CA bundle ruby is using. Use this to add self-signed certs for your Chef Infra Server or local HTTP file servers. Default value:
trusted_certsdirectory in your chef configuration directory.umaskThe file mode creation mask, or umask. Default value:
0022.use_policyfileChef Infra Client automatically checks the configuration, node JSON, and the stored node on the Chef Infra Server to determine if Policyfile files are in use, and then automatically updates this flag. Default value:
false.userThe user that owns a process. This is required when starting any executable as a daemon. Default value:
nil.validation_client_nameThe name of the chef-validator key that Chef Infra Client uses to access the Chef Infra Server during the initial Chef Infra Client run. This is only used by the legacy validator based bootstrapping.
validation_keyThe location of the file that contains the key used when a Chef Infra Client is registered with a Chef Infra Server. A validation key is signed using the
validation_client_namefor authentication. Default value:/etc/chef/validation.pem. This is only used by the legacy validator based bootstrapping.verbose_loggingSet the log level. Options:
true,nil, andfalse. When this is set tofalse, notifications about individual resources being processed are suppressed (and are output at the:infologging level). Setting this tofalsecan be useful when a Chef Infra Client is run as a daemon. Default value:nil.verify_api_certVerify the SSL certificate on the Chef Infra Server. When
true, Chef Infra Client always verifies the SSL certificate. Whenfalse, Chef Infra Client uses the value ofssl_verify_modeto determine if the SSL certificate requires verification. Default value:false.whitelist-
A hash that contains the whitelist of allowed commands used by Chef Push Jobs. For example:
whitelist { 'job-name' => 'command', 'job-name' => 'command', 'chef-client' => 'chef-client' }A job entry may also be
'job-name' => {:lock => true}, which will check thelockfilesetting in the client.rb file before starting the job.
Automatic Proxy Config
If http_proxy, https_proxy, ftp_proxy, or no_proxy is set in the client.rb file but not set in the ENV, Chef Infra Client will configure the ENV variable based on these (and related) settings. For example:
http_proxy 'http://proxy.example.org:8080'
http_proxy_user 'myself'
http_proxy_pass 'Password1'
Or an alternative way to define the proxy (if the previous version does not work):
http_proxy 'http://myself:[email protected]:8080'
will be set to:
ENV['http_proxy'] = 'http://myself:[email protected]:8080'
.d Directories
Chef Infra Client supports reading multiple configuration files by putting them inside a .d configuration directory. For example: /etc/chef/client.d. All files that end in .rb in the .d directory are loaded; other non-.rb files are ignored.
.d directories may exist in any location where the client.rb, config.rb, or solo.rb files are present, such as:
/etc/chef/client.d/etc/chef/config.d~/chef/solo.d
(There is no support for a knife.d directory; use config.d instead.)
For example, when using knife, the following configuration files would be loaded:
~/.chef/config.rb~/.chef/config.d/company_settings.rb~/.chef/config.d/ec2_configuration.rb~/.chef/config.d/old_settings.rb.bak
The old_settings.rb.bak file is ignored because it’s not a configuration file. The config.rb, company_settings.rb, and ec2_configuration files are merged together as if they are a single configuration file.
Note
If multiple configuration files exists in a .d directory, ensure that the same setting has the same value in all files.
Ohai Settings
Ohai configuration settings can be added to the client.rb file.
ohai.directoryThe directory in which Ohai plugins are located.
ohai.disabled_plugins-
An array of Ohai plugins to be disabled on a node. The list of plugins included in Ohai can be found in the ohai/lib/ohai/plugins source. For example, disabling a single plugin:
ohai.disabled_plugins = [ :MyPlugin ]or disabling multiple plugins:
ohai.disabled_plugins = [ :MyPlugin, :MyPlugin2, :MyPlugin3 ]When a plugin is disabled, the Chef Infra Client log file will contain entries similar to:
[2014-06-13T23:49:12+00:00] DEBUG: Skipping disabled plugin MyPlugin ohai.hints_pathThe path to the file that contains hints for Ohai.
ohai.log_levelThe level of logging to be stored in a log file.
ohai.log_locationThe location of the log file.
ohai.plugin_path-
An array of paths at which Ohai plugins are located. Default value:
[<CHEF_GEM_PATH>/ohai-9.9.9/lib/ohai/plugins]. When custom Ohai plugins are added, the paths must be added to the array. For example, a single plugin:ohai.plugin_path << '/etc/chef/ohai_plugins'and for multiple plugins:
ohai.plugin_path += [ '/etc/chef/ohai_plugins', '/path/to/other/plugins' ]
Note
The Ohai executable ignores settings in the client.rb file when Ohai is run independently of Chef Infra Client.
Example
A sample client.rb file that contains the most simple way to connect to Hosted Chef
chef_server_url 'https://api.chef.io/organizations/<orgname>'
validation_client_name '<orgname>-validator'
validation_key '/etc/chef/validator.pem'
client_key '/etc/chef/client.pem'
© Chef Software, Inc.
Licensed under the Creative Commons Attribution 3.0 Unported License.
The Chef™ Mark and Chef Logo are either registered trademarks/service marks or trademarks/servicemarks of Chef, in the United States and other countries and are used with Chef Inc's permission.
We are not affiliated with, endorsed or sponsored by Chef Inc.
https://docs.chef.io/config_rb_client/