github.com/kikitux/packer@v0.10.1-0.20160322154024-6237df566f9f/website/source/docs/provisioners/chef-solo.html.md (about) 1 --- 2 description: | 3 The Chef solo Packer provisioner installs and configures software on machines 4 built by Packer using chef-solo. Cookbooks can be uploaded from your local 5 machine to the remote machine or remote paths can be used. 6 layout: docs 7 page_title: 'Chef-Solo Provisioner' 8 ... 9 10 # Chef Solo Provisioner 11 12 Type: `chef-solo` 13 14 The Chef solo Packer provisioner installs and configures software on machines 15 built by Packer using [chef-solo](https://docs.chef.io/chef_solo.html). 16 Cookbooks can be uploaded from your local machine to the remote machine or 17 remote paths can be used. 18 19 The provisioner will even install Chef onto your machine if it isn't already 20 installed, using the official Chef installers provided by Chef Inc. 21 22 ## Basic Example 23 24 The example below is fully functional and expects cookbooks in the "cookbooks" 25 directory relative to your working directory. 26 27 ``` {.javascript} 28 { 29 "type": "chef-solo", 30 "cookbook_paths": ["cookbooks"] 31 } 32 ``` 33 34 ## Configuration Reference 35 36 The reference of available configuration options is listed below. No 37 configuration is actually required, but at least `run_list` is recommended. 38 39 - `chef_environment` (string) - The name of the `chef_environment` sent to the 40 Chef server. By default this is empty and will not use an environment 41 42 - `config_template` (string) - Path to a template that will be used for the 43 Chef configuration file. By default Packer only sets configuration it needs 44 to match the settings set in the provisioner configuration. If you need to 45 set configurations that the Packer provisioner doesn't support, then you 46 should use a custom configuration template. See the dedicated "Chef 47 Configuration" section below for more details. 48 49 - `cookbook_paths` (array of strings) - This is an array of paths to 50 "cookbooks" directories on your local filesystem. These will be uploaded to 51 the remote machine in the directory specified by the `staging_directory`. By 52 default, this is empty. 53 54 - `data_bags_path` (string) - The path to the "data\_bags" directory on your 55 local filesystem. These will be uploaded to the remote machine in the 56 directory specified by the `staging_directory`. By default, this is empty. 57 58 - `encrypted_data_bag_secret_path` (string) - The path to the file containing 59 the secret for encrypted data bags. By default, this is empty, so no secret 60 will be available. 61 62 - `environments_path` (string) - The path to the "environments" directory on 63 your local filesystem. These will be uploaded to the remote machine in the 64 directory specified by the `staging_directory`. By default, this is empty. 65 66 - `execute_command` (string) - The command used to execute Chef. This has 67 various [configuration template 68 variables](/docs/templates/configuration-templates.html) available. See 69 below for more information. 70 71 - `guest_os_type` (string) - The target guest OS type, either "unix" or 72 "windows". Setting this to "windows" will cause the provisioner to use 73 Windows friendly paths and commands. By default, this is "unix". 74 75 - `install_command` (string) - The command used to install Chef. This has 76 various [configuration template 77 variables](/docs/templates/configuration-templates.html) available. See 78 below for more information. 79 80 - `json` (object) - An arbitrary mapping of JSON that will be available as 81 node attributes while running Chef. 82 83 - `prevent_sudo` (boolean) - By default, the configured commands that are 84 executed to install and run Chef are executed with `sudo`. If this is true, 85 then the sudo will be omitted. This has no effect when guest_os_type is 86 windows. 87 88 - `remote_cookbook_paths` (array of strings) - A list of paths on the remote 89 machine where cookbooks will already exist. These may exist from a previous 90 provisioner or step. If specified, Chef will be configured to look for 91 cookbooks here. By default, this is empty. 92 93 - `roles_path` (string) - The path to the "roles" directory on your 94 local filesystem. These will be uploaded to the remote machine in the 95 directory specified by the `staging_directory`. By default, this is empty. 96 97 - `run_list` (array of strings) - The [run 98 list](https://docs.chef.io/run_lists.html) for Chef. By default this 99 is empty. 100 101 - `skip_install` (boolean) - If true, Chef will not automatically be installed 102 on the machine using the Chef omnibus installers. 103 104 - `staging_directory` (string) - This is the directory where all the 105 configuration of Chef by Packer will be placed. By default this is 106 "/tmp/packer-chef-solo" when guest_os_type unix and 107 "$env:TEMP/packer-chef-solo" when windows. This directory doesn't need to 108 exist but must have proper permissions so that the user that Packer uses is 109 able to create directories and write into this folder. If the permissions 110 are not correct, use a shell provisioner prior to this to configure it 111 properly. 112 113 ## Chef Configuration 114 115 By default, Packer uses a simple Chef configuration file in order to set the 116 options specified for the provisioner. But Chef is a complex tool that supports 117 many configuration options. Packer allows you to specify a custom configuration 118 template if you'd like to set custom configurations. 119 120 The default value for the configuration template is: 121 122 ``` {.liquid} 123 cookbook_path [{{.CookbookPaths}}] 124 ``` 125 126 This template is a [configuration 127 template](/docs/templates/configuration-templates.html) and has a set of 128 variables available to use: 129 130 - `ChefEnvironment` - The current enabled environment. Only non-empty if the 131 environment path is set. 132 - `CookbookPaths` is the set of cookbook paths ready to embedded directly into 133 a Ruby array to configure Chef. 134 - `DataBagsPath` is the path to the data bags folder. 135 - `EncryptedDataBagSecretPath` - The path to the encrypted data bag secret 136 - `EnvironmentsPath` - The path to the environments folder. 137 - `RolesPath` - The path to the roles folder. 138 139 ## Execute Command 140 141 By default, Packer uses the following command (broken across multiple lines for 142 readability) to execute Chef: 143 144 ``` {.liquid} 145 {{if .Sudo}}sudo {{end}}chef-solo \ 146 --no-color \ 147 -c {{.ConfigPath}} \ 148 -j {{.JsonPath}} 149 ``` 150 151 When guest_os_type is set to "windows", Packer uses the following command to 152 execute Chef. The full path to Chef is required because the PATH environment 153 variable changes don't immediately propogate to running processes. 154 155 ``` {.liquid} 156 c:/opscode/chef/bin/chef-solo.bat \ 157 --no-color \ 158 -c {{.ConfigPath}} \ 159 -j {{.JsonPath}} 160 ``` 161 162 This command can be customized using the `execute_command` configuration. As you 163 can see from the default value above, the value of this configuration can 164 contain various template variables, defined below: 165 166 - `ConfigPath` - The path to the Chef configuration file. file. 167 - `JsonPath` - The path to the JSON attributes file for the node. 168 - `Sudo` - A boolean of whether to `sudo` the command or not, depending on the 169 value of the `prevent_sudo` configuration. 170 171 ## Install Command 172 173 By default, Packer uses the following command (broken across multiple lines for 174 readability) to install Chef. This command can be customized if you want to 175 install Chef in another way. 176 177 ``` {.text} 178 curl -L https://www.chef.io/chef/install.sh | \ 179 {{if .Sudo}}sudo{{end}} bash 180 ``` 181 182 When guest_os_type is set to "windows", Packer uses the following command to 183 install the latest version of Chef: 184 185 ``` {.text} 186 powershell.exe -Command "(New-Object System.Net.WebClient).DownloadFile('http://chef.io/chef/install.msi', 'C:\\Windows\\Temp\\chef.msi');Start-Process 'msiexec' -ArgumentList '/qb /i C:\\Windows\\Temp\\chef.msi' -NoNewWindow -Wait" 187 ``` 188 189 This command can be customized using the `install_command` configuration.