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