简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM