2020-03-18 18:46:47 -04:00
|
|
|
---
|
|
|
|
description: >
|
|
|
|
The digitalocean Packer builder is able to create new images for use with
|
|
|
|
|
|
|
|
DigitalOcean. The builder takes a source image, runs any provisioning
|
|
|
|
necessary
|
|
|
|
|
|
|
|
on the image after launching it, then snapshots it into a reusable image. This
|
|
|
|
|
|
|
|
reusable image can then be used as the foundation of new servers that are
|
|
|
|
|
|
|
|
launched within DigitalOcean.
|
|
|
|
layout: docs
|
|
|
|
page_title: DigitalOcean - Builders
|
2020-03-24 19:48:37 -04:00
|
|
|
sidebar_title: 'DigitalOcean'
|
2020-03-18 18:46:47 -04:00
|
|
|
sidebar_current: docs-builders-digitalocean
|
|
|
|
---
|
|
|
|
|
|
|
|
# DigitalOcean Builder
|
|
|
|
|
|
|
|
Type: `digitalocean`
|
|
|
|
|
|
|
|
The `digitalocean` Packer builder is able to create new images for use with
|
|
|
|
[DigitalOcean](https://www.digitalocean.com). The builder takes a source image,
|
|
|
|
runs any provisioning necessary on the image after launching it, then snapshots
|
|
|
|
it into a reusable image. This reusable image can then be used as the
|
|
|
|
foundation of new servers that are launched within DigitalOcean.
|
|
|
|
|
|
|
|
The builder does _not_ manage images. Once it creates an image, it is up to you
|
|
|
|
to use it or delete it.
|
|
|
|
|
|
|
|
## Configuration Reference
|
|
|
|
|
|
|
|
There are many configuration options available for the builder. They are
|
|
|
|
segmented below into two categories: required and optional parameters. Within
|
|
|
|
each category, the available configuration keys are alphabetized.
|
|
|
|
|
|
|
|
In addition to the options listed here, a
|
2020-03-31 17:40:07 -04:00
|
|
|
[communicator](/docs/templates/communicator) can be configured for this
|
2020-03-18 18:46:47 -04:00
|
|
|
builder.
|
|
|
|
|
|
|
|
### Required:
|
|
|
|
|
|
|
|
- `api_token` (string) - The client TOKEN to use to access your account. It
|
|
|
|
can also be specified via environment variable `DIGITALOCEAN_API_TOKEN`, if
|
|
|
|
set.
|
|
|
|
|
|
|
|
- `image` (string) - The name (or slug) of the base image to use. This is the
|
|
|
|
image that will be used to launch a new droplet and provision it. See
|
2020-03-24 20:10:25 -04:00
|
|
|
[here](https://developers.digitalocean.com/documentation/v2/#list-all-images)
|
2020-03-18 18:46:47 -04:00
|
|
|
for details on how to get a list of the accepted image names/slugs.
|
|
|
|
|
|
|
|
- `region` (string) - The name (or slug) of the region to launch the droplet
|
|
|
|
in. Consequently, this is the region where the snapshot will be available.
|
2020-03-24 20:10:25 -04:00
|
|
|
See [here](https://developers.digitalocean.com/documentation/v2/#list-all-regions)
|
2020-03-18 18:46:47 -04:00
|
|
|
for the accepted region names/slugs.
|
|
|
|
|
|
|
|
- `size` (string) - The name (or slug) of the droplet size to use. See
|
2020-03-24 20:10:25 -04:00
|
|
|
[here](https://developers.digitalocean.com/documentation/v2/#list-all-sizes)
|
2020-03-18 18:46:47 -04:00
|
|
|
for the accepted size names/slugs.
|
|
|
|
|
|
|
|
### Optional:
|
|
|
|
|
|
|
|
- `api_url` (string) - Non standard api endpoint URL. Set this if you are
|
|
|
|
using a DigitalOcean API compatible service. It can also be specified via
|
|
|
|
environment variable `DIGITALOCEAN_API_URL`.
|
|
|
|
|
|
|
|
- `droplet_name` (string) - The name assigned to the droplet. DigitalOcean
|
|
|
|
sets the hostname of the machine to this value.
|
|
|
|
|
|
|
|
- `private_networking` (boolean) - Set to `true` to enable private networking
|
|
|
|
for the droplet being created. This defaults to `false`, or not enabled.
|
|
|
|
|
|
|
|
- `monitoring` (boolean) - Set to `true` to enable monitoring for the droplet
|
|
|
|
being created. This defaults to `false`, or not enabled.
|
|
|
|
|
|
|
|
- `ipv6` (boolean) - Set to `true` to enable ipv6 for the droplet being
|
|
|
|
created. This defaults to `false`, or not enabled.
|
|
|
|
|
|
|
|
- `snapshot_name` (string) - The name of the resulting snapshot that will
|
2020-03-23 20:02:12 -04:00
|
|
|
appear in your account. Defaults to `packer-{{timestamp}}` (see
|
2020-03-31 17:40:07 -04:00
|
|
|
[configuration templates](/docs/templates/engine) for more info).
|
2020-03-18 18:46:47 -04:00
|
|
|
|
|
|
|
- `snapshot_regions` (array of strings) - The regions of the resulting
|
|
|
|
snapshot that will appear in your account.
|
|
|
|
|
|
|
|
- `state_timeout` (string) - The time to wait, as a duration string, for a
|
|
|
|
droplet to enter a desired state (such as "active") before timing out. The
|
|
|
|
default state timeout is "6m".
|
|
|
|
|
|
|
|
- `snapshot_timeout` (string) - The time to wait, as a duration string, for a
|
|
|
|
snapshot action to complete (e.g snapshot creation) before timing out. The
|
|
|
|
default snapshot timeout is "60m".
|
|
|
|
|
|
|
|
- `user_data` (string) - User data to launch with the Droplet. Packer will
|
|
|
|
not automatically wait for a user script to finish before shutting down the
|
|
|
|
instance this must be handled in a provisioner.
|
|
|
|
|
|
|
|
- `user_data_file` (string) - Path to a file that will be used for the user
|
|
|
|
data when launching the Droplet.
|
|
|
|
|
|
|
|
- `tags` (list) - Tags to apply to the droplet when it is created
|
|
|
|
|
|
|
|
## Basic Example
|
|
|
|
|
|
|
|
Here is a basic example. It is completely valid as soon as you enter your own
|
|
|
|
access tokens:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"type": "digitalocean",
|
|
|
|
"api_token": "YOUR API KEY",
|
|
|
|
"image": "ubuntu-16-04-x64",
|
|
|
|
"region": "nyc3",
|
|
|
|
"size": "512mb",
|
|
|
|
"ssh_username": "root"
|
|
|
|
}
|
|
|
|
```
|