Creator of this small website
Jan 27, 2010 1 min read

Put your ruby in my ERB

Today I started installing a reverse proxy at $WORK. I choose to follow this way, and all my DNS data is stored in my CMDB. Once again, the solution came from #puppet ! You can embed some “pure” ruby code in ERB templates. And, yes, you can query your database !

dbh = DBI.connect("", "you", "XXXX")
query = dbh.prepare("your fancy query")
while row = query.fetch do
<%= todisplay %>
<% end %>

I use this technique to generate the dnsmasq data file. Just use the subscribe function and all is done !