A requirement more and more pressing in the current data centers is the ability to deploy applications and services quickly, almost immediately.
It is becoming increasingly frequent that the system administrators and DBAs maintain different versions of the same service or application to be used as production environment, testing, development, reporting.
In this post I will show, as the combination of ZFS and FreeBSD Jails can simplify these tasks to the point that are almost trivial.
In order to automate the process of cloning a FreeBSD Jail on ZFS, I have written the following script:
clonejailz.sh
The requirements to be met by a Jail to be cloned with this script are the following:
The clonejailz.rc file can have three different locations, listed in order of precedence:
The clonejailz.sh script is invoked with the following arguments:
This cloning system for Jails consists of the following elements:
It is becoming increasingly frequent that the system administrators and DBAs maintain different versions of the same service or application to be used as production environment, testing, development, reporting.
In this post I will show, as the combination of ZFS and FreeBSD Jails can simplify these tasks to the point that are almost trivial.
In order to automate the process of cloning a FreeBSD Jail on ZFS, I have written the following script:
clonejailz.sh
The requirements to be met by a Jail to be cloned with this script are the following:
- The Jail should have all file systems defined on a single ZFS pool.
- The Jail configuration must reside on a jail.conf file and the file systems of the Jail are defined in a separate fstab file.
- The path of the Jail must take the form $JAIL_ROOT/$JAIL_NAME where the JAIL_ROOT variable defines the root directory of the Jail.
- The dataset where resides the Jail takes the form ZPOOL/$JAIL_ROOT/$JAIL_NAME and is the root of all other file systems associated with the Jail.
The clonejailz.rc file can have three different locations, listed in order of precedence:
- In the directory /usr/local/etc
- In the same directory where the script clonejailz.sh is located.
- In the user's HOME directory, adopted the form $HOME/.clonejailz.rc
The clonejailz.sh script is invoked with the following arguments:
Code:
# clonejailz.sh bjname=base_jail_name njname=new_jail_name jipadr=new_jail_ip [njpool=new_jail_pool] script=script_to_run_inside_the_new_jail
- bjname: It's the name of the Base Jail, ie the Jail to be cloned.
- njname: It is the name of the Jail that will be created as a copy of the Base Jail.
- jipadr: It is the assigned IP address to the newly created Jail.
- njpool: It is the name of the ZFS Pool where reside the Jail to be created. If not defined, the Jail is created as a ZFS clone in the same pool of the Base Jail.
- script: Optionally, you can specify a script to run additional configuration actions for the newly created Jail. This script will be executed within the he newly created Jail.
This cloning system for Jails consists of the following elements: