github.com/supr/packer@v0.3.10-0.20131015195147-7b09e24ac3c1/website/source/docs/provisioners/chef-solo.html.markdown (about)

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