packer-cn/website/source/docs/builders/digitalocean.html.md

4.1 KiB

layout sidebar_current page_title description
docs docs-builders-digitalocean DigitalOcean - Builders 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.

DigitalOcean Builder

Type: digitalocean

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.

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 communicator can be configured for this builder.

Required:

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.

  • snapshot_name (string) - The name of the resulting snapshot that will appear in your account. This must be unique. To help make this unique, use a function like timestamp (see configuration templates for more info)

  • 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".

  • user_data (string) - User data to launch with the Droplet.

  • user_data_file (string) - Path to a file that will be used for the user data when launching the Droplet.

Basic Example

Here is a basic example. It is completely valid as soon as you enter your own access tokens:

{
  "type": "digitalocean",
  "api_token": "YOUR API KEY",
  "image": "ubuntu-14-04-x64",
  "region": "nyc3",
  "size": "512mb",
  "ssh_username": "root"
}