Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
James Turnbull committed Sep 1, 2010
0 parents commit 35721a3
Show file tree
Hide file tree
Showing 58 changed files with 1,023 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Modulefile
@@ -0,0 +1,2 @@
name 'puppetlabs-apache'
version '0.0.3'
24 changes: 24 additions & 0 deletions files/httpd
@@ -0,0 +1,24 @@
# Configuration file for the httpd service.

#
# The default processing model (MPM) is the process-based
# 'prefork' model. A thread-based model, 'worker', is also
# available, but does not work with some modules (such as PHP).
# The service must be stopped before changing this variable.
#
#HTTPD=/usr/sbin/httpd.worker

#
# To pass additional options (for instance, -D definitions) to the
# httpd binary at startup, set OPTIONS here.
#
#OPTIONS=
#OPTIONS=-DDOWN

#
# By default, the httpd process is started in the C locale; to
# change the locale in which the server runs, the HTTPD_LANG
# variable can be set.
#
#HTTPD_LANG=C
export SHORTHOST=`hostname -s`
18 changes: 18 additions & 0 deletions files/test.vhost
@@ -0,0 +1,18 @@
#
# Test vhost
#
NameVirtualHost *:80
<VirtualHost *:80>
ServerName testvhost
DocumentRoot /tmp/testvhost
<Directory /tmp/testvhost>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
21 changes: 21 additions & 0 deletions lib/puppet/provider/a2mod/a2mod.rb
@@ -0,0 +1,21 @@
Puppet::Type.type(:a2mod).provide(:a2mod) do
desc "Manage Apache 2 modules on Debian and Ubuntu"

commands :encmd => "a2enmod"
commands :discmd => "a2dismod"

defaultfor :operatingsystem => [:debian, :ubuntu]

def create
encmd resource[:name]
end

def destroy
discmd resource[:name]
end

def exists?
mod= "/etc/apache2/mods-enabled/" + resource[:name] + ".load"
File.exists?(mod)
end
end
12 changes: 12 additions & 0 deletions lib/puppet/type/a2mod.rb
@@ -0,0 +1,12 @@
Puppet::Type.newtype(:a2mod) do
@doc = "Manage Apache 2 modules on Debian and Ubuntu"

ensurable

newparam(:name) do
desc "The name of the module to be managed"

isnamevar

end
end
18 changes: 18 additions & 0 deletions manifests/dev.pp
@@ -0,0 +1,18 @@
# Class: apache::dev
#
# This class installs Apache development libraries
#
# Parameters:
#
# Actions:
# - Install Apache development libraries
#
# Requires:
#
# Sample Usage:
#
class apache::dev {
include apache::params

package{$apache::params::apache_dev: ensure => installed}
}
44 changes: 44 additions & 0 deletions manifests/init.pp
@@ -0,0 +1,44 @@
# Class: apache
#
# This class installs Apache
#
# Parameters:
#
# Actions:
# - Install Apache
# - Manage Apache service
#
# Requires:
#
# Sample Usage:
#
class apache {
include apache::params
package { 'httpd':
name => $apache::params::apache_name,
ensure => present,
}
service { 'httpd':
name => $apache::params::apache_name,
ensure => running,
enable => true,
subscribe => Package['httpd'],
}
#
# May want to purge all none realize modules using the resources resource type.
#
A2mod { require => Package['httpd'], notify => Service['httpd']}
@a2mod {
'rewrite' : ensure => present;
'headers' : ensure => present;
'expires' : ensure => present;
}


file { $apache::params::vdir:
ensure => directory,
recurse => true,
purge => true,
notify => Service['httpd'],
}
}
47 changes: 47 additions & 0 deletions manifests/params.pp
@@ -0,0 +1,47 @@
# Class: apache::params
#
# This class manages Apache parameters
#
# Parameters:
# - The $user that Apache runs as
# - The $group that Apache runs as
# - The $apache_name is the name of the package and service on the relevant distribution
# - The $php_package is the name of the package that provided PHP
# - The $ssl_package is the name of the Apache SSL package
# - The $apache_dev is the name of the Apache development libraries package
#
# Actions:
#
# Requires:
#
# Sample Usage:
#
class apache::params {

$user = 'www-data'
$group = 'www-data'

case $operatingsystem {
'centos', 'redhat', 'fedora': {
$apache_name = 'httpd'
$php_package = 'php'
$ssl_package = 'mod_ssl'
$apache_dev = 'httpd-devel'
$vdir = '/etc/httpd/conf.d/'
}
'ubuntu', 'debian': {
$apache_name = 'apache2'
$php_package = 'libapache2-mod-php5'
$ssl_package = 'apache-ssl'
$apache_dev = [ 'libaprutil1-dev', 'libapr1-dev', 'apache2-prefork-dev' ]
$vdir = '/etc/apache2/sites-enabled/'
}
default: {
$apache_name = 'apache2'
$php_package = 'libapache2-mod-php5'
$ssl_package = 'apache-ssl'
$apache_dev = 'apache-dev'
$vdir = '/etc/apache2/sites-enabled/'
}
}
}
22 changes: 22 additions & 0 deletions manifests/php.pp
@@ -0,0 +1,22 @@
# Class: apache::php
#
# This class installs PHP for Apache
#
# Parameters:
# - $php_package
#
# Actions:
# - Install Apache PHP package
#
# Requires:
#
# Sample Usage:
#
class apache::php {

include apache::params

package { $apache::params::php_package:
ensure => present,
}
}
29 changes: 29 additions & 0 deletions manifests/ssl.pp
@@ -0,0 +1,29 @@
# Class: apache::ssl
#
# This class installs Apache SSL capabilities
#
# Parameters:
# - The $ssl_package name from the apache::params class
#
# Actions:
# - Install Apache SSL capabilities
#
# Requires:
#
# Sample Usage:
#
class apache::ssl {

include apache

case $operatingsystem {
'centos', 'fedora', 'redhat': {
package { $apache::params::ssl_package:
require => Package['httpd'],
}
}
'ubuntu', 'debian': {
a2mod { "ssl": ensure => present, }
}
}
}
38 changes: 38 additions & 0 deletions manifests/vhost.pp
@@ -0,0 +1,38 @@
# Definition: apache::vhost
#
# This class installs Apache Virtual Hosts
#
# Parameters:
# - The $port to configure the host on
# - The $docroot provides the DocumentationRoot variable
# - The $ssl option is set true or false to enable SSL for this Virtual Host
# - The $template option specifies whether to use the default template or override
# - The $priority of the site
# - The $serveraliases of the site
#
# Actions:
# - Install Apache Virtual Hosts
#
# Requires:
# - The apache class
#
# Sample Usage:
# apache::vhost { 'site.name.fqdn':
# priority => '20',
# port => '80',
# docroot => '/path/to/docroot',
# }
#
define apache::vhost( $port, $docroot, $ssl=true, $template='apache/vhost-default.conf.erb', $priority, $serveraliases = '' ) {

include apache

file {"${apache::params::vdir}/${priority}-${name}":
content => template($template),
owner => 'root',
group => 'root',
mode => '777',
require => Package['httpd'],
notify => Service['httpd'],
}
}
Binary file added pkg/puppetlabs-apache-0.0.2.tar.gz
Binary file not shown.
2 changes: 2 additions & 0 deletions pkg/puppetlabs-apache-0.0.2/Modulefile
@@ -0,0 +1,2 @@
name 'puppetlabs-apache'
version '0.0.2'
24 changes: 24 additions & 0 deletions pkg/puppetlabs-apache-0.0.2/files/httpd
@@ -0,0 +1,24 @@
# Configuration file for the httpd service.

#
# The default processing model (MPM) is the process-based
# 'prefork' model. A thread-based model, 'worker', is also
# available, but does not work with some modules (such as PHP).
# The service must be stopped before changing this variable.
#
#HTTPD=/usr/sbin/httpd.worker

#
# To pass additional options (for instance, -D definitions) to the
# httpd binary at startup, set OPTIONS here.
#
#OPTIONS=
#OPTIONS=-DDOWN

#
# By default, the httpd process is started in the C locale; to
# change the locale in which the server runs, the HTTPD_LANG
# variable can be set.
#
#HTTPD_LANG=C
export SHORTHOST=`hostname -s`
18 changes: 18 additions & 0 deletions pkg/puppetlabs-apache-0.0.2/files/test.vhost
@@ -0,0 +1,18 @@
#
# Test vhost
#
NameVirtualHost *:80
<VirtualHost *:80>
ServerName testvhost
DocumentRoot /tmp/testvhost
<Directory /tmp/testvhost>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
21 changes: 21 additions & 0 deletions pkg/puppetlabs-apache-0.0.2/lib/puppet/provider/a2mod/a2mod.rb
@@ -0,0 +1,21 @@
Puppet::Type.type(:a2mod).provide(:a2mod) do
desc "Manage Apache 2 modules on Debian and Ubuntu"

commands :encmd => "a2enmod"
commands :discmd => "a2dismod"

defaultfor :operatingsystem => [:debian, :ubuntu]

def create
encmd resource[:name]
end

def destroy
discmd resource[:name]
end

def exists?
mod= "/etc/apache2/mods-enabled/" + resource[:name] + ".load"
File.exists?(mod)
end
end
12 changes: 12 additions & 0 deletions pkg/puppetlabs-apache-0.0.2/lib/puppet/type/a2mod.rb
@@ -0,0 +1,12 @@
Puppet::Type.newtype(:a2mod) do
@doc = "Manage Apache 2 modules on Debian and Ubuntu"

ensurable

newparam(:name) do
desc "The name of the module to be managed"

isnamevar

end
end
18 changes: 18 additions & 0 deletions pkg/puppetlabs-apache-0.0.2/manifests/dev.pp
@@ -0,0 +1,18 @@
# Class: apache::dev
#
# This class installs Apache development libraries
#
# Parameters:
#
# Actions:
# - Install Apache development libraries
#
# Requires:
#
# Sample Usage:
#
class apache::dev {
include apache::params

package{$apache::params::apache_dev: ensure => installed}
}

0 comments on commit 35721a3

Please sign in to comment.