Templates in DCImanager are sets of disk images and installation scripts that are stored at the location. DCImanager uses templates to install operating systems (OS), perform diagnostics and restore servers.

You can create your own template based on a template from ISPsystem repository by copying an existing template and configuring its parameters.

Creating a template copy


To create a template copy, enter TemplatesOS and operations templates → select the template →menu.png menu → Copy:

  1. Enter the template Name.
  2. Select who will have Access to the template:
    • All;
    • Admins only.
  3. Specify whether the template requires EFI support.
  4. Specify any discretionary template Tags.
  5. Specify the macro Name and Value. Press Add macro, if you need to add more macros. Read more about macros in Template macros.
  6. Copy the path to the directory where the copy of the template will be saved.
  7. Press Copy.

Example of settings

Configuring template parameters


OS templates are stored at the location server in the /opt/ispsystem/dci/os_templates/<template_name> directory. The template consists of the metainfo.xml file and a set of installation files. Metainfo.xml describes the parameters that will be used during installation. Some of these parameters are used by template macros.

metainfo.xml file format

Parameters in the metainfo.xml file are specified in the format <parameter_name>parameter_value</parameter_name>. For example, <sshpublickey>yes</sshpublickey>. All paths in the parameters are specified relative to the directory with the template.

Main parameters:

  • <kernel> — name of the file with Linux kernel image;

  • <initrd> — name of the file with Initrd image;

  • <kernelcommand> — kernel loading parameters. Macros can be used in the parameter. Read more in Template macros;

Example of parameter

<kernelcommand>lang=en_US keymap=us ks=($OSINSTALLINFO_HTTP) method=http://mirror.yandex.ru/centos/7/os/x86_64/ initrd=initrd ip=($IP) netmask=($NETMASK) gateway=($GATEWAY) dns=($NAMESERVER)</kernelcommand>
BASH
  • <installcfg> — name of the configuration file for installation. This file is specified in the $OSINSTALLINFO_HTTP macro;
  • <image> —  the name of the ISO image file to be mounted as a CD-ROM;
  • <tempipv4> — whether a temporary IPv4 address is required when installing an operating system with a primary IPv6 address. Possible options: yes — required, no — not required;
  • <sharedir> — directory inside the template, files from which will be available via HTTP. This file is specified in the $SHAREDIR_FILE macro;
  • <support><elem version="version"> — short control panel names and versions that support the template. For example, for the template to be supported by all versions of DCImanager starting from 4.8.0, specify <support><elem version="4.8.0">dcimgr</elem></support>;

  • <illegal_password_characters> — characters that cannot be used in a password;

  • <sshpublickey> — support of adding public SSH keys. Possible options: yes — supported, no — not supported;
  • <up_mem_on_install> — RAM in MB, which the server can use when installing the OS. After installation, the amount of memory returns to its basic value;
  • <chpasswd_method> — password change method. Specify mount.linux for a Linux OS;
  • <loaderefi64> — UEFI loader file name;
  • <ipxeconf> — name of configuration file for loading via iPXE;
  • <ipxeconf type="tftp"> — option to load the ipxe.conf configuration file via tftp protocol. A string of the format "tftp://<control_panel_address>/.../ipxe.conf" is added to the configuration file dhcpd.conf.

Examples of templates


kickstart (CentOS)

The kickstart technology allows you to flexibly configure installation parameters for CentOS templates. Read more about kickstart in the official CentOS documentation.

Example of metainfo.xml file

<?xml version="1.0"?>
<doc>
  <osname>CentOS-7-amd64</osname>
  <support>
    <elem>VMmgr</elem>
    <elem>IFXmgr</elem>
  </support>
  <rebootcount>1</rebootcount>
  <kernel>vmlinuz</kernel>
  <initrd>initrd.img</initrd>
  <type>ostemplate</type>
  <loader>pxelinux.0</loader>
  <pxelinuxcfg>pxelinux.conf</pxelinuxcfg>
  <tempipv4>yes</tempipv4>
  <kernelcommand>lang=en_US keymap=us ks=($OSINSTALLINFO_HTTPv4) ksdevice=link method=http://mirror.yandex.ru/centos/7/os/x86_64/ ip=($IPv4) netmask=($NETMASKv4) gateway=($GATEWAYv4) dns=($NAMESERVERv4) proxy=($HTTPPROXYv4) text</kernelcommand>
  <installcfg>install.cfg</installcfg>
  <limit>
    <elem name="ipv4">yes</elem>
    <elem name="ipv6">yes</elem>
    <elem name="mem">512</elem>
    <elem name="disk">2000</elem>
  </limit>
 </doc>
BASH

Example of install.cfg file

%pre

#!/bin/sh

for disk in `ls -la /dev/sd?`; do
    dd if=/dev/zero of=$disk bs=512 count=32
done

SWSIZE=$(grep MemTotal /proc/meminfo  | awk '{print int($2/1024)+1}')
if [ ${SWSIZE} -gt 2048 ]; then
    SWSIZE=2048
fi

if [ `cat /proc/scsi/scsi | grep -wc ATA` -eq 2 ]; then
     set $(fdisk -l 2>/dev/null | grep -vi mapper | grep Disk | grep dev |  sed 's/://' | awk '{print $2}' | tr '\n' ' ')
     HD1=$1
    HD2=$2
    if [ -b ${HD2} ]; then
        SIZE1=$(fdisk -l "${HD1}"  2>/dev/null  | grep Disk | grep dev |  sed 's/://'|awk '{print $5}')
        SIZE2=$(fdisk -l "${HD2}"  2>/dev/null  | grep Disk | grep dev |  sed 's/://'|awk '{print $5}')
        if [ -n "${SIZE1}" ] && [ -n "${SIZE2}" ] && [ "${SIZE1}" = "${SIZE2}" ]; then
            USE_MIRROR=yes
        fi
    fi
fi

if [ -n "${USE_MIRROR}" ]; then
cat > /tmp/part-include << EOF
part raid.11 --size=256 --asprimary --ondisk=sda
part raid.12 --size=${SWSIZE} --asprimary --ondisk=sda 
part raid.13 --size=1 --grow --asprimary --ondisk=sda 
part raid.21 --size=256 --asprimary --ondisk=sdb
part raid.22 --size=${SWSIZE} --asprimary --ondisk=sdb 
part raid.23 --size=1 --grow --asprimary --ondisk=sdb
raid /boot --fstype ext4 --device md0 --level=RAID1 raid.11 raid.21
raid swap --fstype swap --device md1 --level=RAID1 raid.12 raid.22
raid / --fstype ext4 --device md2 --level=RAID1 raid.13 raid.23
EOF
else
cat > /tmp/part-include << EOF
part /boot --fstype ext4 --size=256 --asprimary --ondisk=sda
part swap --size=${SWSIZE} --asprimary --ondisk=sda
part / --fstype ext4 --size=1 --grow --asprimary --ondisk=sda
EOF
fi

%end
auth --useshadow --enablemd5
# Crete partition map
bootloader --location=mbr
zerombr
clearpart --all --initlabel
firstboot --disable
# Disk partitioning information
%include /tmp/part-include
# System keyboard
keyboard us
# System language
lang en_US.UTF-8
# Installation logging level
logging --level=info
# Use NFS installation media
url --url http://mirror.yandex.ru/centos/7/os/x86_64/
#Root password
rootpw ($PASS)
# SELinux configuration
selinux --disabled
# Text installation
text
# System timezone
timezone --utc Europe/Moscow

# Network
network --bootproto=static --ip=($IPv4) --netmask=($NETMASK)  --gateway=($GATEWAYv4) --nameserver=($NAMESERVERv4) --hostname=($HOSTNAME) --device=link

# Install OS instead of upgrade
install
%packages
@core
%end

%post
# Network settings
#echo "NETWORKING=yes" > /etc/sysconfig/network
#echo "HOSTNAME=($HOSTNAME)"
ETHDEV=$(ip route show | grep default | grep -Eo 'dev\ .+\ ' | awk '{print $2}')
HWADDR=$(cat /etc/sysconfig/network-scripts/ifcfg-eth0 | awk -F= '/HWADDR/ {print $2}' | sed 's/"//g')
UUID=$(cat /etc/sysconfig/network-scripts/ifcfg-eth0 | awk -F= '/UUID/ {print $2}' | sed 's/"//g')

if [ -n "($IPv6)" ]; then
cat > /etc/sysconfig/network << EOF
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=($HOSTNAME)
IPV6_DEFAULTGW=($GATEWAY)
EOF

cat > /etc/sysconfig/network-scripts/ifcfg-${ETHDEV} << EOF
DEVICE="${ETHDEV}"
BOOTPROTO="static"
DNS1="($NAMESERVER)"
HWADDR="${HWADDR}"
IPV6ADDR="($IPv6)/($NETMASKv6)"
IPV6INIT="yes"
IPV6_AUTOCONF="no"
IPV6_DEFAULTGW="($GATEWAY)"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="${UUID}"
EOF

fi
%end

%post --nochroot
wget -O /dev/null --no-check-certificate "($FINISHv4)"
# Reboot after installation
%end

reboot
BASH

preseed (Debian, Ubuntu)

Recommended for use with Debian, Ubuntu OS templates Read more in the official Ubuntu and Debian documentation.

Example of metainfo.xml file

<?xml version="1.0"?>
<doc>
  <osname>Debian-9-amd64</osname>
  <support>
    <elem>IFXmgr</elem>
    <elem>VMmgr</elem>
  </support>
  <rebootcount>1</rebootcount>
  <kernel>linux</kernel>
  <initrd>initrd.gz</initrd>
  <type>ostemplate</type>
  <loader>pxelinux.0</loader>
  <pxelinuxcfg>pxelinux.conf</pxelinuxcfg>
  <tempipv4>yes</tempipv4>
  <kernelcommand>url=($OSINSTALLINFO_HTTPv4) language=en debian-installer/country=RU locale=en_US keyboard-configuration/xkb-keymap=us console-keymaps-at/keymap=us interface=auto netcfg/disable_dhcp=true netcfg/get_ipaddress=($IPv4) netcfg/get_netmask=($NETMASKv4) netcfg/get_gateway=($GATEWAYv4) netcfg/get_nameservers=($NAMESERVERv4) hostname=($HOSTNAME) domain=($HOSTNAME)</kernelcommand>
  <installcfg>install.cfg</installcfg>
  <limit>
    <elem name="ipv4">yes</elem>
    <elem name="ipv6">yes</elem>
    <elem name="mem">512</elem>
    <elem name="disk">1000</elem>
  </limit>
</doc>

BASH


Example of install.cfg file

d-i keyboard-configuration/xkb-keymap select us

# Mirrors
#d-i mirror/protocol string ftp
#d-i mirror/country string manual
#d-i mirror/ftp/hostname string ftp.ru.debian.org
#d-i mirror/ftp/directory string /debian
#d-i mirror/ftp/proxy string
d-i mirror/country string manual
d-i mirror/http/hostname string mirror.yandex.ru
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string ($HTTPPROXYv4)

d-i passwd/make-user boolean false

d-i passwd/root-password password ($PASS)
d-i passwd/root-password-again password ($PASS)

d-i clock-setup/utc boolean true

d-i time/zone string Europe/Moscow

d-i preseed/early_command string \
	anna-install parted-udeb 

# Partitioning
d-i partman/early_command string \
for DISK in $(list-devices disk); do \
    dd if=/dev/zero of=${DISK} bs=512 count=1; \
    parted -s ${DISK} mklabel gpt; \
done; \
set $(list-devices disk); \
let numb=$#/2; \
DISKA=$1; \
DISKB=$2; \
if [ -b "${DISKB}" ]; then \
    SIZE1=$(fdisk -l "${DISKA}" 2>/dev/null|grep Disk|grep dev|cut -d' ' -f5); \
    SIZE2=$(fdisk -l "${DISKB}" 2>/dev/null|grep Disk|grep dev|cut -d' ' -f5); \
	if [ -n ${SIZE1} ] && [ -n ${SIZE2} ] && [ "${SIZE1}" = "${SIZE2}" ]; then \
	    USE_MIRROR=yes; \
	else \
	    USE_MIRROR=no; \
	fi; \
fi; \
if [ "#${USE_MIRROR}" = "#yes" ]; then \
	debconf-set partman-auto/disk "$DISKA $DISKB";\
	debconf-set partman-auto/method "raid";\
	debconf-set partman-auto/expert_recipe "multiraid :: \  100 50 100 raid $primary{ } method{ raid } . \  128 512 100% raid method{ raid } . \  1024 10000 1000000000 raid method{ raid } . ";\
	debconf-set partman-auto-raid/recipe "1 2 0 ext2 /boot ${DISKA}1#${DISKB}1 . \  1 2 0 swap — ${DISKA}5#${DISKB}5 . \  1 2 0 ext4 / ${DISKA}6#${DISKB}6 . ";\
	debconf-set grub-installer/bootdev "$DISKA $DISKB";\
else \
	debconf-set partman-auto/disk "$DISKA";\
	debconf-set partman-auto/method "regular";\
	debconf-set partman-auto/expert_recipe "boot-root :: \  100 50 100 ext2 $primary{ } $bootable{ } method{ format } format{ } use_filesystem{ } filesystem{ ext2 } mountpoint{ /boot } . \  128 512 100% linux-swap method{ swap } format{ } . \  1024 10000 1000000000 ext4 method{ format } format{ } use_filesystem{ } filesystem{ ext4 } mountpoint{ / } . ";\
	debconf-set grub-installer/bootdev "$DISKA";\
fi 


#d-i partman-auto/method string regular

#d-i partman-auto/expert_recipe string \
# boot-root :: \
# 40 50 100 ext2 \
# $primary{ } $bootable{ } \
# method{ format } format{ } \
# use_filesystem{ } filesystem{ ext2 } \
# mountpoint{ /boot } \
# . \
# 500 10000 1000000000 ext4 \
# method{ format } format{ } \
# use_filesystem{ } filesystem{ ext4 } \
# mountpoint{ / } \
# . \
# 64 512 300% linux-swap \
# method{ swap } format{ } \
# .

# Force overwrite partitions

d-i partman-partitioning/choose_label       select gpt
d-i partman-partitioning/confirm_new_label  boolean true
d-i partman-partitioning/unknown_label  boolean true
d-i partman/exception_handler   select  Yes
partman-partitioning    partman-partitioning/choose_label       select gpt
partman-partitioning    partman-partitioning/confirm_new_label  boolean true
partman-partitioning    partman-partitioning/unknown_label  boolean true
partman-base    partman/exception_handler   select  Yes

d-i partman-auto/purge_lvm_from_device boolean true
d-i partman-lvm/device_remove_lvm boolean true 
d-i partman-md/device_remove_md boolean true
d-i partman-md/confirm boolean true
d-i partman-md/confirm_nooverwrite boolean true
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true

d-i partman/mount_style select traditional

# Apt

#d-i base-installer/install-recommends boolean true

#d-i base-installer/kernel/linux/initramfs-generators string initramfs-tools
#d-i base-installer/kernel/image string linux-image-amd64

d-i apt-setup/contrib boolean true
#d-i apt-setup/use_mirror boolean true

# Packages
d-i apt-setup/services-select multiselect security, volatile
tasksel tasksel/first multiselect standard
d-i pkgsel/include string openssh-server vim wget

popularity-contest popularity-contest/participate boolean false

# Grub
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true

d-i finish-install/keep-consoles boolean true

d-i preseed/late_command string \
	in-target rm -f /etc/apt/apt.conf ;\
	ETHDEV=$(ip route show | grep default | grep -Eo 'dev\ .+\ ' | cut -d' ' -f2) ;\
	if [ -n "($IPv6)" ]; then \
		echo "# The loopback network interface" > /target/etc/network/interfaces ;\
		echo "auto lo" >> /target/etc/network/interfaces ;\
		echo "iface lo inet loopback" >> /target/etc/network/interfaces ;\
		echo "" >> /target/etc/network/interfaces ;\
		echo "# The primary network interface" >> /target/etc/network/interfaces ;\
		echo "allow-hotplug ${ETHDEV}" >> /target/etc/network/interfaces ;\
		echo "iface ${ETHDEV} inet6 static" >> /target/etc/network/interfaces ;\
		echo -e "\taddress ($IPv6)" >> /target/etc/network/interfaces ;\
		echo -e "\tnetmask ($NETMASKv6)" >> /target/etc/network/interfaces ;\
		echo -e "\tgateway ($GATEWAYv6)" >> /target/etc/network/interfaces ;\
		echo -e "\tdns-nameservers ($NAMESERVERv6)" >> /target/etc/network/interfaces ;\
		echo "nameserver ($NAMESERVERv6)" > /target/etc/resolv.conf ;\
		sed -i "s/($IPv4)/($IPv6)/" /etc/hosts ;\
		sed -i "s/($IPv4)/($IPv6)/" /target/etc/hosts ;\
		echo "# The loopback network interface" > /etc/network/interfaces ;\
		echo "auto lo" >> /etc/network/interfaces ;\
		echo "iface lo inet loopback" >> /etc/network/interfaces ;\
		echo "" >> /etc/network/interfaces ;\
		echo "# The primary network interface" >> /etc/network/interfaces ;\
		echo "allow-hotplug ${ETHDEV}" >> /etc/network/interfaces ;\
		echo "iface ${ETHDEV} inet6 static" >> /etc/network/interfaces ;\
		echo -e "\taddress ($IPv6)" >> /etc/network/interfaces ;\
		echo -e "\tnetmask ($NETMASKv6)" >> /etc/network/interfaces ;\
		echo -e "\tgateway ($GATEWAYv6)" >> /etc/network/interfaces ;\
		echo -e "\tdns-nameservers ($NAMESERVERv6)" >> /etc/network/interfaces ;\
		echo "nameserver ($NAMESERVERv6)" > /etc/resolv.conf ;\
	fi ;\
	in-target wget --no-check-certificate "($FINISHv4)"

d-i finish-install/reboot_in_progress note
BASH