Difference between revisions of "Packer installation"

From Alpine Linux
Jump to: navigation, search
Line 60: Line 60:

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": [
  "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>",
  "rc-service sshd stop<enter>",
  "mount /dev/vg0/lv_root /mnt<enter>",
  "echo 'PermitRootLogin yes' >> /mnt/etc/ssh/sshd_config<enter>",
  "umount /mnt<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:

HOSTNAMEOPTS="-n alpine"
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
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"