autoinstall(8)
is an install method that was added in OpenBSD 5.5.
The text-based installation procedure can be fully automated through the use of a preseeded configuration file containing answers to the questions.
There are plenty of reasons why someone would want to use this feature, including but not limited to:
Everything one needs to get going is already installed under OpenBSD. There is no need to install any packages. The core components of an autoinstall rig are:
next-server
and filename
to pxe client, telling it what to grab next/bsd.rd
kernel/pxeboot
(as /auto_install
)For a high level overview, here are the things we will do in this tutorial:
I run dhcpd from my router, however, it can be run from anywhere as long as you
have control of the broadcast domain. Add a stanza similar to this into your
/etc/dhcpd.conf
:
Make sure it runs on boot
start dhcpd
We will point tftpd to use the webroot instead of the default. We want to do
this because we will also be serving out the install media from there, which
already contains the pxeboot
and bsd.rd
files we need.
Also because it lets us keep all the autoinstall files together in one place.
enable it on boot and point it to the webroot:
start it
Bandwidth is not free, so we will start a webserver and use it to serve the installation media we download. We will be making use of the webserver in the latter half of this presentation.
enable it on boot
start it now
You need to download all of the files you see in a url like
http://ftp.usa.openbsd.org/pub/OpenBSD/5.5/amd64/
(assuming you’re installing amd64)
OpenBSD does not come with wget, but it does come with an http-compatible ftp
binary, which we will use like so:
Now that you have the installation media, symlink the pxeboot file in 5.5/
to a
file called auto_install
We named it auto_install for two reasons:
filename "auto_install";
in the dhcpd.conf
auto_install
the installer knows it must initiate the
autoinstall process (as opposed to the autoupgrade or interactive installer)Now finally, set the bsd
kernel in the tftp/web root so we can actually boot it:
Now that everything is coming together, we have one last step to do: build an
openbsd install.conf
file.
As you probably know, installing openbsd involves answering a series of questions - most of which you go with the default on. However, in some cases they are not sufficient (root password comes to mind).
In the event that you would like to change any of the default answers, you
simply create an install.conf
in your tftp root with answers to the questions
asked by the installer.
system hostname = unconfigured
password for root account = hunter2
network interfaces = em0
IPv4 address for em0 = dhcp
Location of sets? = http
server? = 192.168.10.1
server directory? = 5.5/
Make sure this install.conf
file is in the webroot - it has to be
available at:
http://<next-server>/install.conf
In my lab, the setup looks something like this:
site${release}.tgz
to bootstrap your favorite software (CF Management comes to mind)install.conf
generator (so that all install-answers are custom on a per-client/MAC basis)In my lab, I have a similar setup to the one demonstrated earlier , however, I use httpd
, cgi-perl
,
mod_rewrite
and sqlite3
to serve different install.conf
s that are built dynamically. This enables me to create and configure openbsd systems with a single command.
Suppose I wanted to create a new VM called hobosandwiches
with a
different site.tgz, and root key from the rest of my environment.
INSERT INTO vms (name,sitefile,rootkey)
VALUES(
'hobosandwiches',
'./sitefiles/hobos_site.tgz',
'ssh-rsafooooooooooooooooooooooo');
Then, the script will go to a chosen hypervisor and actually create the VM.
During the VM creation phase, a child will fork off and watch the output for the moment a MAC address is assigned
When the MAC address is assigned, it is saved and the record we just added to the DB is updated
UPDATE vms SET mac='mac address' WHERE name='hobosandwiches';
In the meantime, the VM is created and boots
When the VM boots, it checks http://next-server/MACaddress-install.conf
apache is configured to rewrite that URL to install.conf?mac=<mac>
RewriteRule ^/?(.*)-install.conf$ /install.conf?mac=$1 [L]
Apache is also configured to serve install.conf as a perl script
AddHandler cgi-script .conf
Finally, when install.sh
runs on the client and looks for http://next-server/MACaddress-install.conf
, a customized response is delivered.