Jon Davis
2011-Nov-16 03:26 UTC
[Puppet Users] lighttpd / modifying variables in templates?
I''m trying to get puppet to manage my lighttpd install, but I use vhosts. The line I''d normally use is something like this: $HTTP["host"] =~ "site\.example\.tld" { server.document-root = "/var/www/site.example.tld" accesslog.filename = "/var/log/lighttpd/ site.example.tld-access.log" } I would like to be able to pass the template a single variable, the domain name, and have it inserted into the 3 locations above. The only problem is the first one needs to have the escape characters inserted. Is there anyway to modify the variable in the template to add those slashes or am I stuck passing the information in twice? Thanks -- Jon [[User:ShakataGaNai]] / KJ6FNQ http://snowulf.com/ http://www.linkedin.com/in/shakataganai <http://twitter.com/shakataganai> -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Felix Frank
2011-Dec-02 08:57 UTC
Re: [Puppet Users] lighttpd / modifying variables in templates?
Hi, you can use this function: http://ruby-doc.org/core-1.8.7/String.html#method-i-gsub Untested template code: $HTTP["host"] =~ "<%= domain.gsub(/\./, ''\.'') %>" { server.document-root = "/var/www/<%= domain %>" accesslog.filename = "/var/log/lighttpd/<%= domain%>-access.log" } HTH, Felix On 11/16/2011 04:26 AM, Jon Davis wrote:> I''m trying to get puppet to manage my lighttpd install, but I use > vhosts. The line I''d normally use is something like this: > > $HTTP["host"] =~ "site\.example\.tld" { > server.document-root = "/var/www/site.example.tld" > accesslog.filename > "/var/log/lighttpd/site.example.tld-access.log" > } > > > I would like to be able to pass the template a single variable, the > domain name, and have it inserted into the 3 locations above. The only > problem is the first one needs to have the escape characters inserted. > Is there anyway to modify the variable in the template to > add those slashes or am I stuck passing the information in twice? > > Thanks-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.