On Tue, Feb 28, 2012 at 5:06 AM, Danijel Krmar <[email protected]> wrote:

> 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' ] ]
>
> Thanks in advance.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>
>
You might want to use a parametrized class instead of the define, there is
a discussion in removing or not from future puppet releases[1]

so instead of the:
define vhost_default() {

you will have:
class vhost($name) {

And you will make reference to it as
class { "vhost": name => $fqdn }

You can put this into another more generic class and just include in your
node reference.
class vhost_default {
  class { "vhost": name => $fqdn }
}

node foo {
  include vhost_default
}

[1]
http://groups.google.com/group/puppet-users/browse_thread/thread/627731283dcc4a6b/f37ab68fa1797e6b

-- 
Tony
http://blog.tonyskapunk.net

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to