I am running Puppet 2.6.4, and have run into a situation where I would like to use conditional statements inside a template ERB file. I am trying to deploy apache virtual host configuration files, and have found that certain environments use SSL certificate files from one vendor and other environments use different formatted certificates from another vendor. I would like to avoid maintaining two versions of virtual host files and would prefer to use a single template file with conditional logic using tags to decide which lines to use. When I test the syntax of the Template I get Syntax OK. When I try to run the run the catalog I get the following error:
puppet-agent[6010]: Could not retrieve catalog from remote server: Error 400 on SERVER: Failed to parse template foobar/vhost.conf.erb: Could not find value for 'development' at /etc/puppet/modules/foobar/manifests/vhost-conf.pp:6 on node
www.example.com
Here is the snippet from my vhost.erb
.....
Alias /js /var/www/html/<%= hostname %>/static/js
Alias /video /var/www/html/<%= hostname %>/static/video
Alias /pdf /var/www/html/<%= hostname %>/static/pdf
SSLEngine on
<% if tagged(development) %>
SSLCertificateFile /etc/pki/tls/certs/<%= hostname %>.pem
SSLCertificateKeyFile /etc/pki/tls/certs/<%= hostname %>.pem
<% else tagged(testing) %>
SSLCertificateFile /etc/pki/tls/certs/<%= hostname %>.crt
SSLCertificateKeyFile /etc/pki/tls/private/<%= hostname %>.key
SSLCertificateChainFile /etc/pki/tls/certs/<%= hostname %>_bundle.crt
<% end %>
</VirtualHost>
Any thoughts would be greatly appreciated. Also is it possible to use if else statements as well?
Cheers,
DK