Community

»Vultr

Type: vultr

The vultr Packer builder is able to create new images for use with Vultr. 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 be then used as the foundation of new servers that are launched within Vultr.

The builder does not manage images. Once it creates an image, it is up to you to use it or delete it.

NOTE: Packer-Builder-Vultr v2+ uses API V2

»Required:

NOTE: that os_id, app_id, snapshot_id, or iso_id are not required and are optional. You must supply at least one for instance creation.

»Optional

  • os_id (int) - The id of the os to use. This will be the OS that will be used to launch a new instance and provision it. See List Operating Systems.

  • snapshot_description (string) - Description of the snapshot.

  • snapshot_id (string) - If you've selected the 'snapshot' operating system, this should be the ID of the snapshot. See Snapshot.

  • iso_id (string) - If you've selected the 'custom' operating system, this is the ID of a specific ISO to mount during the deployment. See ISO.

  • app_id (int) - If launching an application, this is the ID to launch. See App.

  • image_id (string) If launching a marketplace application. See App. Note marketplace applications are denoted by type: marketplace and you must use the image_id not the id.

  • enable_ipv6 (bool) - IPv6 subnet will be assigned to the machine. Defaults to false

  • enable_private_network (bool) - Enables private networking support to the new server. Defaults to false

  • script_id (string) - If you've not selected a 'custom' (OS 159) operating system, this can be the id of a startup script to execute on boot. See Startup Script.

  • ssh_key_ids (array of string) - List of SSH keys to apply to this server on install. Separate keys with commas. See SSH Key.

  • instance_label (string) - This is a text label that will be shown in the control panel.

  • userdata (string) - Base64 encoded user-data.

  • hostname (string) - Hostname to assign to this server.

  • tag (string) - The tag to assign to this server.

  • state_timeout (string) - A duration to wait for the instance to boot, or a snapshot to be taken. Must be a string in golang Duration-parsable format, like "10m" or "30s". Defaults to 10m

You may also adjust the SSH communicator settings to configure how Packer will log into Vultr Instances.

»Example Usage

variable "vultr_api_key" {
  type    = string
  default = "${env("VULTR_API_KEY")}"
}

source "vultr" "ubuntu-20" {
  api_key              = "${var.vultr_api_key}"
  os_id                = "413"
  plan_id              = "vhf-1c-1gb"
  region_id            = "atl"
  snapshot_description = "testing"
  state_timeout        = "10m"
  ssh_username         = "root"
}

build {
  sources = ["source.vultr.ubuntu-20"]
}
variable "vultr_api_key" {  type    = string  default = "${env("VULTR_API_KEY")}"}
source "vultr" "ubuntu-20" {  api_key              = "${var.vultr_api_key}"  os_id                = "413"  plan_id              = "vhf-1c-1gb"  region_id            = "atl"  snapshot_description = "testing"  state_timeout        = "10m"  ssh_username         = "root"}
build {  sources = ["source.vultr.ubuntu-20"]}