Skip to content

Commit dd6cd79

Browse files
committed
packer: Add digitalocean image
1 parent 92ac26b commit dd6cd79

File tree

7 files changed

+190
-128
lines changed

7 files changed

+190
-128
lines changed

packer/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output_*
2+
packer_cache
3+
crash.log
4+
*.box

packer/http/autoinstall.cfg

Lines changed: 0 additions & 82 deletions
This file was deleted.

packer/http/cloud.cfg

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
# Void Linux Automatic Install Configuration
3+
4+
export username="void"
5+
export password="void"
6+
7+
export end_action=func
8+
end_function() {
9+
printf "Linking default services"
10+
chroot "$target" ln -s /etc/sv/dhcpcd /etc/runit/runsvdir/default/dhcpcd
11+
chroot "$target" ln -s /etc/sv/sshd /etc/runit/runsvdir/default/sshd
12+
13+
sync
14+
reboot -f
15+
}
16+
17+
18+
VAI_partition_disk() {
19+
# Paritition Disk
20+
sfdisk "${disk}" <<EOF
21+
;
22+
EOF
23+
}
24+
25+
VAI_format_disk() {
26+
# Make Filesystems
27+
mkfs.ext4 -F "${disk}1"
28+
}
29+
30+
VAI_mount_target() {
31+
# Mount targetfs
32+
mkdir -p "${target}"
33+
mount "${disk}1" "${target}"
34+
}
35+
36+
VAI_configure_fstab() {
37+
uuid1="$(blkid -s UUID -o value "${disk}1")"
38+
echo "UUID=$uuid1 / ext4 defaults,errors=remount-ro 0 1" >> "${target}/etc/fstab"
39+
}

packer/http/vagrant.cfg

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
# Void Linux Automatic Install Configuration
3+
4+
export username="vagrant"
5+
export password="vagrant"
6+
7+
export end_action=func
8+
end_function() {
9+
printf "Linking default services"
10+
chroot "$target" ln -s /etc/sv/dhcpcd /etc/runit/runsvdir/default/dhcpcd
11+
chroot "$target" ln -s /etc/sv/sshd /etc/runit/runsvdir/default/sshd
12+
13+
xbps-install -r "$target" -Sy dbus virtualbox-ose-guest
14+
15+
chroot "$target" ln -s /etc/sv/dbus /etc/runit/runsvdir/default/dbus
16+
chroot "$target" ln -s /etc/sv/vboxservice /etc/runit/runsvdir/default/vboxservice
17+
18+
sync
19+
reboot -f
20+
}

packer/scripts/cloud.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
echo "void ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/99-void
4+
echo "Defaults:void !requiretty" >> /etc/sudoers.d/99-void
5+
chmod 0440 /etc/sudoers.d/99-void
6+
mv /etc/sudoers.d/{,10-}wheel
7+
8+
xbps-fetch -o /usr/bin/growpart https://raw.githubusercontent.com/canonical/cloud-utils/ubuntu/0.31-22-g37d4e32a-0ubuntu1/bin/growpart
9+
chmod +x /usr/bin/growpart
10+
11+
xbps-install -y util-linux coreutils sed shinit
12+
ln -s /etc/sv/shinit /var/service/
13+
14+
cat <<'EOF' > /etc/runit/core-services/10-resize-root.sh
15+
#!/bin/sh
16+
rpart=$(findmnt -r -o SOURCE -v -n /)
17+
rnum=$(cat /sys/class/block/$(basename $rpart)/partition)
18+
19+
/usr/bin/growpart ${rpart%%$rnum} $rnum
20+
resize2fs $rpart
21+
EOF
22+
23+
passwd -dl void
24+
passwd -dl root
25+
26+
rm -rf /var/cache/xbps
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"builders": [
3+
{
4+
"accelerator": "kvm",
5+
"boot_command": [
6+
"<tab><wait>",
7+
"auto autourl=http://{{ .HTTPIP }}:{{ .HTTPPort }}/cloud.cfg",
8+
"<enter>"
9+
],
10+
"boot_wait": "5s",
11+
"disk_interface": "virtio",
12+
"disk_size": "1000M",
13+
"format": "qcow2",
14+
"http_directory": "http",
15+
"iso_checksum": "sha256:d95d40e1eb13a7776b5319a05660792fddd762662eaecee5df6b8feb3aa9b391",
16+
"iso_url": "https://alpha.de.repo.voidlinux.org/live/20200722/void-live-x86_64-5.7.10_1-20200722.iso",
17+
"output_directory": "output_void_qcow2",
18+
"shutdown_command": "echo 'void' | sudo -S shutdown -P now",
19+
"ssh_password": "void",
20+
"ssh_timeout": "20m",
21+
"ssh_username": "void",
22+
"type": "qemu",
23+
"vm_name": "DO-glibc64"
24+
}
25+
],
26+
"post-processors": [
27+
{
28+
"image_description": "Packer import {{timestamp}}",
29+
"image_name": "void-linux-{{user `release`}}",
30+
"image_regions": "{{user `image_regions`}}",
31+
"image_tags": [
32+
"custom",
33+
"packer"
34+
],
35+
"space_name": "{{user `spaces_bucket`}}",
36+
"spaces_region": "{{user `spaces_region`}}",
37+
"type": "digitalocean-import"
38+
}
39+
],
40+
"provisioners": [
41+
{
42+
"execute_command": "echo 'void' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
43+
"script": "scripts/cloud.sh",
44+
"type": "shell"
45+
}
46+
],
47+
"variables": {
48+
"image_regions": "{{env `IMAGE_REGIONS`}}",
49+
"spaces_bucket": "{{env `SPACES_BUCKET`}}",
50+
"spaces_region": "{{env `SPACES_REGION`}}",
51+
"release": "{{env `RELEASE`}}"
52+
}
53+
}
Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,53 @@
11
{
2-
"variables": {
3-
"version": "{{env `RELEASE`}}"
4-
},
5-
"builders": [
6-
{
7-
"type": "virtualbox-iso",
8-
"vboxmanage": [
9-
["modifyvm", "{{.Name}}", "--nictype1", "virtio"]
10-
],
11-
"iso_url": "https://alpha.de.repo.voidlinux.org/live/20190217/void-live-x86_64-20190217.iso",
12-
"iso_checksum": "b6884f6ea435e242c29a5778ced7a1ce187cef2f07eb9543765064a1256030e9",
13-
"iso_checksum_type": "sha256",
14-
"boot_wait": "5s",
15-
"boot_command": [
16-
"<tab><wait>",
17-
"auto autourl=http://{{ .HTTPIP }}:{{ .HTTPPort }}/autoinstall.cfg",
18-
"<enter>"
19-
],
20-
"guest_os_type": "Linux_64",
21-
"http_directory": "http",
22-
"shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now",
23-
"ssh_wait_timeout": "20m",
24-
"virtualbox_version_file": ".vbox_version",
25-
"guest_additions_mode": "disable",
26-
"ssh_username": "vagrant",
27-
"ssh_password": "vagrant"
28-
}
29-
],
30-
31-
"provisioners": [
32-
{
33-
"type": "shell",
34-
"script": "scripts/vagrant.sh",
35-
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -E -S bash '{{.Path}}'"
36-
}
37-
],
38-
39-
"post-processors": [
2+
"builders": [
3+
{
4+
"boot_command": [
5+
"<tab><wait>",
6+
"auto autourl=http://{{ .HTTPIP }}:{{ .HTTPPort }}/vagrant.cfg",
7+
"<enter>"
8+
],
9+
"boot_wait": "5s",
10+
"guest_additions_mode": "disable",
11+
"guest_os_type": "Linux_64",
12+
"http_directory": "http",
13+
"iso_checksum": "sha256:d95d40e1eb13a7776b5319a05660792fddd762662eaecee5df6b8feb3aa9b391",
14+
"iso_url": "https://alpha.de.repo.voidlinux.org/live/20200722/void-live-x86_64-5.7.10_1-20200722.iso",
15+
"shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now",
16+
"ssh_password": "vagrant",
17+
"ssh_timeout": "20m",
18+
"ssh_username": "vagrant",
19+
"type": "virtualbox-iso",
20+
"vboxmanage": [
4021
[
41-
{
42-
"type": "vagrant"
43-
},
44-
{
45-
"type": "vagrant-cloud",
46-
"box_tag": "voidlinux/glibc64",
47-
"version": "{{user `version`}}"
48-
}
22+
"modifyvm",
23+
"{{.Name}}",
24+
"--nictype1",
25+
"virtio"
4926
]
27+
],
28+
"virtualbox_version_file": ".vbox_version"
29+
}
30+
],
31+
"post-processors": [
32+
[
33+
{
34+
"type": "vagrant"
35+
},
36+
{
37+
"box_tag": "voidlinux/glibc64",
38+
"type": "vagrant-cloud",
39+
"version": "{{user `version`}}"
40+
}
5041
]
42+
],
43+
"provisioners": [
44+
{
45+
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
46+
"script": "scripts/vagrant.sh",
47+
"type": "shell"
48+
}
49+
],
50+
"variables": {
51+
"version": "{{env `RELEASE`}}"
52+
}
5153
}

0 commit comments

Comments
 (0)