Puppet: Referencing variables from a define in a template

Solution 1:

Something like this in $template.erb:

<VirtualHost <%= ip %>:443>
  Document Root <%= docroot %>
  SSLCertificateFile <%= cert %>
  # ...
</VirtualHost>

That is, any variable in puppet is available as a local variable in the ruby bits hiding in the .erb file.

Not sure why you have "$template" instead of a named .erb file (not seeing $template set anywhere, but willing to assume it's hiding somewhere)

And this seems wrong: cert => Openssl::Cert["rri"]. I'd expect something more like:

openssl::cert { "rri": }

And then the .erb would be more like:

<VirtualHost <%= ip %>:443>
  Document Root <%= docroot %>
  SSLCertificateFile <%= certDirectory %>/<%= name %>
  # ...
</VirtualHost>