github.com/mmcquillan/packer@v1.1.1-0.20171009221028-c85cf0483a5d/website/source/docs/builders/openstack.html.md (about) 1 --- 2 description: | 3 The openstack Packer builder is able to create new images for use with 4 OpenStack. The builder takes a source image, runs any provisioning necessary 5 on the image after launching it, then creates a new reusable image. This 6 reusable image can then be used as the foundation of new servers that are 7 launched within OpenStack. 8 layout: docs 9 page_title: 'OpenStack - Builders' 10 sidebar_current: 'docs-builders-openstack' 11 --- 12 13 # OpenStack Builder 14 15 Type: `openstack` 16 17 The `openstack` Packer builder is able to create new images for use with 18 [OpenStack](http://www.openstack.org). The builder takes a source image, runs 19 any provisioning necessary on the image after launching it, then creates a new 20 reusable image. This reusable image can then be used as the foundation of new 21 servers that are launched within OpenStack. The builder will create temporary 22 keypairs that provide temporary access to the server while the image is being 23 created. This simplifies configuration quite a bit. 24 25 The builder does *not* manage images. Once it creates an image, it is up to you 26 to use it or delete it. 27 28 ~> **OpenStack Liberty or later requires OpenSSL!** To use the OpenStack 29 builder with OpenStack Liberty (Oct 2015) or later you need to have OpenSSL 30 installed *if you are using temporary key pairs*, i.e. don't use 31 [`ssh_keypair_name`](openstack.html#ssh_keypair_name) nor 32 [`ssh_password`](/docs/templates/communicator.html#ssh_password). All major 33 OS'es have OpenSSL installed by default except Windows. 34 35 ## Configuration Reference 36 37 There are many configuration options available for the builder. They are 38 segmented below into two categories: required and optional parameters. Within 39 each category, the available configuration keys are alphabetized. 40 41 In addition to the options listed here, a 42 [communicator](/docs/templates/communicator.html) can be configured for this 43 builder. 44 45 ### Required: 46 47 - `flavor` (string) - The ID, name, or full URL for the desired flavor for the 48 server to be created. 49 50 - `image_name` (string) - The name of the resulting image. 51 52 - `identity_endpoint` (string) - The URL to the OpenStack Identity service. 53 If not specified, Packer will use the environment variables `OS_AUTH_URL`, 54 if set. 55 56 - `source_image` (string) - The ID or full URL to the base image to use. This 57 is the image that will be used to launch a new server and provision it. 58 Unless you specify completely custom SSH settings, the source image must 59 have `cloud-init` installed so that the keypair gets assigned properly. 60 61 - `source_image_name` (string) - The name of the base image to use. This 62 is an alternative way of providing `source_image` and only either of them 63 can be specified. 64 65 - `username` or `user_id` (string) - The username or id used to connect to 66 the OpenStack service. If not specified, Packer will use the environment 67 variable `OS_USERNAME` or `OS_USERID`, if set. 68 69 - `password` (string) - The password used to connect to the OpenStack service. 70 If not specified, Packer will use the environment variables `OS_PASSWORD`, 71 if set. 72 73 ### Optional: 74 75 - `availability_zone` (string) - The availability zone to launch the 76 server in. If this isn't specified, the default enforced by your OpenStack 77 cluster will be used. This may be required for some OpenStack clusters. 78 79 - `cacert` (string) - Custom CA certificate file path. 80 If ommited the OS\_CACERT environment variable can be used. 81 82 - `config_drive` (boolean) - Whether or not nova should use ConfigDrive for 83 cloud-init metadata. 84 85 - `cert` (string) - Client certificate file path for SSL client authentication. 86 If omitted the OS\_CERT environment variable can be used. 87 88 - `domain_name` or `domain_id` (string) - The Domain name or ID you are 89 authenticating with. OpenStack installations require this if identity v3 is used. 90 Packer will use the environment variable `OS_DOMAIN_NAME` or `OS_DOMAIN_ID`, if set. 91 92 - `endpoint_type` (string) - The endpoint type to use. Can be any of "internal", 93 "internalURL", "admin", "adminURL", "public", and "publicURL". By default 94 this is "public". 95 96 - `floating_ip` (string) - A specific floating IP to assign to this instance. 97 98 - `floating_ip_pool` (string) - The name of the floating IP pool to use to 99 allocate a floating IP. 100 101 - `image_members` (array of strings) - List of members to add to the image 102 after creation. An image member is usually a project (also called the 103 “tenant”) with whom the image is shared. 104 105 - `image_visibility` (string) - One of "public", "private", "shared", or 106 "community". 107 108 - `insecure` (boolean) - Whether or not the connection to OpenStack can be 109 done over an insecure connection. By default this is false. 110 111 - `key` (string) - Client private key file path for SSL client authentication. 112 If ommited the OS\_KEY environment variable can be used. 113 114 - `metadata` (object of key/value strings) - Glance metadata that will be 115 applied to the image. 116 117 - `instance_metadata` (object of key/value strings) - Metadata that is 118 applied to the server instance created by Packer. Also called server 119 properties in some documentation. The strings have a max size of 255 bytes 120 each. 121 122 - `networks` (array of strings) - A list of networks by UUID to attach to 123 this instance. 124 125 - `rackconnect_wait` (boolean) - For rackspace, whether or not to wait for 126 Rackconnect to assign the machine an IP address before connecting via SSH. 127 Defaults to false. 128 129 - `region` (string) - The name of the region, such as "DFW", in which to 130 launch the server to create the AMI. If not specified, Packer will use the 131 environment variable `OS_REGION_NAME`, if set. 132 133 - `reuse_ips` (boolean) - Whether or not to attempt to reuse existing 134 unassigned floating ips in the project before allocating a new one. Note 135 that it is not possible to safely do this concurrently, so if you are 136 running multiple openstack builds concurrently, or if other processes are 137 assigning and using floating IPs in the same openstack project while packer 138 is running, you should not set this to true. Defaults to false. 139 140 - `security_groups` (array of strings) - A list of security groups by name to 141 add to this instance. 142 143 - `ssh_interface` (string) - The type of interface to connect via SSH. Values 144 useful for Rackspace are "public" or "private", and the default behavior is 145 to connect via whichever is returned first from the OpenStack API. 146 147 - `ssh_ip_version` (string) - The IP version to use for SSH connections, valid 148 values are `4` and `6`. Useful on dual stacked instances where the default 149 behavior is to connect via whichever IP address is returned first from the 150 OpenStack API. 151 152 - `ssh_keypair_name` (string) - If specified, this is the key that will be 153 used for SSH with the machine. By default, this is blank, and Packer will 154 generate a temporary keypair. 155 [`ssh_password`](/docs/templates/communicator.html#ssh_password) is used. 156 [`ssh_private_key_file`](/docs/templates/communicator.html#ssh_private_key_file) 157 or `ssh_agent_auth` must be specified when `ssh_keypair_name` is utilized. 158 159 - `ssh_agent_auth` (boolean) - If true, the local SSH agent will be used to 160 authenticate connections to the source instance. No temporary keypair will 161 be created, and the values of `ssh_password` and `ssh_private_key_file` will 162 be ignored. To use this option with a key pair already configured in the source 163 image, leave the `ssh_keypair_name` blank. To associate an existing key pair 164 with the source instance, set the `ssh_keypair_name` field to the name 165 of the key pair. 166 167 - `temporary_key_pair_name` (string) - The name of the temporary key pair 168 to generate. By default, Packer generates a name that looks like 169 `packer_<UUID>`, where <UUID> is a 36 character unique identifier. 170 171 - `tenant_id` or `tenant_name` (string) - The tenant ID or name to boot the 172 instance into. Some OpenStack installations require this. If not specified, 173 Packer will use the environment variable `OS_TENANT_NAME`, if set. Tenant 174 is also called Project in later versions of OpenStack. 175 176 - `use_floating_ip` (boolean) - *Deprecated* use `floating_ip` or `floating_ip_pool` 177 instead. 178 179 - `user_data` (string) - User data to apply when launching the instance. Note 180 that you need to be careful about escaping characters due to the templates 181 being JSON. It is often more convenient to use `user_data_file`, instead. 182 183 - `user_data_file` (string) - Path to a file that will be used for the user 184 data when launching the instance. 185 186 ## Basic Example: DevStack 187 188 Here is a basic example. This is a example to build on DevStack running in a VM. 189 190 ``` json 191 { 192 "type": "openstack", 193 "identity_endpoint": "http://<destack-ip>:5000/v3", 194 "tenant_name": "admin", 195 "domain_name": "Default", 196 "username": "admin", 197 "password": "<your admin password>", 198 "region": "RegionOne", 199 "ssh_username": "root", 200 "image_name": "Test image", 201 "source_image": "<image id>", 202 "flavor": "m1.tiny", 203 "insecure": "true" 204 } 205 ``` 206 207 ## Basic Example: Rackspace public cloud 208 209 Here is a basic example. This is a working example to build a Ubuntu 12.04 LTS 210 (Precise Pangolin) on Rackspace OpenStack cloud offering. 211 212 ``` json 213 { 214 "type": "openstack", 215 "username": "foo", 216 "password": "foo", 217 "region": "DFW", 218 "ssh_username": "root", 219 "image_name": "Test image", 220 "source_image": "23b564c9-c3e6-49f9-bc68-86c7a9ab5018", 221 "flavor": "2" 222 } 223 ``` 224 225 ## Basic Example: Private OpenStack cloud 226 227 This example builds an Ubuntu 14.04 image on a private OpenStack cloud, powered 228 by Metacloud. 229 230 ``` json 231 { 232 "type": "openstack", 233 "ssh_username": "root", 234 "image_name": "ubuntu1404_packer_test_1", 235 "source_image": "91d9c168-d1e5-49ca-a775-3bfdbb6c97f1", 236 "flavor": "2" 237 } 238 ``` 239 240 In this case, the connection information for connecting to OpenStack doesn't 241 appear in the template. That is because I source a standard OpenStack script 242 with environment variables set before I run this. This script is setting 243 environment variables like: 244 245 - `OS_AUTH_URL` 246 - `OS_TENANT_ID` 247 - `OS_USERNAME` 248 - `OS_PASSWORD` 249 250 This is slightly different when identity v3 is used: 251 252 - `OS_AUTH_URL` 253 - `OS_USERNAME` 254 - `OS_PASSWORD` 255 - `OS_DOMAIN_NAME` 256 - `OS_TENANT_NAME` 257 258 This will authenticate the user on the domain and scope you to the project. 259 A tenant is the same as a project. It's optional to use names or IDs in v3. 260 This means you can use `OS_USERNAME` or `OS_USERID`, `OS_TENANT_ID` or 261 `OS_TENANT_NAME` and `OS_DOMAIN_ID` or `OS_DOMAIN_NAME`. 262 263 The above example would be equivalent to an RC file looking like this : 264 265 ``` shell 266 export OS_AUTH_URL="https://identity.myprovider/v3" 267 export OS_USERNAME="myuser" 268 export OS_PASSWORD="password" 269 export OS_USER_DOMAIN_NAME="mydomain" 270 export OS_PROJECT_DOMAIN_NAME="mydomain" 271 ``` 272 273 ## Notes on OpenStack Authorization 274 275 The simplest way to get all settings for authorization agains OpenStack is to 276 go into the OpenStack Dashboard (Horizon) select your *Project* and navigate 277 *Project, Access & Security*, select *API Access* and *Download OpenStack RC 278 File v3*. Source the file, and select your wanted region by setting 279 environment variable `OS_REGION_NAME` or `OS_REGION_ID` and `export OS_TENANT_NAME=$OS_PROJECT_NAME` or `export OS_TENANT_ID=$OS_PROJECT_ID`. 280 281 ~> `OS_TENANT_NAME` or `OS_TENANT_ID` must be used even with Identity v3, 282 `OS_PROJECT_NAME` and `OS_PROJECT_ID` has no effect in Packer. 283 284 To troubleshoot authorization issues test you environment variables with the 285 OpenStack cli. It can be installed with 286 287 $ pip install --user python-openstackclient