https://wiki.fai-project.org/api.php?action=feedcontributions&user=BrianShowalter&feedformat=atomFAIWiki - User contributions [en]2024-03-28T16:49:41ZUser contributionsMediaWiki 1.39.5https://wiki.fai-project.org/index.php?title=User:BrianShowalter/Using_FAI_to_install_Linux-vservers&diff=1018User:BrianShowalter/Using FAI to install Linux-vservers2006-03-10T05:21:26Z<p>BrianShowalter: </p>
<hr />
<div>This document explains how to set up and use FAI to install [http://www.linux-vserver.org Linux vservers]. It assumes that the vserver patches have already been compiled into the kernel that will be installed by FAI.<br />
<br />
<br />
In the <code>$FAI_CONFIGDIR</code> or <code>/usr/lib/fai</code> directory, there is a file called <code>subroutines</code> which contains functions that handle certain FAI tasks. Load this file into a text editor. Around line 112 there is a line that executes "<code>unset task_$taskname</code>". Comment out this line so that the task functions will remain available for use when installing vserver children.<br />
<br />
<br />
In <code>$FAI_CONFIGDIR/class/50-host-classes</code>, set up the vserver host and child classes similar to the following:<br />
<br />
<pre>#!/bin/sh<br />
<br />
class $HOSTNAME in<br />
vshost)<br />
echo "FAIBASE VSHOST VSCOMMON";;<br />
vschild1)<br />
echo "VSCHILD VSCOMMON APACHE" && exit 0;;<br />
vschild2)<br />
echo "VSCHILD VSCOMMON MYSQL" && exit 0;;<br />
vschild3)<br />
echo "VSCHILD VSCOMMON POSTFIX" && exit 0;;<br />
*)<br />
echo "FAIBASE DHCPC";;<br />
esac<br />
<br />
ifclass I386 && echo "GRUB"<br />
exit 0</pre><br />
<br />
<br />
In <code>$FAI_CONFIGDIR/class/vshost.var</code>, set up the names of the child vservers that are associated with a host:<br />
<br />
<pre>vschildren="vschild1 vschild2 vschild3"</pre><br />
<br />
<br />
Set up the vserver child classes (one class file per child) as follows in <code>$FAI_CONFIGDIR/class/<childname>.var</code>:<br />
<br />
<pre>vsname="vs1"<br />
childdev="eth0"<br />
childip="192.168.0.10"<br />
childprefix="24"</pre><br />
<br />
<br />
Copy <code>$FAI_CONFIGDIR/debconf/FAIBASE</code> to <code>$FAI_CONFIGDIR/debconf/VSCHILD</code>.<br />
<br />
<br />
In <code>$FAI_CONFIGDIR/hooks/finish.VSHOST</code>, create a file with the following contents:<br />
<br />
<pre><br />
#!/bin/sh<br />
#<br />
# $FAI_CONFIGDIR/hooks/finish.VSHOST<br />
#<br />
# Save hostname and root directory of vserver base<br />
VSHOST=$HOSTNAME<br />
VSHOST_IPADDR=$IPADDR<br />
VSHOST_FAI_ROOT=$FAI_ROOT<br />
<br />
# Create vserver base directories<br />
[ -e $FAI_ROOT/vservers ] || mkdir $FAI_ROOT/vservers<br />
rm -f $FAI_ROOT/etc/vservers/.defaults/vdirbase<br />
chroot $FAI_ROOT ln -s /vservers /etc/vservers/.defaults/vdirbase<br />
chroot $FAI_ROOT setattr --barrier /vservers<br />
<br />
mkdir -p $FAI_ROOT/etc/vservers/.defaults/apps/debootstrap<br />
echo "http://$mirrorhost/debian" >$FAI_ROOT/etc/vservers/.defaults/apps/debootstrap/mirror<br />
<br />
# Check whether any vserver children need to be installed<br />
if [ -n "$vschildren" ]; then<br />
for childhost in $vschildren; do<br />
HOSTNAME=$childhost<br />
hostname $childhost<br />
echo "vserver child hostname set to $childhost"<br />
sleep 3<br />
export HOSTNAME<br />
<br />
task vschild_defclass<br />
task defvar<br />
<br />
# Set up FAI_ROOT to point to vserver child root<br />
export FAI_ROOT="$VSHOST_FAI_ROOT/vservers/$vsname"<br />
export ROOTCMD="chroot $FAI_ROOT"<br />
export IPADDR=$childip<br />
<br />
# Variables for cfengine<br />
target=$FAI_ROOT<br />
<br />
# Create child vserver<br />
task vschild_create<br />
<br />
# Install & configure vserver packages<br />
task vschild_install<br />
done<br />
fi<br />
<br />
# Restore hostname, IP address and root directory of vserver base<br />
export HOSTNAME=$VSHOST<br />
hostname $VSHOST<br />
export IPADDR=$VSHOST_IPADDR<br />
export FAI_ROOT=$VSHOST_FAI_ROOT<br />
export ROOTCMD="chroot $FAI_ROOT"<br />
</pre><br />
<br />
<br />
In <code>$FAI_CONFIGDIR/hooks/subroutines</code>, create a file with the following contents:<br />
<br />
<pre><br />
#! /bin/bash<br />
#<br />
# $FAI_CONFIGDIR/hooks/subroutines<br />
<br />
# Custom FAI subroutines to install vserver children<br />
#<br />
# Written by Brian Showalter<br />
# 11 Feb 2006<br />
<br />
task_vschild_defclass() {<br />
# Reevaluate classes<br />
fai-class -T $FAI/class $LOGDIR/FAI_CLASSES<br />
classes=$(< $LOGDIR/FAI_CLASSES)<br />
<br />
# define classes as: a.b.c.d for cfengine -D<br />
# this doesn't work without echo<br />
cfclasses=$(echo $classes)<br />
cfclasses=${cfclasses// /.}<br />
[ "$debug" ] && echo "cfclasses: $cfclasses"<br />
}<br />
<br />
task_vschild_create() {<br />
echo "Creating vserver $vsname"<br />
local removepkgs="sparc-utils,dhcp-client,lilo,makedev,pcmcia-cs,ppp,pppconfig,pppoe"<br />
removepkgs="${removepkgs},pppoeconf,setserial,syslinux,fdutils,libpcap0"<br />
removepkgs="${removepkgs},pciutils,ipchains,iptables,jove,nano"<br />
<br />
chroot $VSHOST_FAI_ROOT /usr/sbin/vserver $vsname build -m debootstrap \<br />
--hostname $childhost --interface $childdev:$childip/$childprefix -- \<br />
-d sarge -m http://$mirrorhost/debian -- --exclude="$removepkgs"<br />
}<br />
<br />
task_vschild_updatebase() {<br />
if [ "$FAI_ACTION" = "install" ]; then<br />
# Some packages must access /proc even in chroot environment<br />
mount -t proc proc $FAI_ROOT/proc<br />
<br />
# if libc is upgraded init u is called in chroot environment and<br />
# then init will eat up much cpu time<br />
fai-divert -a /sbin/init /usr/sbin/liloconfig /usr/sbin/invoke-rc.d<br />
# fake some more programs<br />
# fai-divert -a /etc/init.d/nis /sbin/start-stop-daemon<br />
# cp /sbin/start-stop-daemon $FAI_ROOT/sbin/start-stop-daemon<br />
fi<br />
<br />
# update the apt-get information inside the nfsroot<br />
export aptopt='-y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"'<br />
$ROOTCMD apt-get $aptopt update<br />
$ROOTCMD apt-get $aptopt check<br />
[ $? -ne 0 ] && $ROOTCMD apt-get $aptopt -f install </dev/null<br />
$ROOTCMD dpkg -C<br />
[ $? -ne 0 ] && yes '' | $ROOTCMD dpkg --configure -a<br />
# using the above value, causes an error: "dpkg need action"<br />
export aptopt=<br />
$ROOTCMD apt-get $aptopt -f -y dist-upgrade </dev/null<br />
# update dpkg info which packages are available<br />
tmp=$($ROOTCMD mktemp)<br />
$ROOTCMD apt-cache dumpavail > $FAI_ROOT/$tmp<br />
$ROOTCMD dpkg --update-avail $tmp<br />
rm -f $FAI_ROOT/$tmp<br />
}<br />
<br />
task_vschild_install() {<br />
task debconf<br />
task prepareapt<br />
task vschild_updatebase<br />
task instsoft<br />
task configure<br />
}<br />
</pre><br />
The two commented-out lines above cause problems when starting vserver children.<br />
<br />
<br />
In <code>$FAI_CONFIGDIR/package_config/VSCOMMON</code>, insert the following package names to install common software. This is similar to those installed with the FAIBASE class, except that it doesn't include packages that should not go in a vserver child, such as hdparm or nfs-common:<br />
<pre><br />
PACKAGES aptitude<br />
bzip2<br />
cfengine<br />
cron<br />
debconf-utils<br />
file<br />
less<br />
linuxlogo<br />
rsync<br />
ssh<br />
sysutils<br />
time<br />
</pre><br />
<br />
<br />
In <code>$FAI_CONFIGDIR/package_config/VSHOST</code>, insert the following package names to install the vserver utility software:<br />
<pre><br />
PACKAGES aptitude<br />
util-vserver<br />
vserver-debiantools<br />
</pre><br />
<br />
<br />
In <code>$FAI_CONFIGDIR/scripts/VSCHILD/10-misc</code>, insert the following:<br />
<pre><br />
#! /bin/sh<br />
<br />
# (c) Thomas Lange, 2001-2005, lange@debian.org<br />
<br />
error=0 ; trap "error=$((error|1))" ERR<br />
<br />
# assuming that make-fai-nfsroot.conf sets<br />
# FAI_LOCAL_REPOSITORY="deb file:/fai/files packages/"<br />
# install additional packags that are located in /fai/files/packages/<br />
if [ -d /fai/files/packages ] && [ ! -f /fai/files/packages/Packages.gz ]; then<br />
# Mm. It seems not to be a simple repository. I assume it's configured in sources.list<br />
echo "WARNING! Index file Packages.gz is missing in /fai/files/packages."<br />
fi<br />
<br />
fcopy /etc/hostname || echo $HOSTNAME > $target/etc/hostname<br />
echo $time_zone > $target/etc/timezone<br />
ln -fs /usr/share/zoneinfo/${time_zone} $target/etc/localtime<br />
<br />
fcopy -iM /etc/hosts /etc/motd<br />
<br />
# set root password<br />
echo "root:$rootpw" | $ROOTCMD chpasswd --encrypted<br />
# make /root accessable only by root<br />
chmod 0700 $target/root<br />
chown root:root $target/root<br />
# copy default dotfiles for root account<br />
fcopy -ir /root<br />
<br />
# create keyboard layput table<br />
$ROOTCMD bash -c "echo 'console-data console-data/keymap/full select $FAI_KEYMAP' | debconf-set-selections"<br />
$ROOTCMD install-keymap $FAI_KEYMAP || true<br />
# dumpkeys | gzip -9f >$target/etc/console/boottime.kmap.gz<br />
<br />
exit $error<br />
</pre><br />
<br />
<br />
In <code>$FAI_CONFIGDIR/scripts/VSCHILD/20-misc</code>, insert the following:<br />
<pre><br />
#! /usr/bin/cfengine<br />
<br />
control:<br />
OutputPrefix = ("cfengine")<br />
actionsequence = ( tidy )<br />
EditFileSize = ( 30000 )<br />
<br />
tidy:<br />
any::<br />
${target}/etc/rc?.d pattern=S??exim4 R=0 age=0<br />
${target}/etc/rc?.d pattern=S??klogd R=0 age=0<br />
${target}/etc/rc?.d pattern=S??makedev R=0 age=0<br />
${target}/etc/rc?.d pattern=S??nfs-common R=0 age=0<br />
${target}/etc/rc?.d pattern=S??portmap R=0 age=0<br />
${target}/etc/rc?.d pattern=S??postfix R=0 age=0<br />
${target}/etc/rc?.d pattern=S??rsync R=0 age=0<br />
</pre><br />
<br />
<br />
In <code>$FAI_CONFIGDIR/scripts/VSHOST/10-misc</code>, insert the following:<br />
<br />
<pre><br />
#! /usr/bin/cfengine<br />
<br />
control:<br />
OutputPrefix = ("cfengine")<br />
actionsequence = ( directories editfiles )<br />
EditFileSize = ( 30000 )<br />
<br />
directories:<br />
any::<br />
${target}/vservers mode=1000 owner=0 group=0<br />
<br />
editfiles:<br />
any::<br />
{ ${target}/etc/ssh/sshd_config<br />
LocateLineMatching "#ListenAddress 0.0.0.0"<br />
ReplaceLineWith "ListenAddress ${IPADDR}"<br />
}<br />
</pre></div>BrianShowalterhttps://wiki.fai-project.org/index.php?title=Main_Page&diff=395Main Page2006-01-18T04:08:35Z<p>BrianShowalter: /* User documentation and examples */</p>
<hr />
<div>Hello and welcome to the FAI wiki.<br />
<br />
'''important note: due to spam we were forced to change the registration policy for the wiki. please contact [[User:Lazyboy]] or [http://www.informatik.uni-koeln.de/ls_juenger/people/lange/ Thomas Lange] to get an account, or ask on the FAI mailing list. we are trying to find more convenient solutions for that problem, but it will take a while... Henning'''<br />
<br />
This is a public wiki for [http://www.informatik.uni-koeln.de/fai/ FAI - Fully Automatic Installation]. It's a place for users and developers of FAI to share information. If you have some information on FAI to share, create an account and go ahead! <br />
Below is a first start for the contents that we want to provide here. Most pages, colored in red, have not been started yet. If you can contribute something to them, do it, after reading the [[editing rules]]):<br />
<br />
== Common Information ==<br />
* [[FAIWiki:About | About this Wiki]] - info on this wiki<br />
* [[help for editing]] (mainly mediawiki documentation links)<br />
* [[editing rules]] - some ideas that make collaborative work here easier<br />
* [[Resources]] - there are some information resources about FAI available &quot;out there&quot;, as well as some unofficial developer branches, that are handled somewhere else until that code is incoporated in the FAI main Branch - and we want to point to them.<br />
* [[Wishlist]] (for those users that can't use the debian bts for reporting a bug of type wishlist and for developers who want to know what users wish) <br />
* for now, the [http://www.informatik.uni-koeln.de/fai/ FAI Homepage] is still the biggest source of information, eventually lots of the stuff there will migrate into the wiki<br />
* practice wiki writing [[practice wiki writing|here]]<br />
<br />
* getting FAI - if you want the latest and greatest version:<br />
** download ist from: http://www.informatik.uni-koeln.de/fai/download/<br />
** add this to your /etc/apt/sources.list: "deb http://www.informatik.uni-koeln.de/fai/ download"<br />
** install it within debian sid<br />
<br />
== User documentation and examples ==<br />
* Main documentation for FAI is the fai guide: Either in [http://www.informatik.uni-koeln.de/fai/fai-guide.html/ english], [http://www.informatik.uni-koeln.de/fai/fai-guide-fr/ french], [http://pc.debian.ro/fai/ romanian]<br />
* [[reporting bugs]] and also maybe find fixes for problems that you might encounter when using FAI. '''Think about it, you can help make FAI better by telling us what's wrong with it!'''<br />
* [[example classes]] and [[helper scripts]] - classes and small code contributions that are not (already) part of the FAI distribution<br />
* tips and tricks - other hints for users by users that are not exactly written in code like the above - general advice, configuration hints<br />
** smaller [[tips and tricks]]<br />
** [[Installing Ubuntu Linux with FAI]]<br />
** [[Using gpg-authenticated debian-archives]]<br />
** [[Using FAI to set up XEN domains]]<br />
** [http://faiwiki.informatik.uni-koeln.de/index.php/User:Svamberg/Software_RAID Software-RAID with mdadm]<br />
** [http://www.informatik.uni-koeln.de/fai/download/developers/setup_harddisks patched version of setup_harddisks]: Code refactoring, LVM/RAID support and POD manual page: Copyright (c) 2003, Sam Vilain]<br />
** [http://www.linuxma.com/fai_raid/ LVM & RAID]<br />
** [http://faiwiki.informatik.uni-koeln.de/index.php/User:Svamberg/Logs_to_mail FAI-Logs via Mail]<br />
** [http://faiwiki.informatik.uni-koeln.de/index.php/User:Svamberg/Making_documentation Creating class-based documentaion]<br />
** [[Using_customized_kernels_with_FAI]]<br />
* [[Success Stories]] - who is using FAI, how and why - and, when available pictures of the machines installed with FAI :)<br />
* [http://www.informatik.uni-koeln.de/fai/q-answers User reports] by filling out the [http://www.informatik.uni-koeln.de/fai/questionnaire FAI questionnaire] (TODO: create a webform for this)<br />
* [[user FAQ]] ( from questions in the mailing list and on IRC freenode #fai) - We took the contents of the old and somewhat unmaintained [http://faifaq.andrew.net.au/cache/index.html fai faqmatic] to this wiki to have all information more centralized. Please use the Wiki from now on.<br />
* [[linux-fai mailing list infos]] (Netiquette, how to subscribe and use)<br />
* this wiki needs a [[Logo]]<br />
<br />
* [http://www.debian-administration.org/articles/240 a short tutorial on www.debian-administration.org]<br />
* [http://jijo.free.net.ph/files/talks/20050914-linuxworld2005.pdf a talk on fai and debian]<br />
<br />
== Developer information ==<br />
[[Developers information]]</div>BrianShowalter