github.com/kaixiang/packer@v0.5.2-0.20140114230416-1f5786b0d7f1/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  * `data_bags_path` (string) - The path to the "data\_bags" 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  * `encrypted_data_bag_secret_path` (string) - The path to the file containing
    52    the secret for encrypted data bags. By default, this is empty, so no
    53    secret will be available.
    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  * `json` (object) - An arbitrary mapping of JSON that will be available as
    64    node attributes while running Chef.
    65  
    66  * `remote_cookbook_paths` (array of string) - A list of paths on the remote
    67    machine where cookbooks will already exist. These may exist from a previous
    68    provisioner or step. If specified, Chef will be configured to look for
    69    cookbooks here. By default, this is empty.
    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  * `roles_path` (string) - The path to the "roles" directory on your local filesystem.
    76    These will be uploaded to the remote machine in the directory specified by the
    77    `staging_directory`.  By default, this is empty.
    78  
    79  * `run_list` (array of strings) - The [run list](http://docs.opscode.com/essentials_node_object_run_lists.html)
    80    for Chef. By default this is empty.
    81  
    82  * `skip_install` (boolean) - If true, Chef will not automatically be installed
    83    on the machine using the Opscode omnibus installers.
    84  
    85  * `staging_directory` (string) - This is the directory where all the configuration
    86    of Chef by Packer will be placed. By default this is "/tmp/packer-chef-solo".
    87    This directory doesn't need to exist but must have proper permissions so that
    88    the SSH user that Packer uses is able to create directories and write into
    89    this folder. If the permissions are not correct, use a shell provisioner
    90    prior to this to configure it properly.
    91  
    92  ## Chef Configuration
    93  
    94  By default, Packer uses a simple Chef configuration file in order to set
    95  the options specified for the provisioner. But Chef is a complex tool that
    96  supports many configuration options. Packer allows you to specify a custom
    97  configuration template if you'd like to set custom configurations.
    98  
    99  The default value for the configuration template is:
   100  
   101  ```
   102  cookbook_path [{{.CookbookPaths}}]
   103  ```
   104  
   105  This template is a [configuration template](/docs/templates/configuration-templates.html)
   106  and has a set of variables available to use:
   107  
   108  * `ChefEnvironment` - The current enabled environment. Only non-empty
   109    if the environment path is set.
   110  * `CookbookPaths` is the set of cookbook paths ready to embedded directly
   111    into a Ruby array to configure Chef.
   112  * `DataBagsPath` is the path to the data bags folder.
   113  * `EncryptedDataBagSecretPath` - The path to the encrypted data bag secret
   114  * `EnvironmentsPath` - The path to the environments folder.
   115  * `RolesPath` - The path the folders folder.
   116  
   117  ## Execute Command
   118  
   119  By default, Packer uses the following command (broken across multiple lines
   120  for readability) to execute Chef:
   121  
   122  ```
   123  {{if .Sudo}}sudo {{end}}chef-solo \
   124    --no-color \
   125    -c {{.ConfigPath}} \
   126    -j {{.JsonPath}}
   127  ```
   128  
   129  This command can be customized using the `execute_command` configuration.
   130  As you can see from the default value above, the value of this configuration
   131  can contain various template variables, defined below:
   132  
   133  * `ConfigPath` - The path to the Chef configuration file.
   134    file.
   135  * `JsonPath` - The path to the JSON attributes file for the node.
   136  * `Sudo` - A boolean of whether to `sudo` the command or not, depending on
   137    the value of the `prevent_sudo` configuration.
   138  
   139  ## Install Command
   140  
   141  By default, Packer uses the following command (broken across multiple lines
   142  for readability) to install Chef. This command can be customized if you want
   143  to install Chef in another way.
   144  
   145  ```
   146  curl -L https://www.opscode.com/chef/install.sh | \
   147    {{if .Sudo}}sudo{{end}} bash
   148  ```
   149  
   150  This command can be customized using the `install_command` configuration.