github.com/hugorut/terraform@v1.1.3/website/docs/language/resources/provisioners/chef.mdx (about) 1 --- 2 page_title: 'Provisioner: chef' 3 description: >- 4 The `chef` provisioner installs, configures and runs the Chef client on a 5 resource. 6 --- 7 8 # Chef Provisioner 9 10 The `chef` provisioner installs, configures and runs the Chef Client on a remote 11 resource. The `chef` provisioner supports both `ssh` and `winrm` type 12 [connections](/language/resources/provisioners/connection). 13 14 !> **Note:** This provisioner was removed in the 0.15.0 version of Terraform after being deprecated as of Terraform 0.13.4. For most common situations there are better alternatives to using provisioners. For more information, see [the main Provisioners page](/language/resources/provisioners). 15 16 ## Requirements 17 18 The `chef` provisioner has some prerequisites for specific connection types: 19 20 * For `ssh` type connections, `cURL` must be available on the remote host. 21 * For `winrm` connections, `PowerShell 2.0` must be available on the remote host. 22 23 [Chef end user license agreement](https://www.chef.io/end-user-license-agreement/) must be accepted by setting `chef_license` to `accept` in `client_options` argument unless you are installing an old version of Chef client. 24 25 Without these prerequisites, your provisioning execution will fail. 26 27 ## Example usage 28 29 ```hcl 30 resource "aws_instance" "web" { 31 # ... 32 33 provisioner "chef" { 34 attributes_json = <<EOF 35 { 36 "key": "value", 37 "app": { 38 "cluster1": { 39 "nodes": [ 40 "webserver1", 41 "webserver2" 42 ] 43 } 44 } 45 } 46 EOF 47 48 environment = "_default" 49 client_options = ["chef_license 'accept'"] 50 run_list = ["cookbook::recipe"] 51 node_name = "webserver1" 52 secret_key = "${file("../encrypted_data_bag_secret")}" 53 server_url = "https://chef.company.com/organizations/org1" 54 recreate_client = true 55 user_name = "bork" 56 user_key = "${file("../bork.pem")}" 57 version = "15.10.13" 58 # If you have a self signed cert on your chef server change this to :verify_none 59 ssl_verify_mode = ":verify_peer" 60 } 61 } 62 ``` 63 64 ## Argument Reference 65 66 The following arguments are supported: 67 68 * `attributes_json (string)` - (Optional) A raw JSON string with initial node attributes 69 for the new node. These can also be loaded from a file on disk using 70 [the `file` function](/language/functions/file). 71 72 * `channel (string)` - (Optional) The Chef Client release channel to install from. If not 73 set, the `stable` channel will be used. 74 75 * `client_options (array)` - (Optional) A list of optional Chef Client configuration 76 options. See the [Chef Client ](https://docs.chef.io/config_rb_client.html) documentation 77 for all available options. 78 79 * `disable_reporting (boolean)` - (Optional) If `true` the Chef Client will not try to send 80 reporting data (used by Chef Reporting) to the Chef Server (defaults to `false`). 81 82 * `environment (string)` - (Optional) The Chef environment the new node will be joining 83 (defaults to `_default`). 84 85 * `fetch_chef_certificates (boolean)` (Optional) If `true` the SSL certificates configured 86 on your Chef Server will be fetched and trusted. See the knife [ssl_fetch](https://docs.chef.io/knife_ssl_fetch.html) 87 documentation for more details. 88 89 * `log_to_file (boolean)` - (Optional) If `true`, the output of the initial Chef Client run 90 will be logged to a local file instead of the console. The file will be created in a 91 subdirectory called `logfiles` created in your current directory. The filename will be 92 the `node_name` of the new node. 93 94 * `use_policyfile (boolean)` - (Optional) If `true`, use the policy files to bootstrap the 95 node. Setting `policy_group` and `policy_name` are required if this is `true`. (defaults to 96 `false`). 97 98 * `policy_group (string)` - (Optional) The name of a policy group that exists on the Chef 99 server. Required if `use_policyfile` is set; `policy_name` must also be specified. 100 101 * `policy_name (string)` - (Optional) The name of a policy, as identified by the `name` 102 setting in a Policyfile.rb file. Required if `use_policyfile` is set; `policy_group` 103 must also be specified. 104 105 * `http_proxy (string)` - (Optional) The proxy server for Chef Client HTTP connections. 106 107 * `https_proxy (string)` - (Optional) The proxy server for Chef Client HTTPS connections. 108 109 * `max_retries (integer)` - (Optional) The number of times to retry the provisioning process 110 after receiving an exit code in the `retry_on_error` list. Defaults to `0` 111 112 * `named_run_list (string)` - (Optional) The name of an alternate run-list to invoke during the 113 initial Chef Client run. The run-list must already exist in the Policyfile that defines 114 `policy_name`. Only applies when `use_policyfile` is `true`. 115 116 * `no_proxy (array)` - (Optional) A list of URLs that should bypass the proxy. 117 118 * `node_name (string)` - (Required) The name of the node to register with the Chef Server. 119 120 * `ohai_hints (array)` - (Optional) A list with 121 [Ohai hints](https://docs.chef.io/ohai.html#hints) to upload to the node. 122 123 * `os_type (string)` - (Optional) The OS type of the node. Valid options are: `linux` and 124 `windows`. If not supplied, the connection type will be used to determine the OS type (`ssh` 125 will assume `linux` and `winrm` will assume `windows`). 126 127 * `prevent_sudo (boolean)` - (Optional) Prevent the use of the `sudo` command while installing, configuring 128 and running the initial Chef Client run. This option is only used with `ssh` type 129 [connections](/language/resources/provisioners/connection). 130 131 * `recreate_client (boolean)` - (Optional) If `true`, first delete any existing Chef Node and 132 Client before registering the new Chef Client. 133 134 * `retry_on_error (array)` - (Optional) The error codes upon which Terraform should 135 gracefully retry the provisioning process. Intended for use with 136 [Chef RFC062 codes](https://github.com/chef-boneyard/chef-rfc/blob/master/rfc062-exit-status.md). 137 (Defaults to `[35, 37, 213]`) 138 139 * `run_list (array)` - (Optional) A list with recipes that will be invoked during the initial 140 Chef Client run. The run-list will also be saved to the Chef Server after a successful 141 initial run. Required if `use_policyfile` is `false`; ignored when `use_policyfile` is `true` 142 (see `named_run_list` to specify a run-list defined in a Policyfile). 143 144 * `secret_key (string)` - (Optional) The contents of the secret key that is used 145 by the Chef Client to decrypt data bags on the Chef Server. The key will be uploaded to the remote 146 machine. This can also be loaded from a file on disk using 147 [the `file` function](/language/functions/file). 148 149 * `server_url (string)` - (Required) The URL to the Chef server. This includes the path to 150 the organization. See the example. 151 152 * `skip_install (boolean)` - (Optional) Skip the installation of Chef Client on the remote 153 machine. This assumes Chef Client is already installed when you run the `chef` 154 provisioner. 155 156 * `skip_register (boolean)` - (Optional) Skip the registration of Chef Client on the remote 157 machine. This assumes Chef Client is already registered and the private key (`client.pem`) 158 is available in the default Chef configuration directory when you run the `chef` 159 provisioner. 160 161 * `ssl_verify_mode (string)` - (Optional) Used to set the verify mode for Chef Client HTTPS 162 requests. The options are `:verify_none`, or `:verify_peer` which is default. 163 164 * `user_name (string)` - (Required) The name of an existing Chef user to register 165 the new Chef Client and optionally configure Chef Vaults. 166 167 * `user_key (string)` - (Required) The contents of the user key that will be used to 168 authenticate with the Chef Server. This can also be loaded from a file on disk using 169 [the `file` function](/language/functions/file). 170 171 * `vault_json (string)` - (Optional) A raw JSON string with Chef Vaults and Items to which the new node 172 should have access. These can also be loaded from a file on disk using 173 [the `file` function](/language/functions/file). 174 175 * `version (string)` - (Optional) The Chef Client version to install on the remote machine. 176 If not set, the latest available version will be installed. 177 178 * `wait_for_retry (integer)` - (Optional) - Amount of time in seconds to wait before 179 retrying the provisionining process after receiving an exit code in the `retry_on_error` 180 list. Defaults to `30`.