apache vhosts in puppet

1,636 views
Skip to first unread message

Tim Dunphy

unread,
Mar 2, 2011, 7:58:12 PM3/2/11
to puppet...@googlegroups.com
hello puppet list!!

I sincerely appreciate your help in the past and hope you don't mind
me bouncing this scenario off of you. I am attempting to define apache
vhosts with a puppet module but things are not going according to plan
at the moment


## error


[root@kromep1 ~]# puppetd --test
info: Caching catalog for kromep1.example.net
err: Could not run Puppet configuration client: Could not find
dependent Service[httpd] for
File[/etc/httpd/conf.d/web1.ops.example.com.conf] at
/etc/puppet/modules/apache/manifests/virtual_host.pp:11

## /etc/puppet/modules/apache/init.pp

class apache {

$packagelist = ["httpd","webalizer","mod_ssl"]

package { $packagelist:
ensure => "installed"
}

apache::apache_files {
"/etc/httpd/conf/httpd.conf":
source => "puppet:///apache/httpd.conf"
}

service { "httpd":
enable => "true",
ensure => "running",
hasrestart => "true",
hasstatus => "true",
require => Package["httpd"]
}

}


## /etc/puppet/modules/apache/manifests/virtual_host.pp


define apache::virtual_host($ip, $ensure = "enabled") {
$file = "/etc/httpd/conf.d/$name.conf"
$document_root = "/var/www/html/$name"

file { $file:
ensure => $ensure ? {
enabled => present,
disabled => absent },
content => template("apache/virtual_host.erb"),
notify => Service["httpd"]
}

file { $document_root:
ensure => $ensure ? {
enabled => directory,
disabled => absent },
require => File["$file"]
}
}

# /etc/puppet/modules/apache/templates/virutal_host.erb

<VirtualHost <%= ip %>>
DocumentRoot <%= document_root %>
ServerName <%= name %>
</VirtualHost>

## /etc/puppet/manifests/nodes.pp

node 'mclient.example.net' inherits webserver {
}


node 'kromep1.example.net' inherits mailserver {
apache::virtual_host { "ext-kromep1.ops.example.com":
ip => "50.xx.xxx.255"
}
apache::virtual_host { "web1.ops.example.com":
ip => "50.xx.xxx.255"
}
}
node 'kromep2.example.net' inherits webserver {
apache::virtual_host { "web2.ops.example.com":
ip => "174.xx.xxx.60"
}


}
node 'kromedb1.example.net' inherits dbserver {
}


I would like to take this opportunity to thank you again. the puppet
community has been amazing!! all help that has been rendered and any
that may be is sincerely appreciated!

tim

--
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B

Matthew Black

unread,
Mar 2, 2011, 11:28:08 PM3/2/11
to puppet...@googlegroups.com
looks like you're not including the apache class, which has the definition that puppet is complaining about.


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


Tim Dunphy

unread,
Mar 3, 2011, 3:36:38 PM3/3/11
to puppet...@googlegroups.com
Hi Matthew,

Thank you for your input. What I did was add an include apache
statement to the /etc/puppet/modules/apache/manifests/virtual_host.pp
file and that got this working!

define apache::virtual_host($ip, $ensure = "enabled") {

include apache


$file = "/etc/httpd/conf.d/$name.conf"
$document_root = "/var/www/html/$name"

file { $file:
ensure => $ensure ? {
enabled => present,
disabled => absent },
content => template("apache/virtual_host.erb"),
notify => Service["httpd"]
}

file { $document_root:
ensure => $ensure ? {
enabled => directory,
disabled => absent },
require => File["$file"]
}
}


Again sincere thanks the puppet community is incredibly helpful!

TIm

Reply all
Reply to author
Forward
0 new messages