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