This is a HashiCorp Packer plugin for creating Vultr snapshots. It uses the public Vultr API.
- Download binaries from the releases page.
- Install the plugin, or simply put it into the same directory with JSON templates.
Install Go, then run:
$ go get github.com/ivandeex/packer-builder-vultr
See Ubuntu template in the examples folder.
You must have your Vultr API token obtained from the Vultr account pages.
{
"variables": {
"vultr_api_key": "{{ env `VULTR_API_KEY` }}"
},
"builders": [{
"type": "vultr",
"api_key": "{{ user `vultr_api_key` }}",
"description": "My Server",
"region_name": "Amsterdam",
"plan_name": "1024 MB RAM,25 GB SSD,1.00 TB BW",
"os_name": "Ubuntu 18.04 x64",
"ssh_username": "root",
"shutdown_command": "/sbin/shutdown -P now"
}],
"provisioners": [{
"type": "file",
"source": "message.txt",
"destination": "/root/message.txt"
}]
}
type
(string) — Alwaysvultr
for this builder, required.api_key
(string) — Your Vultr API token, required.description
(string) — A name of the resulting snapshot (required).state_timeout
(string) — The time to wait, as a duration string (like5m
,60s
or2h15m45s
), for an instance to power-on or for Vultr to create a final snapshot) before timing out. The default state timeout is "10m" (10 minutes).shutdown_command
(string) — The build will shutdown the instance after all template provisioning is complete but before commanding Vultr to take snapshot. This parameter allows to customize the shutdown command (defaults toshutdown -P now
).
ssh_port
(number) — This is only required if you start from a prebaked snapshot. Defaults to22
.ssh_username
(string) — Optional user name to login into instance after power-on, the default isroot
. If you start building from a standard OS image, then the only option isroot
(usually). You may need to customize user name if you start from a prebaked snapshot.ssh_password
(string) — Not required unless you start from a prebaked snapshot.ssh_private_key_file
(string) — Path to a PEM encoded private key file to use to authenticate with SSH. The~
can be used in path and will be expanded to the home directory of current user.ssh_timeout
(string) — maximum time to wait for SSH availability after Vultr has created the instance (optional string like5m
or60s
, see packer documentation
You can skip both password and private key file if you start from a standard OS image, then the builder will use a random root password provided by Vultr to login into new instance.
You can define ssh_password
and ssh_private_key_file
together. Then SSH communicator will try them in sequence.
Also, you can use other SSH connection parameters supported by packer.
region_name
(string) — The name of the region to launch the instance in, e.g.Frankfurt
orNew Jersey
. Consequently, this is the region where the snapshot will be available.region_code
(string) — You can use a short code instead of a full region name.region_id
(number) — You can use a numeric region ID instead of a full region name.
Only one of region_name
, region_code
or region_id
is required.
Run the following command to obtain all available regions with their names, short codes and numeric IDs:
$ curl https://api.vultr.com/v1/regions/list | jq
plan_name
(string) — The name of the base OS image to use. This is the image that will be used to launch a new instance and provision it.plan_id
(number) — You can use a numeric plan ID instead of a full plan name.ipv6
(boolean, optional) — Set totrue
to enable ipv6 for the instance being created. This defaults tofalse
, or not enabled.private_networking
(boolean, optional) — Set totrue
to enable private networking for the instance being created. This defaults tofalse
, or not enabled.
Either plan_name
or plan_id
is required.
Run the following command to obtain all available plans with their names and numeric IDs:
$ curl "https://api.vultr.com/v1/plans/list?type=vc2" | jq
You can use either standard OS image from the Vultr library or a pre-saved instance snapshot.
os_name
(string) — The name of the base OS image to use. This is the image that will be used to launch a new instance and provision it.os_id
(number) — You can use a numeric OS image ID instead of a full plan name. Eitheros_name
oros_id
is required.
Run the following command to obtain all available OSes with their names and numeric IDs:
$ curl https://api.vultr.com/v1/os/list | jq
snapshot_name
(string) — The name of a pre-saved instance snapshot. See the list of snapshots on your Vultr dashboard. The builder will fail if there are multiple snapshots with the same name.snapshot_id
(string) — You can use internal snapshot ID instead of the full name, if you know it. Eithersnapshot_name
orsnapshot_id
is required.
startup_script_name
(string) — The name of a startup script to run on the instance before running your template provisioners. Startup scripts can be a powerful tool for configuring the instance from which the image is made. The script must be manually configured in your Vultr dashboard before use. The builder will fail if there are multiple startup scripts with the same name.startup_script_id
(number) — You can use a numeric startup script ID instead of the full name.sshkey_name
(string) — Name of the SSH key to add to the instance on launch. The key must be manually configured in your Vultr dashboard before use. The builder will fail if there are multiple SSH keys with the same name. Thesshkey
parameter name deliberately lacks underscore to make it different from connection related parameters.sshkey_id
(string) — You can use a short SSH key ID instead of the full name.