So, I create a my.cnf.tmpl file and that is deployed to all database instances.
The /etc/init.d/mysql script executes a perl script to generate my.cnf from my.cnf.tmpl right before a start executes.
my $HOSTNAME = `hostname`;
my ($name,$alias,$addrtype,$length,@addrs) = gethostbyname($HOSTNAME);
my ($a,$b,$c,$d) = unpack('C4',$addrs);
my $cnfContents ='';
$cnfContents .= $_;
$cnfContents =~ s/\%SERVERID\%/$b$c$d/g;
This script gets the IP address of the host, reads stdin and prints out the my.cnf contents, after replacing %SERVERID% with an the last 3 octets of the IP address to ensure that the number fits in the variable size.
in /etc/init.d/mysql this is added
if test -s $confdir/my.cnf.tmpl
if test -x $bindir/generateServerID.pl
cat $confdir/my.cnf.tmpl | $bindir/generateServerID.pl > $confdir/my.cnf
So, I'm ensured that my, my.cnf is generated and set to a server of which is the concat of the servers IP address.