This was inspired by siteXYtools from mongers.org, but it seemed like it needed a few additional features to make it easier to do more common tasks.
For more information on siteXX files see: http://www.openbsd.org/faq/faq4.html#site
The goals of sxxu are to help you:
- Keep configuration for your systems in a source control
- Recover from a disaster more quickly
- Do a matching install on a secondary system so you can
- Upgrade between versions of OpenBSD with the ability to revert
- Replace aging hardware
- Build a test environment before pushing changes to a production system
sxxu is meant to be a simple utility for installing systems. It does not have the ability to continue to push changes out to already installed systems. For that functionality there are many more powerful solutions. I do wonder if it would be possible to patch sysmerge to support some way of migrating these files.
Some of the problems sxxu tries to solve:
- duplication of common configuration for each system
- permissions easily get broken when configuration is in source control
sxxu [-kmR] [-w WRKDIR] [machine1 [machine2 [...]]]
-k : Keep WRKDIR
-m : rebuild mtree files
-R : don't Recurse into Roles
-w : specify the WRKDIR
In the basedir, each directory is considered a "role", the common directory is merged into each role by default and any directory named role-* does not generate a tgz by default.
Any of the directory structure not in the siteXX directory is treated as a normal siteXX that will extract to the root of your system after the install.
Special files are kept in the siteXX directories. These special files are processed by the install.sxxu after install.
If a role/install.site exists, this WILL overwrite the install.sxxu
that
would have processed these special files.
Create a directory structure for your system:
basedir/
|-common/
|---siteXX
|------roles
|------mtree
|------siteXXrc
|------pkg_add_list
|------install_list
|------patches/
|------packages/
|------install.site
|-machine1/
|---siteXX/
|-machine2/
|---etc/
|------my_app.conf
|---siteXX/
|-role-imap/
|---siteXX/
|---var/
|-----sendmail/
Special files and directories inside the siteXX directory:
-
roles
- Contains a list of "roles" (directories in the basedir) to merge into this configuration. The common directory is automatically included in all configurations.
-
mtree
- An mtree(8) spec file for permissions on the files in this role. It gets applied before the files are put into the archive. See below for notes on how to create and update.
-
siteXXrc
- A ksh script that is included before running the
*_list
commands and the individualinstall.site
files for each role.
- A ksh script that is included before running the
-
pkg_path
- A list (one per line) of sites to add to the
PKG_PATH
environment. Can also be colon separated the same as a normalPKG_PATH
.
- A list (one per line) of sites to add to the
-
*_list
-
A list of arguments to commands to be run. For example if
pkg_add_list
containing "rsync nrpe check_hw_sensors" will attempt to runpkg_add rsync nrpe check_hw_sensors
.The command is executed for each line of the file.
You can set environment variables in the siteXXrc file for arguments. Setting "
pkg_add_args='-i'
" in a siteXXrc would make the above commandpkg_add -i rsync nrpe check_hw_sensors
-
-
patches/
- All patches in this dir need to be relative to the root of the system where the tgz was extracted.
-
packages/
- Package files that will get installed. Completely separate from
pkg_add_list above. It does inherit
pkg_path
andpkg_add_args
.
- Package files that will get installed. Completely separate from
pkg_add_list above. It does inherit
-
install.site
- Your script that gets run after all the above things have been done.
/etc/hostname.if files
If you create /etc/hostname files with generic interfaces, then set ${interface}_if in siteXXrc to the name of the interface, sxxu will rename the hostname file to the interface you specified.
If you create /etc/hostname.egress
and in siteXX/siteXXrc set
egress_if=em0
then after other processing, the /etc/hostname.egress
file
will be renamed to /etc/hostname.em0
You can use sxxu -m
to generate mtree spec files. This will generate the
spec files with the permissions the files have after copying and applying the
existing mtree file.
You can get some more advanced features with some other switches.
# sxxu -kRw /tmp/sxxu-work
will extract all roles including those named role-* into /tmp/sxxy-work without following the included roles. At that point you can change permissions in the work directory as you see fit, then when you are ready, from the place where your source files are you would run
$ sxxu -mw /tmp/sxxu-work
which will regenerate the mtree specs with the permissions you have set.