Packer installation: Difference between revisions
No edit summary |
m (change /dev/vg0/lv_root to /dev/sda3) |
||
| Line 16: | Line 16: | ||
"<wait>y<enter><wait10>", | "<wait>y<enter><wait10>", | ||
"rc-service sshd stop<enter>", | "rc-service sshd stop<enter>", | ||
"mount /dev/ | "mount /dev/sda3 /mnt<enter>", | ||
"echo 'PermitRootLogin yes' >> /mnt/etc/ssh/sshd_config<enter>", | "echo 'PermitRootLogin yes' >> /mnt/etc/ssh/sshd_config<enter>", | ||
"umount /mnt<enter>", | "umount /mnt<enter>", | ||
Latest revision as of 17:15, 17 March 2021
Basic understanding
Alpine Linux installer is just a bunch of shell scripts, see setup-alpine.in in alpine-conf repository. Understanding this is key to success.
packer example boot_command
This is a part of 'boot_command' from QEMU builder:
"boot_command": [
"root<enter><wait>",
"ifconfig eth0 up && udhcpc -i eth0<enter><wait5>",
"wget http://{{ .HTTPIP }}:{{ .HTTPPort }}/answers<enter><wait>",
"setup-alpine -f answers<enter><wait5>",
"{{user `ssh_password`}}<enter><wait>",
"{{user `ssh_password`}}<enter><wait5>",
"<wait>y<enter><wait10>",
"rc-service sshd stop<enter>",
"mount /dev/sda3 /mnt<enter>",
"echo 'PermitRootLogin yes' >> /mnt/etc/ssh/sshd_config<enter>",
"umount /mnt<enter>",
"reboot<enter>"
],
What it does is to mimic a human typing in "console" (VNC). Before running Alpine Linux installer (ie. 'setup-alpine') it does:
- logins in as 'root' (installation media doesn't require password)
- configures first network interfaces via DHCP
- gets 'answers' file from 'packer' built-in HTTP server to be able to start automated installation
- runs Alpine Linux 'setup-alpine' installer script with 'answers' file
- as 'setup-alpine' script asks to configure root password, it just does that
- after that, you can run whatever commands you want, but keep in mind that it is still installer media; you can 'reboot' into installed system and run 'provisioners'
The 'answer' file can be something like this:
KEYMAPOPTS="us us" HOSTNAMEOPTS="-n alpine" INTERFACESOPTS="auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp " DNSOPTS="-n 8.8.8.8" TIMEZONEOPTS="-z UTC" PROXYOPTS="none" APKREPOSOPTS="-1" SSHDOPTS="-c openssh" NTPOPTS="-c openntpd" DISKOPTS="-L -m sys /dev/vda"
packer example provisioners
"provisioners": [
{
"type": "shell",
"scripts": [
"{{ template_dir }}/../scripts/00_alpinelinux_base.sh",
"{{ template_dir }}/../scripts/99_alpinelinux_base.sh"
]
}
],