Skip to content

perryflynn/iac

Repository files navigation

iac

Infrastructure as Code.

This project installs and configures Arch Linux, Debian or Ubuntu operating systems fully automated.

⚠ Make sure to create a .env file and reference to the correct code branch with the env vars in it!

Features:

  • 💿 Build the installer ISO image in a Docker environment
  • 💡 Read hostname and OS type from UEFI variables or use cloud-init
  • 🔨 Install a minimal Arch Linux OS, Debian OS or Ubuntu OS
  • ❓ Decide target disk for installation, etc by hostname
  • 🔐 Setup root password, SSH keys and user accounts
  • 🚀 Autostart OS configuration at first boot
  • 💻 Autostart Desktop configuration at first Desktop logon
  • ⏱ From blank disk to booted system in ~10 Minutes

Workflow base installation & hostname based configuration:

graph LR
    build["Build<br>ISO"] --> boot["Boot<br>ISO"]
    boot --> bootstrap["Run<br>bootstrap"]
    bootstrap --> reboot1["Reboot into<br>new OS"]
    autorun1["Autorun host<br>playbook on<br>first boot<br>(Install OS components)"]
    autorun1 --> reboot2["Reboot"]
    reboot2 --> xfce["Boot into<br>XFCE4"]
    xfce --> autorun2["Run host<br>playbook on<br>first XFCE Login<br>(Configure XFCE4)"]
    autorun2 --> logout["Logout<br>to load<br>XFCE settings"]
    logout --> done["Done!"]
Loading

Architecture

All packages are installed from the official sources.

  • bash
  • systemd
  • systemd-networkd (DHCP on all ens* interfaces)
  • systemd-timesyncd
  • systemd-resolved
  • net-tools + dnsutils
  • nano + vim
  • curl + wget
  • Ansible
OS #Packages #Processes Size Memory
Ubuntu 24.04 "Noble" ~390 14 2.5GB 280MB
Debian 12 "Bookworm" ~390 14 2.2GB 270MB
Arch Linux ~170 20 2.7GB 300MB

archiso

Archiso is used as a base for the Installer ISO. archiso/ contains a Dockerfile and some scripts to build a custom Arch Linux installer ISO with additional scripts.

  • ./archiso/build.sh builds the container image
  • ./archiso/pack.sh runs the container image to build the Arch Linux ISO image
  • ISO Image can be found in ./archiso/output/

Requires Docker CE, pack.sh executes a container in privileged mode.

Automatic configuration with Cloud-Init

TODO

Automatic hostname detection with UEFI varables

The perrys-bootstrapper.sh script is using UEFI variables to fetch the hostname from the system and use the correct ansible inventory variables.

Set hostname in UEFI variable:

echo -n myhostname > efi-hostname
efivar --name ed38a5bf-1135-4b0f-aa72-49d30b05dfd4-PerryHostname -w -f efi-hostname

Get the hostname from UEFI variable:

cat /sys/firmware/efi/efivars/PerryHostname-ed38a5bf-1135-4b0f-aa72-49d30b05dfd4

In addition the variable PerryFlavor-ed38a5bf-1135-4b0f-aa72-49d30b05dfd4 can be used to set the flavor (debian or archlinux).

How to install a OS

  • Build the Arch Linux ISO image
  • Boot ISO in a virtual machine or on a physical system
  • Ensure that the diskdev and bootmode are correct in the inventoy
  • Run installer
    • Debian: perrys-bootstrapper.sh --flavor debian
    • Arch Linux: perrys-bootstrapper.sh --flavor archlinux
  • Reboot into the new OS

Configure Arch Linux OS

Run perrys-ansible-apply.sh as root.

It pulls automatically the correct playbook from this repo by the hostname of the operating system.

TODO

  • Bluetooth
  • NetworkManager
  • NFTables
  • Pulseaudio
  • Swap File
  • Unix Account
  • X11
  • XFCE
  • Self-Signed certificate for localhost
  • NGINX with tilde user dirs
  • SSH Daemon config
  • Disk Encryption

About

Infrastructure as Code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published