A FreeBSD 14.0+ jail script generator.
This repository has been archived on 2026-09-15. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
  • Go 97.5%
  • Makefile 2.5%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2025-02-01 21:17:59 -05:00
templates Replace 'bootstrap' with 'configure' terminology 2025-02-01 21:17:59 -05:00
.gitignore Manually template ZFS scripts 2025-01-05 16:28:40 -05:00
bridge.go Fix interface nil comparison crash 2025-01-16 00:04:58 -05:00
checks.go Add message to CheckResult 2025-01-05 18:20:31 -05:00
config.go Fix interface nil comparison crash 2025-01-16 00:04:58 -05:00
configure.go Replace 'bootstrap' with 'configure' terminology 2025-02-01 21:17:59 -05:00
embed.go Move ExecTemplates logic to templates.go 2025-01-17 15:23:53 -05:00
go.mod Fix go module name 2025-01-06 21:02:36 -05:00
go.sum Fix go module name 2025-01-06 21:02:36 -05:00
host.go Start jail.conf processing logic 2025-01-06 16:56:51 -05:00
img.go Replace 'bootstrap' with 'configure' terminology 2025-02-01 21:17:59 -05:00
jail.go Replace 'bootstrap' with 'configure' terminology 2025-02-01 21:17:59 -05:00
LICENSE Initial commit 2024-12-31 11:25:29 -05:00
main.go Fix vnet interface and epair name collisions 2025-01-06 22:12:07 -05:00
Makefile Add Makefile for installation 2024-12-31 14:37:14 -05:00
rc.go Move template logic to root package 2025-01-06 15:14:44 -05:00
README.md Replace 'bootstrap' with 'configure' terminology 2025-02-01 21:17:59 -05:00
templates.go Replace 'bootstrap' with 'configure' terminology 2025-02-01 21:17:59 -05:00
zfs.go Fix interface nil comparison crash 2025-01-16 00:04:58 -05:00

jmake

A FreeBSD 14.0+ jail script generator. (WIP)

Philosophy

jmake is not a jail manager. Instead of trying to abstract the task of jail management away from the vanilla FreeBSD utilities, jmake instead generates commands and configuration for use with these vanilla utilities. This philosophy ensures that jmake doesn't tie its users or their systems to any non-vanilla tooling. You can choose to stop using jmake and write these commands/configurations with another method (either manually or via different tool[s]) at any time.

Example Config

# It's recommended to place the [host] section at the top in order to
# make any jmake.toml quickly identifiable and asssociable with its intended deployment host(s)

[host] # Configuration describing the jail deployment host
domain = "ncrypt.ing" # Network domain the host resides on (jails will be configured with this same domain)

[zfs] # Config for ZFS backed jail storage (ZFS is required for jmake)
dataset = "zroot/var/jail" # Name of the ZFS dataset used for jail storage
mountpoint = "/var/jail" # Mountpoint for the ZFS dataset used for jail storage

# Config for the FreeBSD image which will be used as a template for jail deployment
[img]
# FreeBSD release version to deploy jails from
release = "14.2-RELEASE"
# Name of the ZFS template snapshot to deploy jails from
snapshot = "base-custom0"
# FreeBSD architecture string
# (optional, default: "amd64/amd64")
arch = "amd64/amd64"
# FreeBSD download mirror URL used for fetching release media
# (optional, default: "https://download.freebsd.org/ftp/releases")
mirror = "https://download.freebsd.org/ftp/releases"

# Config for bootstrapping the jail deployment template snapshot. See bootstrap.go for all available options
# (optional)
#
# Image bootstrapping is useful to describe common options (packages, users, etc.) that are expected for *all* jails
[img.bootstrap]
packages = ["bash", "bash-completion", "sudo", "neovim"]
user.alice = {groups = ["wheel"], shell = "bash", files = [".bashrc"]} # Alice is an admin who prefers bash as a shell
user.bob = {shell = "tcsh", files = [".cshrc"]} # Bob is an unprivileged user who prefers tcsh as a shell

# Jail configuration for a redundant web server setup
[jail.dmz] # This jail gets a hostname of dmz.ncrypt.ing
description = "Reverse proxy to application servers"
network = "192.168.120.3/24"
[jail.dmz.bootstrap]
packages = ["haproxy"]

[jail.www1]
description = "Web server 1"
network = "192.168.120.4/24"
[jail.www1.bootstrap]
packages = ["node", "npm", "nginx"]
user.www = {home_dir = "/var/www", home_dir_perms = 0o755}

[jail.www2]
description = "Web server 2"
network = "192.168.120.5/24"
[jail.www2.bootstrap]
packages = ["node", "npm", "nginx"]
user.www = {home_dir = "/var/www", home_dir_perms = 0o755}

[jail.api1]
description = "API server 1"
network = "192.168.120.6/24"
[jail.api1.bootstrap]
packages = ["go"]
user.api = {home_dir = "/var/www/api", home_dir_perms = 0o700}

[jail.api2]
description = "API server 2"
network = "192.168.120.7/24"
[jail.api2.bootstrap]
packages = ["go"]
user.api = {home_dir = "/var/www/api", home_dir_perms = 0o700}

Usage

Generated Scripts

jmake generates its commands in the form of *.sh files. The name of these files follows the format {section}-{action}.sh, where {section} is a top level config section (i.e zfs, img, bridge) and {action} describes what the script does in relation to its section. For example, zfs-init.sh initializes the ZFS pool configured in the [zfs] section, which can then be used to store FreeBSD images and jails. Conversely, zfs-destroy.sh destroys this ZFS pool.

Editing /etc/rc.conf

jmake may generate rc config blocks in *.rc.conf files (i.e bridge.rc.conf for bridge networking configuration). These files are intended to have their contents appended to /etc/rc.conf, which can be achieved by using sudo tee -a to append with root privileges.

# Example: append the contents of bridge.rc.conf to /etc/rc.conf
cat bridge.rc.conf | sudo tee -a /etc/rc.conf
# Example: append the contents of all generated *.rc.conf files to /etc/rc.conf
cat *.rc.conf | sudo tee -a /etc/rc.conf