Creating Environments via CBSDfile
Command
cbsd up
The cbsd up command reads the CBSDfile in the current working directory and creates all environments defined within it. This is the recommended and standard method for regular use.
What is CBSDfile
CBSDfile is a shell script containing configuration functions. Each function describes one environment. The cbsd up command executes (source) this script and creates environments according to the definitions.
An environment definition is specified by a function name in the following format:
<type>_<name>()
{
# parameters
}
The type determines the hypervisor:
- jail — FreeBSD jail container
- bhyve — bhyve virtual machine
- qemu — QEMU virtual machine
- xen — Xen virtual machine
Basic Structure
Minimal CBSDfile:
jail_web1()
{
ip4_addr="10.0.0.10"
host_hostname="web1.example.com"
ver="14.2"
}
Running cbsd up will create the web1 jail with the specified parameters.
With multiple environments:
jail_web1()
{
ip4_addr="10.0.0.10"
host_hostname="web1.example.com"
}
jail_web2()
{
ip4_addr="10.0.0.11"
host_hostname="web2.example.com"
}
Global Variables
The globals() function sets parameters applied to all environments in the file:
globals()
{
default_domain="example.com"
bhyve_vnc_tcp_bind="0.0.0.0"
}
jail_web1()
{
ip4_addr="10.0.0.10"
}
Variables from globals() are applied to all environments unless a specific environment overrides them.
Mixed Hypervisors
A single CBSDfile can contain different types of environments:
jail_web() { ip4_addr="10.0.0.10"; } bhyve_vm1() { vm_ram="2g"; vm_cpus="2"; } ``` Running `cbsd up` will process both functions, creating a jail and a bhyve VM respectively.`cbsd up web ver= 3 CLI Override CLI arguments for cbsd up override values from CBSDfile:`cbsd up web ver= 3 For CBSDfile:`jail_web(){ver= " 3}`
Result: `web1` will be created with `ver=14.4` and `ip4_addr=DHCP`, ignoring the values from the file.
This allows using a single CBSDfile as a template for different configurations.
## Parallel Execution
The `PARALLEL` variable controls the number of environments created simultaneously:
```bash
globals()
{
PARALLEL=4
}
By default, PARALLEL=1 (sequential execution).
Global Environment Parameters
Parameters from the jcreate table are applicable in CBSDfile. Main ones:
| Parameter | Default | Description |
|---|---|---|
ip4_addr |
DHCP |
IPv4 address |
host_hostname |
${jname}.${default_domain} |
FQDN |
ver |
native |
FreeBSD release version |
arch |
native |
Architecture |
vnet |
0 |
VNET isolation |
astart |
1 |
Auto-start on host bootup |
runasap |
0 |
Start immediately after creation |
pkglist List of packages to install || |
List of packages to install | |
cbsd destroy |
Remove all environments from CBSDfile | |
cbsd destroy <name> |
Remove a specific environment |