How to organise Fully Automated Install (FAI) class hosts?

30 views Asked by At

Fully Automated Install (FAI) has hosts in the file 50-host-classes. We currently have a bunch of hosts which have similar names (eg, ba-hostxx.subdomain). The sub-domains are different but one cannot specify host.subdomain in the class file as the '.' is invalid.

Is it possible to have different hosts in different files? Or to specify the host in some other fashion than just

hostname*)
    echo "BASEFILE FILE" ;;

such as

cluster/hostname*)

    echo "BASEFILE FILE" ;;

?

The documentation leads one to the opinion that all hosts sit in the 50- file.

1

There are 1 answers

0
user7037 On

You can create any number of scripts in the $FAI/class/ folder to generate classes for the hosts. They just need to print out the correct class name(s) based on your criteria. Example below.

class/51-more-classes

#!/bin/bash

# Check the domain name for the host
host_domain=`hostname -A|cut -f 2- -d .`
if [ -n "$host_domain" ] ; then
    [ $host_domain = domain-a.foo ] && echo DOMAIN_A 
    [ $host_domain = domain-b.foo ] && echo DOMAIN_B
fi

# just check the host name
[ $HOSTNAME = ba-host76 ] && echo BA_THING
[ $HOSTNAME = qf-host76 ] && echo QF_THING

# Check that the host matches a pattern
if echo $HOSTNAME | grep -q 'zz-host[0-9][0-9]' ; then
    echo CARROTS
    # Play the lottery
    [ $RANDOM -lt 16536 ] && echo WINNER
fi