Initial version of apache::server.
This commit is contained in:
parent
130b585eea
commit
819265f038
3 changed files with 1118 additions and 2 deletions
|
@ -1,7 +1,19 @@
|
|||
|
||||
# Install www logrotate script and cron job.
|
||||
# Install Apache, www logrotate script and cron job.
|
||||
#
|
||||
class apache::logrotate {
|
||||
class apache::common {
|
||||
|
||||
file { [ "/srv/www",
|
||||
"/srv/www/log", ]:
|
||||
ensure => directory,
|
||||
mode => 0755,
|
||||
owner => root,
|
||||
group => root,
|
||||
}
|
||||
|
||||
package { "httpd":
|
||||
ensure => installed,
|
||||
}
|
||||
|
||||
file { "/usr/local/sbin/www-logrotate.sh":
|
||||
ensure => present,
|
||||
|
@ -22,3 +34,107 @@ class apache::logrotate {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Configure HTTP server.
|
||||
#
|
||||
class apache::server inherits apache::common {
|
||||
|
||||
file { [ "/etc/httpd/conf.http.d",
|
||||
"/etc/httpd/site.http.d",
|
||||
"/srv/www/http",
|
||||
"/srv/www/http/${fqdn}",
|
||||
"/srv/www/log/http",
|
||||
"/srv/www/log/http/${fqdn}", ]:
|
||||
ensure => directory,
|
||||
mode => 0755,
|
||||
owner => root,
|
||||
group => root,
|
||||
require => Package["httpd"],
|
||||
before => File["/etc/httpd/conf/httpd.conf"],
|
||||
}
|
||||
|
||||
file { "/etc/httpd/conf/httpd.conf":
|
||||
ensure => present,
|
||||
content => template("apache/httpd.conf.erb"),
|
||||
require => Package["httpd"],
|
||||
notify => Service["httpd"],
|
||||
}
|
||||
|
||||
service { "httpd":
|
||||
ensure => running,
|
||||
enable => true,
|
||||
require => [ Package["httpd"],
|
||||
File["/etc/httpd/conf/httpd.conf"], ],
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Configure HTTP virtual host.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# $name:
|
||||
# FQDN of virtual host.
|
||||
# $site_root:
|
||||
# Path to document root. Defaults to /srv/www/http/$fqdn
|
||||
# $site_conf:
|
||||
# Path to custom configuration file. Defaults to a basic template.
|
||||
#
|
||||
# === Sample usage
|
||||
#
|
||||
# apache::site { "www.example.com":
|
||||
# site_root => "/roles/prteam/public/public_access",
|
||||
# site_conf => "puppet:///path/to/www.example.com.conf",
|
||||
# }
|
||||
#
|
||||
define apache::site($site_root="none", $site_conf="none") {
|
||||
|
||||
if $name == "default" {
|
||||
$site_fqdn = $fqdn
|
||||
} else {
|
||||
$site_fqdn = $name
|
||||
|
||||
if $site_root == "none" {
|
||||
file { "/srv/www/http/${site_fqdn}":
|
||||
ensure => directory,
|
||||
mode => 0755,
|
||||
owner => root,
|
||||
group => root,
|
||||
before => File["/etc/httpd/site.http.d/${site_fqdn}.conf"],
|
||||
}
|
||||
} else {
|
||||
file { "/srv/www/http/${site_fqdn}":
|
||||
ensure => link,
|
||||
target => "${site_root}",
|
||||
before => File["/etc/httpd/site.http.d/${site_fqdn}.conf"],
|
||||
}
|
||||
}
|
||||
|
||||
file { "/srv/www/log/http/${site_fqdn}":
|
||||
ensure => directory,
|
||||
mode => 0755,
|
||||
owner => root,
|
||||
group => root,
|
||||
before => File["/etc/httpd/site.http.d/${site_fqdn}.conf"],
|
||||
}
|
||||
}
|
||||
|
||||
file { "/etc/httpd/site.http.d/${site_fqdn}.conf":
|
||||
ensure => present,
|
||||
notify => Service["httpd"],
|
||||
}
|
||||
|
||||
if $site_conf == "none" {
|
||||
File["/etc/httpd/site.http.d/${site_fqdn}.conf"] {
|
||||
content => template("apache/site.http.conf.erb"),
|
||||
}
|
||||
} else {
|
||||
File["/etc/httpd/site.http.d/${site_fqdn}.conf"] {
|
||||
source => "${site_conf}",
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue