5.4 KiB
layout | page_title | sidebar_current | description |
---|---|---|---|
docs | Provisioner: chef | docs-provisioners-chef | The `chef` provisioner invokes a Chef Client run on a remote resource after first installing and configuring Chef Client on the remote resource. The `chef` provisioner supports both `ssh` and `winrm` type connections. |
Chef Provisioner
The chef
provisioner invokes a Chef Client run on a remote resource after first installing
and configuring Chef Client on the remote resource. The chef
provisioner supports both ssh
and winrm
type connections.
Requirements
In order for the chef
provisioner to work properly, you need either cURL
(when using
a ssh
type connection) or PowerShell 2.0
(when using a winrm
type connection) to be
available on the target machine.
Example usage
# Start a initial chef run on a resource
resource "aws_instance" "web" {
...
provisioner "chef" {
attributes = <<EOF
{
"key": "value",
"app": {
"cluster1": {
"nodes": [
"webserver1",
"webserver2"
]
}
}
}
EOF
environment = "_default"
run_list = ["cookbook::recipe"]
node_name = "webserver1"
secret_key = "${file("../encrypted_data_bag_secret")}"
server_url = "https://chef.company.com/organizations/org1"
validation_client_name = "chef-validator"
validation_key = "${file("../chef-validator.pem")}"
version = "12.4.1"
}
}
Argument Reference
The following arguments are supported:
-
attributes (string)
- (Optional) A raw JSON string with initial node attributes for the new node. These can also be loaded from a file on disk using thefile()
interpolation function. -
client_options (array)
- (Optional) A list of optional Chef Client configuration options. See the Chef Client documentation for all available options. -
disable_reporting (boolean)
- (Optional) If true the Chef Client will not try to send reporting data (used by Chef Reporting) to the Chef Server (defaults false) -
environment (string)
- (Optional) The Chef environment the new node will be joining (defaults_default
). -
log_to_file (boolean)
- (Optional) If true, the output of the initial Chef Client run will be logged to a local file instead of the console. The file will be created in a subdirectory calledlogfiles
created in your current directory. The filename will be thenode_name
of the new node. -
http_proxy (string)
- (Optional) The proxy server for Chef Client HTTP connections. -
https_proxy (string)
- (Optional) The proxy server for Chef Client HTTPS connections. -
no_proxy (array)
- (Optional) A list of URLs that should bypass the proxy. -
node_name (string)
- (Required) The name of the node to register with the Chef Server. -
ohai_hints (array)
- (Optional) A list with Ohai hints to upload to the node. -
os_type (string)
- (Optional) The OS type of the node. Valid options are:linux
andwindows
. If not supplied the connection type will be used to determine the OS type (ssh
will assumelinux
andwinrm
will assumewindows
). -
prevent_sudo (boolean)
- (Optional) Prevent the use of sudo while installing, configuring and running the initial Chef Client run. This option is only used withssh
type connections. -
run_list (array)
- (Required) A list with recipes that will be invoked during the initial Chef Client run. The run-list will also be saved to the Chef Server after a successful initial run. -
secret_key (string)
- (Optional) The contents of the secret key that is used by the client to decrypt data bags on the Chef Server. The key will be uploaded to the remote machine. These can be loaded from a file on disk using thefile()
interpolation function. -
server_url (string)
- (Required) The URL to the Chef server. This includes the path to the organization. See the example. -
skip_install (boolean)
- (Optional) Skip the installation of Chef Client on the remote machine. This assumes Chef Client is already installed when you run thechef
provisioner. -
ssl_verify_mode (string)
- (Optional) Use to set the verify mode for Chef Client HTTPS requests. -
validation_client_name (string)
- (Required) The name of the validation client to use for the initial communication with the Chef Server. -
validation_key (string)
- (Required) The contents of the validation key that is needed by the node to register itself with the Chef Server. The key will be uploaded to the remote machine. These can be loaded from a file on disk using thefile()
interpolation function. -
version (string)
- (Optional) The Chef Client version to install on the remote machine. If not set the latest available version will be installed.
These are supported for backwards compatibility and may be removed in a future version:
validation_key_path (string)
- Deprecated: please usevalidation_key
instead.secret_key_path (string)
- Deprecated: please usesecret_key
instead.