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