--- title: Debian Preseeded install medium date: 2016-08-02 09:00:00 --- After the configuration of my servers through Saltstack, I decided to go furter and to also store the configuration to my laptops and home computed into Saltstack and thus allow an easy way to format and get a fully configured system back in place really easily and quickly. First step was to get a quick way of formatting my computers without or with only minimal human intervention. As I'm using Debian, it means preparing a preseeded installation file so that everything is taken care of. I tried some approaches to build manually an install image but as I went along, I decided to scratch all that and script the build of this medium. I looked around and found existing work by [acatton on GitHub](https://github.com/acatton/debian-preseeded-iso). There were a number of problems I wanted to fix : 1. The hostname should be provided by the user on build 2. A default user account should be created 2. Or perhaps not and the user would have to input something during the install 3. I wanted an encrypted root partition by default 4. I wanted to install a Saltstack minion by default 5. I needed to copy default configuration files The encryption and installation of a minion were easy tasks and only need edition of the preseed file. The other points introduced the need for a templating script that could generate different files as needed and using user input during the generation of the medium. As I already knew the Mustache syntax, I decided to use Mustache as a templating engine to generate the needed preseed files. Instead of copying the preseed file from the folder into the generated medium image, I sent it through `mo` with various variables to get 4 different install seeds. cat "$PRESEED" | SUITE="jessie" TARGETNAME=$HOSTNAME CREATEUSER=1 ./mo > "$TMP/preseed-jessie-autouser.cfg" cat "$PRESEED" | SUITE="stretch" TARGETNAME=$HOSTNAME CREATEUSER=1 ./mo > "$TMP/preseed-stretch-autouser.cfg" unset CREATEUSER cat "$PRESEED" | SUITE="jessie" TARGETNAME=$HOSTNAME ./mo > "$TMP/preseed-jessie-manualuser.cfg" cat "$PRESEED" | SUITE="stretch" TARGETNAME=$HOSTNAME ./mo > "$TMP/preseed-stretch-manualuser.cfg" And then, I changed the `isolinux/txt.cfg` configuration file to get an entry for each configuration file. cat >> isolinux/txt.cfg <> isolinux/txt.cfg <> isolinux/txt.cfg <> isolinux/txt.cfg <