github.com/daniellockard/packer@v0.7.6-0.20141210173435-5a9390934716/website/source/docs/provisioners/chef-solo.html.markdown (about)

     1  ---
     2  layout: "docs"
     3  page_title: "Chef-Solo Provisioner"
     4  description: |-
     5    The Chef solo Packer provisioner installs and configures software on machines built by Packer using chef-solo. Cookbooks can be uploaded from your local machine to the remote machine or remote paths can be used.
     6  ---
     7  
     8  # Chef Solo Provisioner
     9  
    10  Type: `chef-solo`
    11  
    12  The Chef solo Packer provisioner installs and configures software on machines built
    13  by Packer using [chef-solo](http://docs.opscode.com/chef_solo.html). Cookbooks
    14  can be uploaded from your local machine to the remote machine or remote paths
    15  can be used.
    16  
    17  The provisioner will even install Chef onto your machine if it isn't already
    18  installed, using the official Chef installers provided by Opscode.
    19  
    20  ## Basic Example
    21  
    22  The example below is fully functional and expects cookbooks in the
    23  "cookbooks" directory relative to your working directory.
    24  
    25  ```javascript
    26  {
    27    "type": "chef-solo",
    28    "cookbook_paths": ["cookbooks"]
    29  }
    30  ```
    31  
    32  ## Configuration Reference
    33  
    34  The reference of available configuration options is listed below. No
    35  configuration is actually required, but at least `run_list` is recommended.
    36  
    37  * `config_template` (string) - Path to a template that will be used for
    38    the Chef configuration file. By default Packer only sets configuration
    39    it needs to match the settings set in the provisioner configuration. If
    40    you need to set configurations that the Packer provisioner doesn't support,
    41    then you should use a custom configuration template. See the dedicated
    42    "Chef Configuration" section below for more details.
    43  
    44  * `cookbook_paths` (array of strings) - This is an array of paths to
    45    "cookbooks" directories on your local filesystem. These will be uploaded
    46    to the remote machine in the directory specified by the `staging_directory`.
    47    By default, this is empty.
    48  
    49  * `data_bags_path` (string) - The path to the "data\_bags" directory on your local filesystem.
    50    These will be uploaded to the remote machine in the directory specified by the
    51    `staging_directory`.  By default, this is empty.
    52  
    53  * `encrypted_data_bag_secret_path` (string) - The path to the file containing
    54    the secret for encrypted data bags. By default, this is empty, so no
    55    secret will be available.
    56  
    57  * `execute_command` (string) - The command used to execute Chef. This has
    58    various [configuration template variables](/docs/templates/configuration-templates.html)
    59    available. See below for more information.
    60  
    61  * `install_command` (string) - The command used to install Chef. This has
    62    various [configuration template variables](/docs/templates/configuration-templates.html)
    63    available. See below for more information.
    64  
    65  * `json` (object) - An arbitrary mapping of JSON that will be available as
    66    node attributes while running Chef.
    67  
    68  * `prevent_sudo` (boolean) - By default, the configured commands that are
    69    executed to install and run Chef are executed with `sudo`. If this is true,
    70    then the sudo will be omitted.
    71  
    72  * `remote_cookbook_paths` (array of strings) - A list of paths on the remote
    73    machine where cookbooks will already exist. These may exist from a previous
    74    provisioner or step. If specified, Chef will be configured to look for
    75    cookbooks here. By default, this is empty.
    76  
    77  * `roles_path` (string) - The path to the "roles" directory on your local filesystem.
    78    These will be uploaded to the remote machine in the directory specified by the
    79    `staging_directory`.  By default, this is empty.
    80  
    81  * `run_list` (array of strings) - The [run list](http://docs.opscode.com/essentials_node_object_run_lists.html)
    82    for Chef. By default this is empty.
    83  
    84  * `skip_install` (boolean) - If true, Chef will not automatically be installed
    85    on the machine using the Opscode omnibus installers.
    86  
    87  * `staging_directory` (string) - This is the directory where all the configuration
    88    of Chef by Packer will be placed. By default this is "/tmp/packer-chef-solo".
    89    This directory doesn't need to exist but must have proper permissions so that
    90    the SSH user that Packer uses is able to create directories and write into
    91    this folder. If the permissions are not correct, use a shell provisioner
    92    prior to this to configure it properly.
    93  
    94  ## Chef Configuration
    95  
    96  By default, Packer uses a simple Chef configuration file in order to set
    97  the options specified for the provisioner. But Chef is a complex tool that
    98  supports many configuration options. Packer allows you to specify a custom
    99  configuration template if you'd like to set custom configurations.
   100  
   101  The default value for the configuration template is:
   102  
   103  ```liquid
   104  cookbook_path [{{.CookbookPaths}}]
   105  ```
   106  
   107  This template is a [configuration template](/docs/templates/configuration-templates.html)
   108  and has a set of variables available to use:
   109  
   110  * `ChefEnvironment` - The current enabled environment. Only non-empty
   111    if the environment path is set.
   112  * `CookbookPaths` is the set of cookbook paths ready to embedded directly
   113    into a Ruby array to configure Chef.
   114  * `DataBagsPath` is the path to the data bags folder.
   115  * `EncryptedDataBagSecretPath` - The path to the encrypted data bag secret
   116  * `EnvironmentsPath` - The path to the environments folder.
   117  * `RolesPath` - The path to the roles folder.
   118  
   119  ## Execute Command
   120  
   121  By default, Packer uses the following command (broken across multiple lines
   122  for readability) to execute Chef:
   123  
   124  ```liquid
   125  {{if .Sudo}}sudo {{end}}chef-solo \
   126    --no-color \
   127    -c {{.ConfigPath}} \
   128    -j {{.JsonPath}}
   129  ```
   130  
   131  This command can be customized using the `execute_command` configuration.
   132  As you can see from the default value above, the value of this configuration
   133  can contain various template variables, defined below:
   134  
   135  * `ConfigPath` - The path to the Chef configuration file.
   136    file.
   137  * `JsonPath` - The path to the JSON attributes file for the node.
   138  * `Sudo` - A boolean of whether to `sudo` the command or not, depending on
   139    the value of the `prevent_sudo` configuration.
   140  
   141  ## Install Command
   142  
   143  By default, Packer uses the following command (broken across multiple lines
   144  for readability) to install Chef. This command can be customized if you want
   145  to install Chef in another way.
   146  
   147  ```text
   148  curl -L https://www.opscode.com/chef/install.sh | \
   149    {{if .Sudo}}sudo{{end}} bash
   150  ```
   151  
   152  This command can be customized using the `install_command` configuration.