Skip to content

Commit 0e254c0

Browse files
committed
reorg of modules based on best practice
0 parents  commit 0e254c0

File tree

20 files changed

+365
-0
lines changed

20 files changed

+365
-0
lines changed

Modulefile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name 'puppetlabs-apache'
2+
version '0.0.3'

REVISION

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module: puppetlabs/apache
2+
version: 0.0.3
3+
url: file:///Users/james/.puppet/var/puppet-module/cache/http_forge_puppetlabs_com-75a31f1d6f1ef6eb63b4479b3512ee1508209a7f/puppetlabs-apache-0.0.3.tar.gz
4+
installed: Fri Aug 05 09:49:43 -0500 2011

files/httpd

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Configuration file for the httpd service.
2+
3+
#
4+
# The default processing model (MPM) is the process-based
5+
# 'prefork' model. A thread-based model, 'worker', is also
6+
# available, but does not work with some modules (such as PHP).
7+
# The service must be stopped before changing this variable.
8+
#
9+
#HTTPD=/usr/sbin/httpd.worker
10+
11+
#
12+
# To pass additional options (for instance, -D definitions) to the
13+
# httpd binary at startup, set OPTIONS here.
14+
#
15+
#OPTIONS=
16+
#OPTIONS=-DDOWN
17+
18+
#
19+
# By default, the httpd process is started in the C locale; to
20+
# change the locale in which the server runs, the HTTPD_LANG
21+
# variable can be set.
22+
#
23+
#HTTPD_LANG=C
24+
export SHORTHOST=`hostname -s`

files/test.vhost

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
# Test vhost
3+
#
4+
NameVirtualHost *:80
5+
<VirtualHost *:80>
6+
ServerName testvhost
7+
DocumentRoot /tmp/testvhost
8+
<Directory /tmp/testvhost>
9+
Options Indexes FollowSymLinks MultiViews
10+
AllowOverride None
11+
Order allow,deny
12+
allow from all
13+
</Directory>
14+
ErrorLog /var/log/apache2/error.log
15+
LogLevel warn
16+
CustomLog /var/log/apache2/access.log combined
17+
ServerSignature On
18+
</VirtualHost>

lib/puppet/provider/a2mod/a2mod.rb

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Puppet::Type.type(:a2mod).provide(:a2mod) do
2+
desc "Manage Apache 2 modules on Debian and Ubuntu"
3+
4+
commands :encmd => "a2enmod"
5+
commands :discmd => "a2dismod"
6+
7+
defaultfor :operatingsystem => [:debian, :ubuntu]
8+
9+
def create
10+
encmd resource[:name]
11+
end
12+
13+
def destroy
14+
discmd resource[:name]
15+
end
16+
17+
def exists?
18+
mod= "/etc/apache2/mods-enabled/" + resource[:name] + ".load"
19+
File.exists?(mod)
20+
end
21+
end

lib/puppet/type/a2mod.rb

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Puppet::Type.newtype(:a2mod) do
2+
@doc = "Manage Apache 2 modules on Debian and Ubuntu"
3+
4+
ensurable
5+
6+
newparam(:name) do
7+
desc "The name of the module to be managed"
8+
9+
isnamevar
10+
11+
end
12+
end

manifests/dev.pp

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Class: apache::dev
2+
#
3+
# This class installs Apache development libraries
4+
#
5+
# Parameters:
6+
#
7+
# Actions:
8+
# - Install Apache development libraries
9+
#
10+
# Requires:
11+
#
12+
# Sample Usage:
13+
#
14+
class apache::dev {
15+
include apache::params
16+
17+
package{$apache::params::apache_dev: ensure => installed}
18+
}

manifests/init.pp

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Class: apache
2+
#
3+
# This class installs Apache
4+
#
5+
# Parameters:
6+
#
7+
# Actions:
8+
# - Install Apache
9+
# - Manage Apache service
10+
#
11+
# Requires:
12+
#
13+
# Sample Usage:
14+
#
15+
class apache {
16+
include apache::params
17+
package { 'httpd':
18+
name => $apache::params::apache_name,
19+
ensure => present,
20+
}
21+
service { 'httpd':
22+
name => $apache::params::apache_name,
23+
ensure => running,
24+
enable => true,
25+
subscribe => Package['httpd'],
26+
}
27+
#
28+
# May want to purge all none realize modules using the resources resource type.
29+
#
30+
A2mod { require => Package['httpd'], notify => Service['httpd']}
31+
@a2mod {
32+
'rewrite' : ensure => present;
33+
'headers' : ensure => present;
34+
'expires' : ensure => present;
35+
}
36+
37+
38+
file { $apache::params::vdir:
39+
ensure => directory,
40+
recurse => true,
41+
purge => true,
42+
notify => Service['httpd'],
43+
}
44+
}

manifests/params.pp

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Class: apache::params
2+
#
3+
# This class manages Apache parameters
4+
#
5+
# Parameters:
6+
# - The $user that Apache runs as
7+
# - The $group that Apache runs as
8+
# - The $apache_name is the name of the package and service on the relevant distribution
9+
# - The $php_package is the name of the package that provided PHP
10+
# - The $ssl_package is the name of the Apache SSL package
11+
# - The $apache_dev is the name of the Apache development libraries package
12+
#
13+
# Actions:
14+
#
15+
# Requires:
16+
#
17+
# Sample Usage:
18+
#
19+
class apache::params {
20+
21+
$user = 'www-data'
22+
$group = 'www-data'
23+
24+
case $operatingsystem {
25+
'centos', 'redhat', 'fedora': {
26+
$apache_name = 'httpd'
27+
$php_package = 'php'
28+
$ssl_package = 'mod_ssl'
29+
$apache_dev = 'httpd-devel'
30+
$vdir = '/etc/httpd/conf.d/'
31+
}
32+
'ubuntu', 'debian': {
33+
$apache_name = 'apache2'
34+
$php_package = 'libapache2-mod-php5'
35+
$ssl_package = 'apache-ssl'
36+
$apache_dev = [ 'libaprutil1-dev', 'libapr1-dev', 'apache2-prefork-dev' ]
37+
$vdir = '/etc/apache2/sites-enabled/'
38+
}
39+
default: {
40+
$apache_name = 'apache2'
41+
$php_package = 'libapache2-mod-php5'
42+
$ssl_package = 'apache-ssl'
43+
$apache_dev = 'apache-dev'
44+
$vdir = '/etc/apache2/sites-enabled/'
45+
}
46+
}
47+
}

manifests/php.pp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Class: apache::php
2+
#
3+
# This class installs PHP for Apache
4+
#
5+
# Parameters:
6+
# - $php_package
7+
#
8+
# Actions:
9+
# - Install Apache PHP package
10+
#
11+
# Requires:
12+
#
13+
# Sample Usage:
14+
#
15+
class apache::php {
16+
17+
include apache::params
18+
19+
package { $apache::params::php_package:
20+
ensure => present,
21+
}
22+
}

manifests/ssl.pp

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Class: apache::ssl
2+
#
3+
# This class installs Apache SSL capabilities
4+
#
5+
# Parameters:
6+
# - The $ssl_package name from the apache::params class
7+
#
8+
# Actions:
9+
# - Install Apache SSL capabilities
10+
#
11+
# Requires:
12+
#
13+
# Sample Usage:
14+
#
15+
class apache::ssl {
16+
17+
include apache
18+
19+
case $operatingsystem {
20+
'centos', 'fedora', 'redhat': {
21+
package { $apache::params::ssl_package:
22+
require => Package['httpd'],
23+
}
24+
}
25+
'ubuntu', 'debian': {
26+
a2mod { "ssl": ensure => present, }
27+
}
28+
}
29+
}

manifests/vhost.pp

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Definition: apache::vhost
2+
#
3+
# This class installs Apache Virtual Hosts
4+
#
5+
# Parameters:
6+
# - The $port to configure the host on
7+
# - The $docroot provides the DocumentationRoot variable
8+
# - The $ssl option is set true or false to enable SSL for this Virtual Host
9+
# - The $template option specifies whether to use the default template or override
10+
# - The $priority of the site
11+
# - The $serveraliases of the site
12+
#
13+
# Actions:
14+
# - Install Apache Virtual Hosts
15+
#
16+
# Requires:
17+
# - The apache class
18+
#
19+
# Sample Usage:
20+
# apache::vhost { 'site.name.fqdn':
21+
# priority => '20',
22+
# port => '80',
23+
# docroot => '/path/to/docroot',
24+
# }
25+
#
26+
define apache::vhost( $port, $docroot, $ssl=true, $template='apache/vhost-default.conf.erb', $priority, $serveraliases = '' ) {
27+
28+
include apache
29+
30+
file {"${apache::params::vdir}/${priority}-${name}.conf":
31+
content => template($template),
32+
owner => 'root',
33+
group => 'root',
34+
mode => '777',
35+
require => Package['httpd'],
36+
notify => Service['httpd'],
37+
}
38+
}

metadata.json

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "puppetlabs-apache",
3+
"dependencies": [
4+
5+
],
6+
"author": "",
7+
"license": "",
8+
"version": "0.0.3",
9+
"checksums": {
10+
"tests/ssl.pp": "191912535199531fd631f911c6329e56",
11+
"manifests/params.pp": "8728cf041cdd94bb0899170eb2b417d9",
12+
"tests/vhost.pp": "1b91e03c8ef89a7ecb6793831ac18399",
13+
"manifests/php.pp": "8a5ca4035b1c22892923f3fde55e3d5e",
14+
"lib/puppet/provider/a2mod/a2mod.rb": "18c5bb180b75a2375e95e07f88a94257",
15+
"tests/php.pp": "ce7bb9eef69d32b42a32ce32d9653625",
16+
"files/httpd": "295f5e924afe6f752d29327e73fe6d0a",
17+
"manifests/dev.pp": "bc54a5af648cb04b7b3bb0e3f7be6543",
18+
"manifests/ssl.pp": "11ed1861298c72cca3a706480bb0b67c",
19+
"files/test.vhost": "0602022c19a7b6b289f218c7b93c1aea",
20+
"tests/init.pp": "4eac4a7ef68499854c54a78879e25535",
21+
"manifests/vhost.pp": "7806a6c098e217da046d0555314756c4",
22+
"lib/puppet/type/a2mod.rb": "0e1b4843431413a10320ac1f6a055d15",
23+
"templates/vhost-default.conf.erb": "ed64a53af0d7bad762176a98c9ea3e62",
24+
"tests/dev.pp": "4cf15c1fecea3ca86009f182b402c7ab",
25+
"tests/apache.pp": "4eac4a7ef68499854c54a78879e25535",
26+
"Modulefile": "9b7a414bf15b06afe2f011068fcaff52",
27+
"manifests/init.pp": "9ef7e081c832bca8f861c3a9feb9949d"
28+
},
29+
"types": [
30+
{
31+
"name": "a2mod",
32+
"doc": "Manage Apache 2 modules on Debian and Ubuntu",
33+
"parameters": [
34+
{
35+
"name": "name",
36+
"doc": "The name of the module to be managed"
37+
}
38+
],
39+
"providers": [
40+
{
41+
"name": "a2mod",
42+
"doc": "Manage Apache 2 modules on Debian and Ubuntu Required binaries: ``a2enmod``, ``a2dismod``. Default for ``operatingsystem`` == ``debianubuntu``. "
43+
}
44+
],
45+
"properties": [
46+
{
47+
"name": "ensure",
48+
"doc": "The basic property that the resource should be in. Valid values are ``present``, ``absent``."
49+
}
50+
]
51+
}
52+
],
53+
"source": ""
54+
}

templates/vhost-default.conf.erb

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# ************************************
2+
# Default template in module puppetlabs-apache
3+
# Managed by Puppet
4+
# ************************************
5+
6+
NameVirtualHost *:<%= port %>
7+
<VirtualHost *:<%= port %>>
8+
ServerName <%= name %>
9+
<%if serveraliases.is_a? Array -%>
10+
<% serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%>
11+
<% elsif serveraliases != '' -%>
12+
<%= " ServerAlias #{serveraliases}" -%>
13+
<% end -%>
14+
DocumentRoot <%= docroot %>
15+
<Directory <%= docroot %>>
16+
Options Indexes FollowSymLinks MultiViews
17+
AllowOverride None
18+
Order allow,deny
19+
allow from all
20+
</Directory>
21+
ErrorLog /var/log/httpd/<%= name %>_error.log
22+
LogLevel warn
23+
CustomLog /var/log/httpd/<%= name %>_access.log combined
24+
ServerSignature On
25+
</VirtualHost>

tests/apache.pp

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include apache

tests/dev.pp

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include apache::dev

tests/init.pp

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include apache

tests/php.pp

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include apache::php

tests/ssl.pp

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include apache::ssl

tests/vhost.pp

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include apache
2+
apache::vhost { 'test.vhost': source => 'puppet:///modules/apache/test.vhost' }

0 commit comments

Comments
 (0)