Try something like this to extract the \d from the hostname:
<% id = fqdn.dup %>
<% id.gsub!(/db(\d).domain.ext/){$1} %>
server-id = <%= id %>


On 09/15/2015 03:59 PM, Tim Dunphy wrote:
Hey guys,

 Is there any other way to automate this setting in my.cnf:

server-id=1

So that if the host is db1 it'll get a value of 1, for db2 a value of 2, for db3 a value of 3 and db4 a value of 4?

The only way I can think of this is to have branching logic in the puppet manifest that does a test on the $hostname fact. But then you'd have to have 4 files corresponding to each host.

But I'd like to find a way to get this to happen automatically using templates.

I'm already setting up the SSL certs for the DB servers using the fqdn fact like this:

ssl-cert=/opt/mysql/<%= fqdn %>.crt
ssl-key=/opt/mysql/<%= fqdn %>.key


I'm looking for a way to just have one my.cnf template for all 4 db hosts that automatically assigns the right value to server-id the way I describe above.

Any suggestions that could allow for that would be very welcome!

Thanks,
Tim

--
GPG me!!

gpg --keyserver pool.sks-keyservers.net <http://pool.sks-keyservers.net> --recv-keys F186197B

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com <mailto:puppet-users+unsubscr...@googlegroups.com>. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CAOZy0ekzV%2B8PAHjHVMiVmWS6%3DvXo2FNLpGowtWu-%2B-qCFKe6Tg%40mail.gmail.com <https://groups.google.com/d/msgid/puppet-users/CAOZy0ekzV%2B8PAHjHVMiVmWS6%3DvXo2FNLpGowtWu-%2B-qCFKe6Tg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/55F87A47.9010808%40ias.edu.
For more options, visit https://groups.google.com/d/optout.

Reply via email to