commit 35721a3f352531f53264fb08f2d4a7f7bab11712 Author: James Turnbull Date: Wed Sep 1 18:01:04 2010 -0400 Initial commit diff --git a/Modulefile b/Modulefile new file mode 100644 index 0000000..5963ae3 --- /dev/null +++ b/Modulefile @@ -0,0 +1,2 @@ +name 'puppetlabs-apache' +version '0.0.3' diff --git a/files/httpd b/files/httpd new file mode 100644 index 0000000..d65a8d4 --- /dev/null +++ b/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` diff --git a/files/test.vhost b/files/test.vhost new file mode 100644 index 0000000..ec9c811 --- /dev/null +++ b/files/test.vhost @@ -0,0 +1,18 @@ +# +# Test vhost +# +NameVirtualHost *:80 + + ServerName testvhost + DocumentRoot /tmp/testvhost + + Options Indexes FollowSymLinks MultiViews + AllowOverride None + Order allow,deny + allow from all + + ErrorLog /var/log/apache2/error.log + LogLevel warn + CustomLog /var/log/apache2/access.log combined + ServerSignature On + diff --git a/lib/puppet/provider/a2mod/a2mod.rb b/lib/puppet/provider/a2mod/a2mod.rb new file mode 100644 index 0000000..a2fdd7c --- /dev/null +++ b/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 diff --git a/lib/puppet/type/a2mod.rb b/lib/puppet/type/a2mod.rb new file mode 100644 index 0000000..0a1c8eb --- /dev/null +++ b/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 diff --git a/manifests/dev.pp b/manifests/dev.pp new file mode 100644 index 0000000..68f0ec9 --- /dev/null +++ b/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} +} diff --git a/manifests/init.pp b/manifests/init.pp new file mode 100644 index 0000000..5a54cc6 --- /dev/null +++ b/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'], + } +} diff --git a/manifests/params.pp b/manifests/params.pp new file mode 100644 index 0000000..46d1bc2 --- /dev/null +++ b/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/' + } + } +} diff --git a/manifests/php.pp b/manifests/php.pp new file mode 100644 index 0000000..932eaee --- /dev/null +++ b/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, + } +} diff --git a/manifests/ssl.pp b/manifests/ssl.pp new file mode 100644 index 0000000..f18bb14 --- /dev/null +++ b/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, } + } + } +} diff --git a/manifests/vhost.pp b/manifests/vhost.pp new file mode 100644 index 0000000..6a61d23 --- /dev/null +++ b/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'], + } +} diff --git a/pkg/puppetlabs-apache-0.0.2.tar.gz b/pkg/puppetlabs-apache-0.0.2.tar.gz new file mode 100644 index 0000000..029bdf2 Binary files /dev/null and b/pkg/puppetlabs-apache-0.0.2.tar.gz differ diff --git a/pkg/puppetlabs-apache-0.0.2/Modulefile b/pkg/puppetlabs-apache-0.0.2/Modulefile new file mode 100644 index 0000000..a4f885e --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.2/Modulefile @@ -0,0 +1,2 @@ +name 'puppetlabs-apache' +version '0.0.2' diff --git a/pkg/puppetlabs-apache-0.0.2/files/httpd b/pkg/puppetlabs-apache-0.0.2/files/httpd new file mode 100644 index 0000000..d65a8d4 --- /dev/null +++ b/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` diff --git a/pkg/puppetlabs-apache-0.0.2/files/test.vhost b/pkg/puppetlabs-apache-0.0.2/files/test.vhost new file mode 100644 index 0000000..ec9c811 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.2/files/test.vhost @@ -0,0 +1,18 @@ +# +# Test vhost +# +NameVirtualHost *:80 + + ServerName testvhost + DocumentRoot /tmp/testvhost + + Options Indexes FollowSymLinks MultiViews + AllowOverride None + Order allow,deny + allow from all + + ErrorLog /var/log/apache2/error.log + LogLevel warn + CustomLog /var/log/apache2/access.log combined + ServerSignature On + diff --git a/pkg/puppetlabs-apache-0.0.2/lib/puppet/provider/a2mod/a2mod.rb b/pkg/puppetlabs-apache-0.0.2/lib/puppet/provider/a2mod/a2mod.rb new file mode 100644 index 0000000..a2fdd7c --- /dev/null +++ b/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 diff --git a/pkg/puppetlabs-apache-0.0.2/lib/puppet/type/a2mod.rb b/pkg/puppetlabs-apache-0.0.2/lib/puppet/type/a2mod.rb new file mode 100644 index 0000000..0a1c8eb --- /dev/null +++ b/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 diff --git a/pkg/puppetlabs-apache-0.0.2/manifests/dev.pp b/pkg/puppetlabs-apache-0.0.2/manifests/dev.pp new file mode 100644 index 0000000..68f0ec9 --- /dev/null +++ b/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} +} diff --git a/pkg/puppetlabs-apache-0.0.2/manifests/init.pp b/pkg/puppetlabs-apache-0.0.2/manifests/init.pp new file mode 100644 index 0000000..8dcdd11 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.2/manifests/init.pp @@ -0,0 +1,47 @@ +# 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 resource type is broken. Look into fixing it and moving it into apache. + # + A2mod { require => Package['httpd'], notify => Service['httpd']} + @a2mod { + 'rewrite' : ensure => present; + 'headers' : ensure => present; + 'expires' : ensure => present; + } + $vdir = $operatingsystem? { + 'ubuntu' => '/etc/apache2/sites-enabled/', + default => '/etc/httpd/conf.d', + } + file { $vdir: + ensure => directory, + recurse => true, + purge => true, + notify => Service['httpd'], + } +} diff --git a/pkg/puppetlabs-apache-0.0.2/manifests/params.pp b/pkg/puppetlabs-apache-0.0.2/manifests/params.pp new file mode 100644 index 0000000..d930572 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.2/manifests/params.pp @@ -0,0 +1,44 @@ +# 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' + } + 'ubuntu', 'debian': { + $apache_name = 'apache2' + $php_package = 'libapache2-mod-php5' + $ssl_package = 'apache-ssl' + $apache_dev = [ 'libaprutil1-dev', 'libapr1-dev', 'apache2-prefork-dev' ] + } + default: { + $apache_name = 'apache2' + $php_package = 'libapache2-mod-php5' + $ssl_package = 'apache-ssl' + $apache_dev = 'apache-dev' + } + } +} diff --git a/pkg/puppetlabs-apache-0.0.2/manifests/php.pp b/pkg/puppetlabs-apache-0.0.2/manifests/php.pp new file mode 100644 index 0000000..932eaee --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.2/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, + } +} diff --git a/pkg/puppetlabs-apache-0.0.2/manifests/ssl.pp b/pkg/puppetlabs-apache-0.0.2/manifests/ssl.pp new file mode 100644 index 0000000..f18bb14 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.2/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, } + } + } +} diff --git a/pkg/puppetlabs-apache-0.0.2/manifests/vhost.pp b/pkg/puppetlabs-apache-0.0.2/manifests/vhost.pp new file mode 100644 index 0000000..5af8fe2 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.2/manifests/vhost.pp @@ -0,0 +1,43 @@ +# 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 + + $vdir = $operatingsystem? { + /(ubuntu|debian)/ => '/etc/apache2/sites-enabled/', + default => '/etc/httpd/conf.d', + } + + file {"${vdir}/${priority}-${name}": + content => template($template), + owner => 'root', + group => 'root', + mode => '777', + require => Package['httpd'], + notify => Service['httpd'], + } +} diff --git a/pkg/puppetlabs-apache-0.0.2/metadata.json b/pkg/puppetlabs-apache-0.0.2/metadata.json new file mode 100644 index 0000000..407bde1 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.2/metadata.json @@ -0,0 +1,51 @@ +{ + "types": [ + { + "parameters": [ + { + "name": "name", + "doc": "The name of the module to be managed" + } + ], + "properties": [ + { + "name": "ensure", + "doc": "The basic property that the resource should be in. Valid values are ``present``, ``absent``." + } + ], + "name": "a2mod", + "providers": [ + { + "name": "a2mod", + "doc": "Manage Apache 2 modules on Debian and Ubuntu Required binaries: ``a2enmod``, ``a2dismod``. Default for ``operatingsystem`` == ``debianubuntu``. " + } + ], + "doc": "Manage Apache 2 modules on Debian and Ubuntu" + } + ], + "dependencies": [ + + ], + "checksums": { + "manifests/params.pp": "f137ab035e6cd5bdbbd50beeac4c68b0", + "tests/ssl.pp": "191912535199531fd631f911c6329e56", + "tests/vhost.pp": "1b91e03c8ef89a7ecb6793831ac18399", + "manifests/php.pp": "8a5ca4035b1c22892923f3fde55e3d5e", + "files/httpd": "295f5e924afe6f752d29327e73fe6d0a", + "tests/php.pp": "ce7bb9eef69d32b42a32ce32d9653625", + "lib/puppet/provider/a2mod/a2mod.rb": "18c5bb180b75a2375e95e07f88a94257", + "files/test.vhost": "0602022c19a7b6b289f218c7b93c1aea", + "manifests/ssl.pp": "11ed1861298c72cca3a706480bb0b67c", + "manifests/dev.pp": "bc54a5af648cb04b7b3bb0e3f7be6543", + "manifests/vhost.pp": "b43a4d6efb4563341efe8092677aac6f", + "tests/init.pp": "4eac4a7ef68499854c54a78879e25535", + "lib/puppet/type/a2mod.rb": "0e1b4843431413a10320ac1f6a055d15", + "tests/apache.pp": "4eac4a7ef68499854c54a78879e25535", + "tests/dev.pp": "4cf15c1fecea3ca86009f182b402c7ab", + "templates/vhost-default.conf.erb": "9055aed946e1111c30ab81fedac2c8b0", + "manifests/init.pp": "168dfe06fb9ad8d67a2effeea4477f57", + "Modulefile": "86f48ebf97e079cf0dc395881d87ecef" + }, + "version": "0.0.2", + "name": "puppetlabs-apache" +} \ No newline at end of file diff --git a/pkg/puppetlabs-apache-0.0.2/templates/vhost-default.conf.erb b/pkg/puppetlabs-apache-0.0.2/templates/vhost-default.conf.erb new file mode 100644 index 0000000..3aaf945 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.2/templates/vhost-default.conf.erb @@ -0,0 +1,20 @@ +NameVirtualHost *:<%= port %> +> + ServerName <%= name %> +<%if serveraliases.is_a? Array -%> +<% serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%> +<% elsif serveraliases != '' -%> +<%= " ServerAlias #{serveraliases}" -%> +<% end -%> + DocumentRoot <%= docroot %> + > + Options Indexes FollowSymLinks MultiViews + AllowOverride None + Order allow,deny + allow from all + + ErrorLog /var/log/apache2/<%= name %>_error.log + LogLevel warn + CustomLog /var/log/apache2/<%= name %>_access.log combined + ServerSignature On + diff --git a/pkg/puppetlabs-apache-0.0.2/tests/apache.pp b/pkg/puppetlabs-apache-0.0.2/tests/apache.pp new file mode 100644 index 0000000..b3f9f13 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.2/tests/apache.pp @@ -0,0 +1 @@ +include apache diff --git a/pkg/puppetlabs-apache-0.0.2/tests/dev.pp b/pkg/puppetlabs-apache-0.0.2/tests/dev.pp new file mode 100644 index 0000000..805ad7e --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.2/tests/dev.pp @@ -0,0 +1 @@ +include apache::dev diff --git a/pkg/puppetlabs-apache-0.0.2/tests/init.pp b/pkg/puppetlabs-apache-0.0.2/tests/init.pp new file mode 100644 index 0000000..b3f9f13 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.2/tests/init.pp @@ -0,0 +1 @@ +include apache diff --git a/pkg/puppetlabs-apache-0.0.2/tests/php.pp b/pkg/puppetlabs-apache-0.0.2/tests/php.pp new file mode 100644 index 0000000..618e0eb --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.2/tests/php.pp @@ -0,0 +1 @@ +include apache::php diff --git a/pkg/puppetlabs-apache-0.0.2/tests/ssl.pp b/pkg/puppetlabs-apache-0.0.2/tests/ssl.pp new file mode 100644 index 0000000..cf2dacf --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.2/tests/ssl.pp @@ -0,0 +1 @@ +include apache::ssl diff --git a/pkg/puppetlabs-apache-0.0.2/tests/vhost.pp b/pkg/puppetlabs-apache-0.0.2/tests/vhost.pp new file mode 100644 index 0000000..c916596 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.2/tests/vhost.pp @@ -0,0 +1,2 @@ +include apache +apache::vhost { 'test.vhost': source => 'puppet:///modules/apache/test.vhost' } diff --git a/pkg/puppetlabs-apache-0.0.3.tar.gz b/pkg/puppetlabs-apache-0.0.3.tar.gz new file mode 100644 index 0000000..8282cc7 Binary files /dev/null and b/pkg/puppetlabs-apache-0.0.3.tar.gz differ diff --git a/pkg/puppetlabs-apache-0.0.3/Modulefile b/pkg/puppetlabs-apache-0.0.3/Modulefile new file mode 100644 index 0000000..5963ae3 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.3/Modulefile @@ -0,0 +1,2 @@ +name 'puppetlabs-apache' +version '0.0.3' diff --git a/pkg/puppetlabs-apache-0.0.3/files/httpd b/pkg/puppetlabs-apache-0.0.3/files/httpd new file mode 100644 index 0000000..d65a8d4 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.3/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` diff --git a/pkg/puppetlabs-apache-0.0.3/files/test.vhost b/pkg/puppetlabs-apache-0.0.3/files/test.vhost new file mode 100644 index 0000000..ec9c811 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.3/files/test.vhost @@ -0,0 +1,18 @@ +# +# Test vhost +# +NameVirtualHost *:80 + + ServerName testvhost + DocumentRoot /tmp/testvhost + + Options Indexes FollowSymLinks MultiViews + AllowOverride None + Order allow,deny + allow from all + + ErrorLog /var/log/apache2/error.log + LogLevel warn + CustomLog /var/log/apache2/access.log combined + ServerSignature On + diff --git a/pkg/puppetlabs-apache-0.0.3/lib/puppet/provider/a2mod/a2mod.rb b/pkg/puppetlabs-apache-0.0.3/lib/puppet/provider/a2mod/a2mod.rb new file mode 100644 index 0000000..a2fdd7c --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.3/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 diff --git a/pkg/puppetlabs-apache-0.0.3/lib/puppet/type/a2mod.rb b/pkg/puppetlabs-apache-0.0.3/lib/puppet/type/a2mod.rb new file mode 100644 index 0000000..0a1c8eb --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.3/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 diff --git a/pkg/puppetlabs-apache-0.0.3/manifests/dev.pp b/pkg/puppetlabs-apache-0.0.3/manifests/dev.pp new file mode 100644 index 0000000..68f0ec9 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.3/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} +} diff --git a/pkg/puppetlabs-apache-0.0.3/manifests/init.pp b/pkg/puppetlabs-apache-0.0.3/manifests/init.pp new file mode 100644 index 0000000..5a54cc6 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.3/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'], + } +} diff --git a/pkg/puppetlabs-apache-0.0.3/manifests/params.pp b/pkg/puppetlabs-apache-0.0.3/manifests/params.pp new file mode 100644 index 0000000..46d1bc2 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.3/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/' + } + } +} diff --git a/pkg/puppetlabs-apache-0.0.3/manifests/php.pp b/pkg/puppetlabs-apache-0.0.3/manifests/php.pp new file mode 100644 index 0000000..932eaee --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.3/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, + } +} diff --git a/pkg/puppetlabs-apache-0.0.3/manifests/ssl.pp b/pkg/puppetlabs-apache-0.0.3/manifests/ssl.pp new file mode 100644 index 0000000..f18bb14 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.3/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, } + } + } +} diff --git a/pkg/puppetlabs-apache-0.0.3/manifests/vhost.pp b/pkg/puppetlabs-apache-0.0.3/manifests/vhost.pp new file mode 100644 index 0000000..6a61d23 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.3/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'], + } +} diff --git a/pkg/puppetlabs-apache-0.0.3/metadata.json b/pkg/puppetlabs-apache-0.0.3/metadata.json new file mode 100644 index 0000000..5fa60a9 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.3/metadata.json @@ -0,0 +1,51 @@ +{ + "dependencies": [ + + ], + "types": [ + { + "properties": [ + { + "name": "ensure", + "doc": "The basic property that the resource should be in. Valid values are ``present``, ``absent``." + } + ], + "parameters": [ + { + "name": "name", + "doc": "The name of the module to be managed" + } + ], + "name": "a2mod", + "providers": [ + { + "name": "a2mod", + "doc": "Manage Apache 2 modules on Debian and Ubuntu Required binaries: ``a2enmod``, ``a2dismod``. Default for ``operatingsystem`` == ``debianubuntu``. " + } + ], + "doc": "Manage Apache 2 modules on Debian and Ubuntu" + } + ], + "checksums": { + "manifests/params.pp": "8728cf041cdd94bb0899170eb2b417d9", + "tests/ssl.pp": "191912535199531fd631f911c6329e56", + "tests/vhost.pp": "1b91e03c8ef89a7ecb6793831ac18399", + "manifests/php.pp": "8a5ca4035b1c22892923f3fde55e3d5e", + "files/httpd": "295f5e924afe6f752d29327e73fe6d0a", + "tests/php.pp": "ce7bb9eef69d32b42a32ce32d9653625", + "lib/puppet/provider/a2mod/a2mod.rb": "18c5bb180b75a2375e95e07f88a94257", + "files/test.vhost": "0602022c19a7b6b289f218c7b93c1aea", + "manifests/ssl.pp": "11ed1861298c72cca3a706480bb0b67c", + "manifests/dev.pp": "bc54a5af648cb04b7b3bb0e3f7be6543", + "manifests/vhost.pp": "7806a6c098e217da046d0555314756c4", + "tests/init.pp": "4eac4a7ef68499854c54a78879e25535", + "lib/puppet/type/a2mod.rb": "0e1b4843431413a10320ac1f6a055d15", + "tests/apache.pp": "4eac4a7ef68499854c54a78879e25535", + "tests/dev.pp": "4cf15c1fecea3ca86009f182b402c7ab", + "templates/vhost-default.conf.erb": "ed64a53af0d7bad762176a98c9ea3e62", + "manifests/init.pp": "9ef7e081c832bca8f861c3a9feb9949d", + "Modulefile": "9b7a414bf15b06afe2f011068fcaff52" + }, + "version": "0.0.3", + "name": "puppetlabs-apache" +} \ No newline at end of file diff --git a/pkg/puppetlabs-apache-0.0.3/templates/vhost-default.conf.erb b/pkg/puppetlabs-apache-0.0.3/templates/vhost-default.conf.erb new file mode 100644 index 0000000..3c0f349 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.3/templates/vhost-default.conf.erb @@ -0,0 +1,25 @@ +# ************************************ +# Default template in module puppetlabs-apache +# Managed by Puppet +# ************************************ + +NameVirtualHost *:<%= port %> +> + ServerName <%= name %> +<%if serveraliases.is_a? Array -%> +<% serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%> +<% elsif serveraliases != '' -%> +<%= " ServerAlias #{serveraliases}" -%> +<% end -%> + DocumentRoot <%= docroot %> + > + Options Indexes FollowSymLinks MultiViews + AllowOverride None + Order allow,deny + allow from all + + ErrorLog /var/log/apache2/<%= name %>_error.log + LogLevel warn + CustomLog /var/log/apache2/<%= name %>_access.log combined + ServerSignature On + diff --git a/pkg/puppetlabs-apache-0.0.3/tests/apache.pp b/pkg/puppetlabs-apache-0.0.3/tests/apache.pp new file mode 100644 index 0000000..b3f9f13 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.3/tests/apache.pp @@ -0,0 +1 @@ +include apache diff --git a/pkg/puppetlabs-apache-0.0.3/tests/dev.pp b/pkg/puppetlabs-apache-0.0.3/tests/dev.pp new file mode 100644 index 0000000..805ad7e --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.3/tests/dev.pp @@ -0,0 +1 @@ +include apache::dev diff --git a/pkg/puppetlabs-apache-0.0.3/tests/init.pp b/pkg/puppetlabs-apache-0.0.3/tests/init.pp new file mode 100644 index 0000000..b3f9f13 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.3/tests/init.pp @@ -0,0 +1 @@ +include apache diff --git a/pkg/puppetlabs-apache-0.0.3/tests/php.pp b/pkg/puppetlabs-apache-0.0.3/tests/php.pp new file mode 100644 index 0000000..618e0eb --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.3/tests/php.pp @@ -0,0 +1 @@ +include apache::php diff --git a/pkg/puppetlabs-apache-0.0.3/tests/ssl.pp b/pkg/puppetlabs-apache-0.0.3/tests/ssl.pp new file mode 100644 index 0000000..cf2dacf --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.3/tests/ssl.pp @@ -0,0 +1 @@ +include apache::ssl diff --git a/pkg/puppetlabs-apache-0.0.3/tests/vhost.pp b/pkg/puppetlabs-apache-0.0.3/tests/vhost.pp new file mode 100644 index 0000000..c916596 --- /dev/null +++ b/pkg/puppetlabs-apache-0.0.3/tests/vhost.pp @@ -0,0 +1,2 @@ +include apache +apache::vhost { 'test.vhost': source => 'puppet:///modules/apache/test.vhost' } diff --git a/templates/vhost-default.conf.erb b/templates/vhost-default.conf.erb new file mode 100644 index 0000000..3c0f349 --- /dev/null +++ b/templates/vhost-default.conf.erb @@ -0,0 +1,25 @@ +# ************************************ +# Default template in module puppetlabs-apache +# Managed by Puppet +# ************************************ + +NameVirtualHost *:<%= port %> +> + ServerName <%= name %> +<%if serveraliases.is_a? Array -%> +<% serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%> +<% elsif serveraliases != '' -%> +<%= " ServerAlias #{serveraliases}" -%> +<% end -%> + DocumentRoot <%= docroot %> + > + Options Indexes FollowSymLinks MultiViews + AllowOverride None + Order allow,deny + allow from all + + ErrorLog /var/log/apache2/<%= name %>_error.log + LogLevel warn + CustomLog /var/log/apache2/<%= name %>_access.log combined + ServerSignature On + diff --git a/tests/apache.pp b/tests/apache.pp new file mode 100644 index 0000000..b3f9f13 --- /dev/null +++ b/tests/apache.pp @@ -0,0 +1 @@ +include apache diff --git a/tests/dev.pp b/tests/dev.pp new file mode 100644 index 0000000..805ad7e --- /dev/null +++ b/tests/dev.pp @@ -0,0 +1 @@ +include apache::dev diff --git a/tests/init.pp b/tests/init.pp new file mode 100644 index 0000000..b3f9f13 --- /dev/null +++ b/tests/init.pp @@ -0,0 +1 @@ +include apache diff --git a/tests/php.pp b/tests/php.pp new file mode 100644 index 0000000..618e0eb --- /dev/null +++ b/tests/php.pp @@ -0,0 +1 @@ +include apache::php diff --git a/tests/ssl.pp b/tests/ssl.pp new file mode 100644 index 0000000..cf2dacf --- /dev/null +++ b/tests/ssl.pp @@ -0,0 +1 @@ +include apache::ssl diff --git a/tests/vhost.pp b/tests/vhost.pp new file mode 100644 index 0000000..c916596 --- /dev/null +++ b/tests/vhost.pp @@ -0,0 +1,2 @@ +include apache +apache::vhost { 'test.vhost': source => 'puppet:///modules/apache/test.vhost' }