Packer installation: Difference between revisions
(Created page with "== Basic understanding == Alpine Linux installer is just a bunch of shell scripts, see [https://git.alpinelinux.org/alpine-conf/tree/setup-alpine.in setup-alpine.in] in [http...") |
No edit summary |
||
Line 30: | Line 30: | ||
* as 'setup-alpine' script asks to configure root password, it just does that | * 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' | * 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 == | == packer example provisioners == |
Revision as of 17:40, 21 April 2020
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://Template:.HTTPIP:Template:.HTTPPort/answers<enter><wait>", "setup-alpine -f answers<enter><wait5>", "Template:User `ssh password`<enter><wait>", "Template:User `ssh password`<enter><wait5>", "<wait>y<enter><wait10>", "rc-service sshd stop<enter>", "mount /dev/vg0/lv_root /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:Template dir/../scripts/00_alpinelinux_base.sh", "Template:Template dir/../scripts/99_alpinelinux_base.sh" ] } ],