diff --git a/.gitignore b/.gitignore index 5635d235..f47553b3 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,7 @@ Cargo.lock # .tgz Files are used for creating the image and are auto generated by the script azure-init.tgz + +# Don't check in local tweaks to the mkosi configuration +mkosi.local.conf +.mkosi/ diff --git a/mkosi.conf b/mkosi.conf new file mode 100644 index 00000000..5c6d9c86 --- /dev/null +++ b/mkosi.conf @@ -0,0 +1,43 @@ +# A basic configuration to test azure-init +# +# Currently, this only works when used from an Azure VM since it relies on the +# Azure-provided IMDS and Wireserver instances. In the future we can provide stubs +# so it's easy to test locally or in GitHub actions. We can also add configurations +# for additional distributions. +# +# To use this: +# - Install mkosi +# - Run `mkosi -d fedora` or `mkosi -d debian` +# - Run `sudo mkosi -d fedora boot` +# +# The repository is available under /work +[Output] +BuildDirectory=.mkosi/builddir +CacheDirectory=.mkosi/cache +Format=directory + +[Content] +Autologin=yes + +Packages= + curl + gdb + sudo + systemd + util-linux + +[Host] +# Build an image with `genisoimage -udf -o target/image.iso ovf` where ovf is a +# directory with a valid `ovf-env.xml` file in it. Then uncomment below to add +# the ISO as a CD-ROM in the virtual machine. +# +# This only works with a bootable image. +#QemuArgs=-cdrom target/image.iso + +# Boot to a temporary snapshot of the image - changes won't be persisted to the +# image. +Ephemeral=true +# Perform an incremental rebuild of the image +Incremental=true +# Make the source available at runtime +RuntimeBuildSources=yes diff --git a/mkosi.conf.d/10-debian.conf b/mkosi.conf.d/10-debian.conf new file mode 100644 index 00000000..68d8e40b --- /dev/null +++ b/mkosi.conf.d/10-debian.conf @@ -0,0 +1,14 @@ +[Match] +Distribution=|debian + +[Output] +OutputDirectory=.mkosi/debian-output + +[Content] +Packages= + apt + dbus-broker + dbus-user-session + openssh-client + openssh-server + passwd diff --git a/mkosi.conf.d/10-fedora.conf b/mkosi.conf.d/10-fedora.conf new file mode 100644 index 00000000..6e861bb0 --- /dev/null +++ b/mkosi.conf.d/10-fedora.conf @@ -0,0 +1,11 @@ +[Match] +Distribution=|fedora + +[Output] +OutputDirectory=.mkosi/fedora-output + +[Content] +Packages= + dnf + openssh + shadow-utils diff --git a/mkosi.postinst.chroot b/mkosi.postinst.chroot new file mode 100755 index 00000000..8f90c3b5 --- /dev/null +++ b/mkosi.postinst.chroot @@ -0,0 +1,24 @@ +#!/bin/bash +set -e + +SUDO_GROUP=$(grep -oP "^%\K\w+" /etc/sudoers) + +cat >/etc/systemd/system/azure-init.service </usr/lib/systemd/system-preset/1-azure-init.preset <