github.com/aspring/packer@v0.8.1-0.20150629211158-9db281ac0f89/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](https://docs.chef.io/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 Chef Inc. 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 * `chef_environment` (string) - The name of the `chef_environment` sent to the 38 Chef server. By default this is empty and will not use an environment 39 40 * `config_template` (string) - Path to a template that will be used for 41 the Chef configuration file. By default Packer only sets configuration 42 it needs to match the settings set in the provisioner configuration. If 43 you need to set configurations that the Packer provisioner doesn't support, 44 then you should use a custom configuration template. See the dedicated 45 "Chef Configuration" section below for more details. 46 47 * `cookbook_paths` (array of strings) - This is an array of paths to 48 "cookbooks" directories on your local filesystem. These will be uploaded 49 to the remote machine in the directory specified by the `staging_directory`. 50 By default, this is empty. 51 52 * `data_bags_path` (string) - The path to the "data\_bags" directory on your local filesystem. 53 These will be uploaded to the remote machine in the directory specified by the 54 `staging_directory`. By default, this is empty. 55 56 * `encrypted_data_bag_secret_path` (string) - The path to the file containing 57 the secret for encrypted data bags. By default, this is empty, so no 58 secret will be available. 59 60 * `environments_path` (string) - The path to the "environments" directory on your local filesystem. 61 These will be uploaded to the remote machine in the directory specified by the 62 `staging_directory`. By default, this is empty. 63 64 * `execute_command` (string) - The command used to execute Chef. This has 65 various [configuration template variables](/docs/templates/configuration-templates.html) 66 available. See below for more information. 67 68 * `install_command` (string) - The command used to install Chef. This has 69 various [configuration template variables](/docs/templates/configuration-templates.html) 70 available. See below for more information. 71 72 * `json` (object) - An arbitrary mapping of JSON that will be available as 73 node attributes while running Chef. 74 75 * `prevent_sudo` (boolean) - By default, the configured commands that are 76 executed to install and run Chef are executed with `sudo`. If this is true, 77 then the sudo will be omitted. 78 79 * `remote_cookbook_paths` (array of strings) - A list of paths on the remote 80 machine where cookbooks will already exist. These may exist from a previous 81 provisioner or step. If specified, Chef will be configured to look for 82 cookbooks here. By default, this is empty. 83 84 * `roles_path` (string) - The path to the "roles" directory on your local filesystem. 85 These will be uploaded to the remote machine in the directory specified by the 86 `staging_directory`. By default, this is empty. 87 88 * `run_list` (array of strings) - The [run list](https://docs.chef.io/run_lists.html) 89 for Chef. By default this is empty. 90 91 * `skip_install` (boolean) - If true, Chef will not automatically be installed 92 on the machine using the Chef omnibus installers. 93 94 * `staging_directory` (string) - This is the directory where all the configuration 95 of Chef by Packer will be placed. By default this is "/tmp/packer-chef-solo". 96 This directory doesn't need to exist but must have proper permissions so that 97 the SSH user that Packer uses is able to create directories and write into 98 this folder. If the permissions are not correct, use a shell provisioner 99 prior to this to configure it properly. 100 101 ## Chef Configuration 102 103 By default, Packer uses a simple Chef configuration file in order to set 104 the options specified for the provisioner. But Chef is a complex tool that 105 supports many configuration options. Packer allows you to specify a custom 106 configuration template if you'd like to set custom configurations. 107 108 The default value for the configuration template is: 109 110 ```liquid 111 cookbook_path [{{.CookbookPaths}}] 112 ``` 113 114 This template is a [configuration template](/docs/templates/configuration-templates.html) 115 and has a set of variables available to use: 116 117 * `ChefEnvironment` - The current enabled environment. Only non-empty 118 if the environment path is set. 119 * `CookbookPaths` is the set of cookbook paths ready to embedded directly 120 into a Ruby array to configure Chef. 121 * `DataBagsPath` is the path to the data bags folder. 122 * `EncryptedDataBagSecretPath` - The path to the encrypted data bag secret 123 * `EnvironmentsPath` - The path to the environments folder. 124 * `RolesPath` - The path to the roles folder. 125 126 ## Execute Command 127 128 By default, Packer uses the following command (broken across multiple lines 129 for readability) to execute Chef: 130 131 ```liquid 132 {{if .Sudo}}sudo {{end}}chef-solo \ 133 --no-color \ 134 -c {{.ConfigPath}} \ 135 -j {{.JsonPath}} 136 ``` 137 138 This command can be customized using the `execute_command` configuration. 139 As you can see from the default value above, the value of this configuration 140 can contain various template variables, defined below: 141 142 * `ConfigPath` - The path to the Chef configuration file. 143 file. 144 * `JsonPath` - The path to the JSON attributes file for the node. 145 * `Sudo` - A boolean of whether to `sudo` the command or not, depending on 146 the value of the `prevent_sudo` configuration. 147 148 ## Install Command 149 150 By default, Packer uses the following command (broken across multiple lines 151 for readability) to install Chef. This command can be customized if you want 152 to install Chef in another way. 153 154 ```text 155 curl -L https://www.chef.io/chef/install.sh | \ 156 {{if .Sudo}}sudo{{end}} bash 157 ``` 158 159 This command can be customized using the `install_command` configuration.