From c61dc1bd539f1cd590a1c0893eff81f6017acca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Molinero=20Fern=C3=A1ndez?= Date: Sat, 15 Aug 2020 17:55:40 +0200 Subject: [PATCH] Added Packer configuration for DigitalOcean --- packer/digitalocean/seed/user-data | 7 +++++++ packer/sources.pkr.hcl | 20 ++++++++++++++++++++ packer/variables.pkr.hcl | 6 ++++++ 3 files changed, 33 insertions(+) create mode 100644 packer/digitalocean/seed/user-data diff --git a/packer/digitalocean/seed/user-data b/packer/digitalocean/seed/user-data new file mode 100644 index 0000000..88f8a36 --- /dev/null +++ b/packer/digitalocean/seed/user-data @@ -0,0 +1,7 @@ +#cloud-config + +ssh_pwauth: false +disable_root: false + +runcmd: + - sed -i '/ssh_pwauth/d' /etc/cloud/cloud.cfg.d/*-digitalocean.cfg diff --git a/packer/sources.pkr.hcl b/packer/sources.pkr.hcl index 658aa25..261333f 100644 --- a/packer/sources.pkr.hcl +++ b/packer/sources.pkr.hcl @@ -18,6 +18,26 @@ source "hcloud" "main" { ssh_timeout = "10m" } +source "digitalocean" "main" { + api_token = var.digitalocean_api_token + + image = "ubuntu-20-04-x64" + droplet_name = "wireguard-{{timestamp}}" + size = "s-1vcpu-1gb" + region = "fra1" + + snapshot_name = "wireguard-{{timestamp}}" + tags = [ + "wireguard" + ] + + user_data_file = "./digitalocean/seed/user-data" + + ssh_port = "22" + ssh_username = "root" + ssh_timeout = "10m" +} + source "qemu" "main" { iso_url = "https://cloud-images.ubuntu.com/daily/server/focal/current/focal-server-cloudimg-amd64.img" iso_checksum = "file:https://cloud-images.ubuntu.com/daily/server/focal/current/SHA256SUMS" diff --git a/packer/variables.pkr.hcl b/packer/variables.pkr.hcl index f277595..f9c69e3 100644 --- a/packer/variables.pkr.hcl +++ b/packer/variables.pkr.hcl @@ -3,3 +3,9 @@ variable "hcloud_api_token" { description = "Hetzner Cloud API token" default = "" } + +variable "digitalocean_api_token" { + type = string + description = "DigitalOcean API token" + default = "" +}