'How to organise Fully Automated Install (FAI) class hosts?
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.
Solution 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | user7037 |