Generate true unique server-id for mysql using puppet


I found a few solutions on the net, but people just attach the last 2 digits and I would like to avoid issues like this where and would both produce server-id 111.

So to fix that, I seperate the IP and multiply the 3rd digit by a 1000.

$serverid = inline_template(‘<%= scope.lookupvar(\’::ipaddress\’).split(\’.\’)[2].to_i * 1000 + scope.lookupvar(\’::ipaddress\’).split(\’.\’)[3].to_i %>’)