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