Skip to content

Commit

Permalink
Add DigitalOcean import step to debian-10.6-amd64.json
Browse files Browse the repository at this point in the history
  • Loading branch information
harrishancock committed Oct 24, 2020
1 parent 45bb130 commit 705bbfd
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 5 deletions.
56 changes: 53 additions & 3 deletions packer_templates/debian/debian-10.6-amd64.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@
],
"boot_wait": "10s",
"cpus": "{{ user `cpus` }}",
"disk_compression": true,
"disk_size": "{{user `disk_size`}}",
"format": "qcow2",
"headless": "{{ user `headless` }}",
"http_directory": "{{user `http_directory`}}",
"iso_checksum": "{{user `iso_checksum`}}",
Expand All @@ -163,7 +165,28 @@
{
"output": "{{ user `build_directory` }}/{{user `box_basename`}}.{{.Provider}}.box",
"type": "vagrant"
}
},
[
{
"type": "compress",
"output": "{{user `template`}}.qcow2.gz",
"compression_level": "9"
},
{
"type": "digitalocean-import",
"api_token": "{{user `do_api_token`}}",
"spaces_key": "{{user `do_spaces_key`}}",
"spaces_secret": "{{user `do_spaces_secret`}}",
"spaces_region": "ams3",
"space_name": "hlh",
"image_name": "{{user `template`}}",
"image_regions": "ams3",
"image_description": "Packer import {{timestamp}}",
"image_distribution": "Debian",
"image_tags": [],
"space_object_name": "{{user `template`}}-{{timestamp}}.qcow2.gz"
}
]
],
"provisioners": [
{
Expand All @@ -185,7 +208,31 @@
"{{template_dir}}/scripts/systemd.sh",
"{{template_dir}}/../_common/virtualbox.sh",
"{{template_dir}}/../ubuntu/scripts/vmware.sh",
"{{template_dir}}/../_common/parallels.sh",
"{{template_dir}}/../_common/parallels.sh"
],
"type": "shell"
},
{
"environment_vars": [
"HOME_DIR=/home/vagrant"
],
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E sh -eux '{{.Path}}'",
"expect_disconnect": true,
"scripts": [
"{{template_dir}}/scripts/cloud-init.sh"
],
"type": "shell"
},
{
"environment_vars": [
"HOME_DIR=/home/vagrant",
"http_proxy={{user `http_proxy`}}",
"https_proxy={{user `https_proxy`}}",
"no_proxy={{user `no_proxy`}}"
],
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E sh -eux '{{.Path}}'",
"expect_disconnect": true,
"scripts": [
"{{template_dir}}/scripts/cleanup.sh",
"{{template_dir}}/../_common/minimize.sh"
],
Expand All @@ -197,7 +244,10 @@
"build_directory": "../../builds",
"build_timestamp": "{{isotime \"20060102150405\"}}",
"cpus": "1",
"disk_size": "65536",
"disk_size": "4096",
"do_api_token": "{{env `DIGITALOCEAN_API_TOKEN`}}",
"do_spaces_key": "{{env `DIGITALOCEAN_SPACES_ACCESS_KEY`}}",
"do_spaces_secret": "{{env `DIGITALOCEAN_SPACES_SECRET_KEY`}}",
"git_revision": "__unknown_git_revision__",
"guest_additions_url": "",
"headless": "",
Expand Down
31 changes: 29 additions & 2 deletions packer_templates/debian/http/debian-9/preseed.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,43 @@ d-i mirror/http/directory string /debian
d-i mirror/http/hostname string httpredir.debian.org
d-i mirror/http/proxy string
d-i partman-auto-lvm/guided_size string max
d-i partman-auto/choose_recipe select atomic

# Use a custom partitioning/volume layout because the default atomic layout puts
# a swap volume after the root volume, which inhibits later filesystem resizing.
#
# TODO(now): Give arm64 a different expert recipe. It will need an EFI
# partition, and some boards may require FAT filesystems.
d-i partman-auto/expert_recipe string \
boot-atomic-lvm-root-noswap :: \
250 500 500 ext2 \
$primary{ } \
$bootable{ } \
method{ format } \
format{ } \
use_filesystem{ } \
filesystem{ ext2 } \
mountpoint{ /boot } \
$defaultignore{ } . \
2000 2000 -1 ext4 \
method{ format } \
format{ } \
use_filesystem{ } \
filesystem{ ext4 } \
lv_name{ root } \
mountpoint{ / } \
$defaultignore{ } \
$lvmok{ } .
d-i partman-auto/method string lvm
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-lvm/device_remove_lvm boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman/confirm_write_new_label boolean true
# Don't ask for confirmation for having no swap space.
d-i partman-basicfilesystems/no_swap boolean false

d-i passwd/root-login boolean false
d-i passwd/root-password-again password vagrant
d-i passwd/root-password password vagrant
Expand Down
25 changes: 25 additions & 0 deletions packer_templates/debian/scripts/cloud-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh -eux

apt-get -y install cloud-init
tee /etc/cloud/cloud.cfg.d/00_generic.cfg << EOF
datasource_list: [ DigitalOcean, None ]
datasource:
DigitalOcean:
retries: 3
timeout: 2
growpart:
mode: auto
devices:
- /dev/vda2
- /dev/vda5
ignore_growroot_disabled: false
# HACK: Buster's cloud-utils doesn't grow LVM volumes. Fixed in cloud-utils 0.31, but that version
# only resizes physical volumes, not logical volumes inside them. So, whatever, do it manually.
# From: https://github.com/mmickan/desployer/blob/master/seed-files/cloud-config
runcmd:
- [ cloud-init-per, once, grow_VG, pvresize, /dev/vda5 ]
- [ cloud-init-per, once, grow_LV, lvextend, -r, -l, "+100%FREE", /dev/debian-10-vg/root ]
EOF

cloud-init clean
fstrim -a

0 comments on commit 705bbfd

Please sign in to comment.