builder/openstack: support legacy env vars

This commit is contained in:
Mitchell Hashimoto 2015-06-12 00:33:52 -04:00
parent 50e2eb30e6
commit e724b5fe80
2 changed files with 30 additions and 44 deletions

View File

@ -41,6 +41,23 @@ func (c *AccessConfig) Prepare(ctx *interpolate.Context) []error {
c.Region = os.Getenv("OS_REGION_NAME") c.Region = os.Getenv("OS_REGION_NAME")
} }
// Legacy RackSpace stuff. We're keeping this around to keep things BC.
if c.APIKey == "" {
c.APIKey = os.Getenv("SDK_API_KEY")
}
if c.Password == "" {
c.Password = os.Getenv("SDK_PASSWORD")
}
if c.Region == "" {
c.Region = os.Getenv("SDK_REGION")
}
if c.TenantName == "" {
c.TenantName = os.Getenv("SDK_PROJECT")
}
if c.Username == "" {
c.Username = os.Getenv("SDK_USERNAME")
}
// Get as much as possible from the end // Get as much as possible from the end
ao, _ := openstack.AuthOptionsFromEnv() ao, _ := openstack.AuthOptionsFromEnv()

View File

@ -34,23 +34,21 @@ each category, the available configuration keys are alphabetized.
* `image_name` (string) - The name of the resulting image. * `image_name` (string) - The name of the resulting image.
* `password` (string) - The password used to connect to the OpenStack service.
If not specified, Packer will use the environment variables
`SDK_PASSWORD` or `OS_PASSWORD` (in that order), if set.
* `source_image` (string) - The ID or full URL to the base image to use. * `source_image` (string) - The ID or full URL to the base image to use.
This is the image that will be used to launch a new server and provision it. This is the image that will be used to launch a new server and provision it.
* `username` (string) - The username used to connect to the OpenStack service. * `username` (string) - The username used to connect to the OpenStack service.
If not specified, Packer will use the environment variable
`OS_USERNAME`, if set.
* `password` (string) - The password used to connect to the OpenStack service.
If not specified, Packer will use the environment variables If not specified, Packer will use the environment variables
`SDK_USERNAME` or `OS_USERNAME` (in that order), if set. `OS_PASSWORD`, if set.
### Optional: ### Optional:
* `api_key` (string) - The API key used to access OpenStack. Some OpenStack * `api_key` (string) - The API key used to access OpenStack. Some OpenStack
installations require this. installations require this.
If not specified, Packer will use the environment variables
`SDK_API_KEY`, if set.
* `floating_ip` (string) - A specific floating IP to assign to this instance. * `floating_ip` (string) - A specific floating IP to assign to this instance.
`use_floating_ip` must also be set to true for this to have an affect. `use_floating_ip` must also be set to true for this to have an affect.
@ -65,32 +63,18 @@ each category, the available configuration keys are alphabetized.
* `networks` (array of strings) - A list of networks by UUID to attach * `networks` (array of strings) - A list of networks by UUID to attach
to this instance. to this instance.
* `openstack_provider` (string) - A name of a provider that has a slightly * `tenant_id` or `tenant_name` (string) - The tenant ID or name to boot the
different API model. Currently supported values are "openstack" (default), instance into. Some OpenStack installations require this.
and "rackspace". If not specified, Packer will use the environment variable
`OS_TENANT_NAME`, if set.
* `project` (string) - The project name to boot the instance into. Some
OpenStack installations require this.
If not specified, Packer will use the environment variables
`SDK_PROJECT` or `OS_TENANT_NAME` (in that order), if set.
* `provider` (string) - The provider used to connect to the OpenStack service.
If not specified, Packer will use the environment variables `SDK_PROVIDER`
or `OS_AUTH_URL` (in that order), if set.
For Rackspace this should be `rackspace-us` or `rackspace-uk`.
* `proxy_url` (string)
* `security_groups` (array of strings) - A list of security groups by name * `security_groups` (array of strings) - A list of security groups by name
to add to this instance. to add to this instance.
* `region` (string) - The name of the region, such as "DFW", in which * `region` (string) - The name of the region, such as "DFW", in which
to launch the server to create the AMI. to launch the server to create the AMI.
If not specified, Packer will use the environment variables If not specified, Packer will use the environment variable
`SDK_REGION` or `OS_REGION_NAME` (in that order), if set. `OS_REGION_NAME`, if set.
For a `provider` of "rackspace", it is required to specify a region,
either using this option or with an environment variable. For other
providers, including a private cloud, specifying a region is optional.
* `ssh_port` (integer) - The port that SSH will be available on. Defaults to port * `ssh_port` (integer) - The port that SSH will be available on. Defaults to port
22. 22.
@ -106,9 +90,6 @@ each category, the available configuration keys are alphabetized.
useful for Rackspace are "public" or "private", and the default behavior is useful for Rackspace are "public" or "private", and the default behavior is
to connect via whichever is returned first from the OpenStack API. to connect via whichever is returned first from the OpenStack API.
* `tenant_id` (string) - Tenant ID for accessing OpenStack if your
installation requires this.
* `use_floating_ip` (boolean) - Whether or not to use a floating IP for * `use_floating_ip` (boolean) - Whether or not to use a floating IP for
the instance. Defaults to false. the instance. Defaults to false.
@ -124,10 +105,8 @@ Ubuntu 12.04 LTS (Precise Pangolin) on Rackspace OpenStack cloud offering.
```javascript ```javascript
{ {
"type": "openstack", "type": "openstack",
"username": "", "username": "foo",
"api_key": "", "password": "foo",
"openstack_provider": "rackspace",
"provider": "rackspace-us",
"region": "DFW", "region": "DFW",
"ssh_username": "root", "ssh_username": "root",
"image_name": "Test image", "image_name": "Test image",
@ -160,13 +139,3 @@ script is setting environment variables like:
* `OS_TENANT_ID` * `OS_TENANT_ID`
* `OS_USERNAME` * `OS_USERNAME`
* `OS_PASSWORD` * `OS_PASSWORD`
## Troubleshooting
*I get the error "Missing or incorrect provider"*
* Verify your "username", "password" and "provider" settings.
*I get the error "Missing endpoint, or insufficient privileges to access endpoint"*
* Verify your "region" setting.