Permalink
Browse files

Redid and simplified apache module

  • Loading branch information...
0 parents commit 28871d8e852a6acd4662b479de72112acfd917ca @ohadlevy ohadlevy committed Sep 21, 2011
Showing with 93 additions and 0 deletions.
  1. +26 −0 manifests/config.pp
  2. +6 −0 manifests/init.pp
  3. +3 −0 manifests/install.pp
  4. +5 −0 manifests/params.pp
  5. +14 −0 manifests/service.pp
  6. +12 −0 manifests/site.pp
  7. +16 −0 manifests/ssl.pp
  8. +11 −0 templates/vhost.conf
26 manifests/config.pp
@@ -0,0 +1,26 @@
+class apache::config {
+
+ group { $apache::params::group: ensure => present, require => Class["apache::install"] }
+ user { $apache::params::user:
+ ensure => present,
+ home => $apache::params::home,
+ managehome => false,
+ membership => minimum,
+ groups => [],
+ shell => "/sbin/nologin",
+ require => Group[$apache::params::group],
+ }
+
+ file{
+ "/etc/httpd/conf/httpd.conf":
+ mode => 0644,
+ notify => Exec["reload-apache"],
+ require => Class["apache::install"];
+ "/etc/httpd/conf.d":
+ ensure => directory,
+ mode => 0644,
+ notify => Exec["reload-apache"],
+ require => Class["apache::install"],
+ }
+
+}
6 manifests/init.pp
@@ -0,0 +1,6 @@
+class apache {
+ include apache::params
+ include apache::install
+ include apache::config
+ include apache::service
+}
3 manifests/install.pp
@@ -0,0 +1,3 @@
+class apache::install {
+ package { "httpd": ensure => installed}
+}
5 manifests/params.pp
@@ -0,0 +1,5 @@
+class apache::params {
+ $user = "apache"
+ $group = "apache"
+ $home = "/var/www"
+}
14 manifests/service.pp
@@ -0,0 +1,14 @@
+class apache::service {
+ service { "httpd":
+ ensure => running, enable => true, hasstatus => true, hasrestart => true,
+ subscribe => Package["httpd"]
+ }
+
+ exec { "reload-apache":
+ command => "/etc/init.d/httpd reload",
+ onlyif => "/usr/sbin/apachectl -t",
+ require => Service["httpd"],
+ refreshonly => true,
+ }
+
+}
12 manifests/site.pp
@@ -0,0 +1,12 @@
+define apache::site( $admin = "webmaster", $aliases = '', $docroot, $ensure = 'present', $rails = false) {
+ if $rails { include passenger }
+
+ file { "/etc/httpd/conf.d/$name.conf":
+ mode => "644",
+ ensure => $ensure,
+ require => Package["httpd"],
+ notify => Exec["reload-apache"],
+ content => template("apache/vhost.conf"),
+ }
+}
+
16 manifests/ssl.pp
@@ -0,0 +1,16 @@
+class apache::ssl {
+ include apache
+ package { [ "mod_ssl" , "mod_authz_ldap" ]:
+ ensure => present, require => Package["httpd"],
+ notify => Class["apache::service"],
+ }
+ file {
+ "/etc/httpd/conf.d/ssl.conf":
+ mode => 0644, owner => root, group => root,
+ notify => Exec["reload-apache"];
+ ["/var/cache/mod_ssl", "/var/cache/mod_ssl/scache"]:
+ ensure => directory,
+ owner => apache, group => root, mode => 0700,
+ notify => Exec["reload-apache"];
+ }
+}
11 templates/vhost.conf
@@ -0,0 +1,11 @@
+<VirtualHost <%= "#{name}.#{domain}" %>:80>
+ServerAdmin <%= admin %>
+DocumentRoot <%= docroot %>
+ServerName <%= name %>
+<% aliases.each do |al| -%>
+ServerAlias <%= al %>
+<% end -%>
+<% if rails -%>
+Railsautodetect on
+<% end -%>
+</VirtualHost>

0 comments on commit 28871d8

Please sign in to comment.