2

Hi there puppeters :),

I hope you can help me with a situation. Namely, I will use puppet to deploy many (I mean really many) nodes with Apache installed. The problem I have is that for now the only way to create a vhost with a specified ServerName is to issue the server name in the main puppetmaster file (site.pp). It looks something like this:

    case $::hostname {
            hostname1: {vhost_default { 'hostname1.domain': }}
            hostname2: {vhost_default { 'hostname2.domain': }}

Is there a way of creating a vhost file without having to issue the name. Meaning, that the puppetmaster reads the hostname and writes it by itself into the template. The template looks as follows (only the important part):

<VirtualHost *:80>
    ServerName <%= fqdn %>
    ServerAlias www.<%= fqdn %>

And the init.pp for apache with the template portion: define vhost_default() {

file { "/etc/apache2/sites-available/domain.conf":
    owner   => 'root',
    group   => 'root',
    mode    => 644,
    content => template( 'apache/default_vhost.erb' ),
    require => [ Package[ 'apache2' ] ]

Or can you maybe think of another way of deploying apache vhost files? (Maybe without ServerName directive?) Thanks in advance.

0 Answers0