Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Reboot fork from puppetlabs/puppet-apache

  • Loading branch information...
commit ed2a7c250dcd038c4f570cfb2d104668182710bc 0 parents
@ceefour ceefour authored
23 .project
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>puppet-apache</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.cloudsmith.geppetto.pp.dsl.ui.modulefileBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.cloudsmith.geppetto.pp.dsl.ui.puppetNature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
6 Modulefile
@@ -0,0 +1,6 @@
+name 'soluvas-apache'
+version '0.0.3.1'
+
+author ''
+license ''
+dependency 'puppetlabs-firewall', '>=0.0.1'
25 README.textile
@@ -0,0 +1,25 @@
+h1. apache Puppet Module
+
+Based on "puppetlabs-apache":https://github.com/puppetlabs/puppetlabs-apache (C) PuppetLabs.
+
+h2. Common Usage
+
+bc. include apache
+# Realize previously defined virtual resources of Apache modules
+Apache::Module <| |>
+
+h2. Development Usage
+
+Add class @apache::dev@ :
+
+bc. include apache::dev
+
+h2. Apache Modules Management
+
+Example:
+
+bc. @apache::module {
+ 'fastcgi' : ensure => present;
+ 'proxy_http': ensure => present;
+ 'status': ensure => absent;
+}
24 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 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>
18 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}
+}
57 manifests/init.pp
@@ -0,0 +1,57 @@
+# 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 => installed,
+ }
+ service { 'httpd':
+ name => $apache::params::apache_name,
+ ensure => running,
+ enable => true,
+ subscribe => Package['httpd'],
+ }
+
+ # ASK: May want to purge all not realized modules using the resources resource type?
+ define module($ensure = 'present') {
+ case $ensure {
+ 'present': {
+ exec { "/usr/sbin/a2enmod $name":
+ unless => "/usr/bin/test -e /etc/apache2/mods-enabled/$name.load",
+ require => Package['httpd'],
+ notify => Service['httpd']
+ }
+ }
+ 'absent': {
+ exec { "/usr/sbin/a2dismod $name":
+ onlyif => "/usr/bin/test -e /etc/apache2/mods-enabled/$name.load",
+ require => Package['httpd'],
+ notify => Service['httpd']
+ }
+ }
+ }
+ }
+ @module {
+ ['rewrite', 'headers', 'expires', 'deflate']: ensure => present;
+ }
+
+ file { $apache::params::vdir:
+ ensure => directory,
+ recurse => true,
+ purge => true,
+ notify => Service['httpd'],
+ }
+}
17 manifests/mod/python.pp
@@ -0,0 +1,17 @@
+class apache::mod::python {
+ include apache
+
+ package { "python":
+ name => $operatingsystem ? {
+ 'centos', 'fedora', 'redhat', 'scientific' => "mod_python",
+ default => "libapache2-mod-python",
+ },
+ ensure => installed,
+ require => Package["httpd"];
+ }
+
+ a2mod { "python": ensure => present; }
+
+}
+
+
16 manifests/mod/wsgi.pp
@@ -0,0 +1,16 @@
+class apache::mod::wsgi {
+ include apache
+
+ package { "wsgi":
+ name => $operatingsystem ? {
+ 'centos', 'fedora', 'redhat', 'scientific' => "mod_wsgi",
+ default => "libapache2-mod-wsgi",
+ },
+ ensure => installed,
+ require => Package["httpd"];
+ }
+
+ a2mod { "wsgi": ensure => present; }
+
+}
+
56 manifests/params.pp
@@ -0,0 +1,56 @@
+# 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'
+ $ssl = 'true'
+ $template = 'apache/vhost-default.conf.erb'
+ $priority = '25'
+ $servername = ''
+ $serveraliases = ''
+ $auth = false
+ $redirect_ssl = false
+ $options = 'Indexes FollowSymLinks MultiViews'
+ $vhost_name = '*'
+
+ case $operatingsystem {
+ 'centos', 'redhat', 'fedora', 'scientific': {
+ $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 manifests/php.pp
@@ -0,0 +1,22 @@
+# Class: apache::php
+#
+# This class installs PHP for Apache
+#
+# Parameters:
+# - $php_package
+#
+# Actions:
+# - Install Apache mod_php5 package
+#
+# Requires:
+#
+# Sample Usage:
+#
+class apache::php {
+ include php
+# include apache::params
+
+# package { $apache::params::php_package:
+# ensure => present,
+# }
+}
24 manifests/python.pp
@@ -0,0 +1,24 @@
+# Class: apache::python
+#
+# This class installs Python for Apache
+#
+# Parameters:
+# - $php_package
+#
+# Actions:
+# - Install Apache Python package
+#
+# Requires:
+#
+# Sample Usage:
+#
+class apache::python {
+ include apache::params
+ include apache
+
+ package { $apache::params::python_package:
+ ensure => present,
+ }
+ a2mod { "python": ensure => present, }
+
+}
29 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', 'scientific': {
+ package { $apache::params::ssl_package:
+ require => Package['httpd'],
+ }
+ }
+ 'ubuntu', 'debian': {
+ a2mod { "ssl": ensure => present, }
+ }
+ }
+}
86 manifests/vhost.pp
@@ -0,0 +1,86 @@
+# 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
+# - The $options for the given vhost
+# - The $vhost_name for name based virtualhosting, defaulting to *
+#
+# 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 = $apache::params::ssl,
+ $template = $apache::params::template,
+ $priority = $apache::params::priority,
+ $servername = $apache::params::servername,
+ $serveraliases = $apache::params::serveraliases,
+ $auth = $apache::params::auth,
+ $redirect_ssl = $apache::params::redirect_ssl,
+ $options = $apache::params::options,
+ $apache_name = $apache::params::apache_name,
+ $vhost_name = $apache::params::vhost_name
+ ) {
+
+ include apache
+
+ if $servername == '' {
+ $srvname = $name
+ } else {
+ $srvname = $servername
+ }
+
+ if $ssl == true {
+ include apache::ssl
+ }
+
+ # Since the template will use auth, redirect to https requires mod_rewrite
+ if $redirect_ssl == true {
+ case $operatingsystem {
+ 'debian','ubuntu': {
+ A2mod <| title == 'rewrite' |>
+ }
+ default: { }
+ }
+ }
+
+ file {
+ "${apache::params::vdir}/${priority}-${name}.conf":
+ content => template($template),
+ owner => 'root',
+ group => 'root',
+ mode => '644',
+ require => Package['httpd'],
+ notify => Service['httpd'],
+ }
+
+# TODO: Firewall
+# if ! defined(Firewall["0100-INPUT ACCEPT $port"]) {
+# @firewall {
+# "0100-INPUT ACCEPT $port":
+# action => 'accept',
+# dport => "$port",
+# proto => 'tcp'
+# }
+# }
+
+}
+
54 manifests/vhost/proxy.pp
@@ -0,0 +1,54 @@
+# Define: apache::vhost::proxy
+#
+# Configures an apache vhost that will only proxy requests
+#
+# Parameters:
+# * $port:
+# The port on which the vhost will respond
+# * $dest:
+# URI that the requests will be proxied for
+# - $priority
+# - $template -- the template to use for the vhost
+# - $vhost_name - the name to use for the vhost, defaults to '*'
+#
+# Actions:
+# * Install Apache Virtual Host
+#
+# Requires:
+# Apache::Module['proxy']
+# Sample Usage:
+# @apache::module { proxy: ensure => present }
+#
+define apache::vhost::proxy (
+ $port,
+ $dest,
+ $priority = '10',
+ $template = "apache/vhost-proxy.conf.erb",
+ $servername = '',
+ $serveraliases = '',
+ $ssl = false,
+ $vhost_name = '*',
+ $ensure = 'present'
+ ) {
+
+ include apache
+ $apache_name = $apache::params::apache_name
+
+ $srvname = $name
+
+ if $ssl == true {
+ include apache::ssl
+ }
+
+ file {"${apache::params::vdir}${priority}-${name}":
+ ensure => $ensure,
+ content => template($template),
+ owner => 'root',
+ group => 'root',
+ mode => 644,
+ require => Package['httpd'],
+ notify => Service['httpd'],
+ }
+
+
+}
53 manifests/vhost/redirect.pp
@@ -0,0 +1,53 @@
+# Define: apache::vhost::redirect
+#
+# This class will create a vhost that does nothing more than redirect to a given location
+#
+# Parameters:
+# $port:
+# Which port to list on
+# $dest:
+# Where to redirect to
+# - $vhost_name
+#
+# Actions:
+# Installs apache and creates a vhost
+#
+# Requires:
+#
+# Sample Usage:
+#
+define apache::vhost::redirect (
+ $port,
+ $dest,
+ $priority = '10',
+ $serveraliases = '',
+ $template = "apache/vhost-redirect.conf.erb",
+ $vhost_name = '*',
+ $status = '302' # temporary
+ ) {
+
+ include apache
+
+ $srvname = $name
+
+ file {"${apache::params::vdir}/${priority}-${name}":
+ content => template($template),
+ owner => 'root',
+ group => 'root',
+ mode => '755',
+ require => Package['httpd'],
+ notify => Service['httpd'],
+ }
+
+# TODO: Firewall
+# if ! defined(Firewall["0100-INPUT ACCEPT $port"]) {
+# @firewall {
+# "0100-INPUT ACCEPT $port":
+# jump => 'ACCEPT',
+# dport => "$port",
+# proto => 'tcp'
+# }
+# }
+
+}
+
42 metadata.json
@@ -0,0 +1,42 @@
+{
+ "name": "soluvas-apache",
+ "author": "",
+ "description": "",
+ "license": "",
+ "project_page": "",
+ "source": "",
+ "summary": "",
+ "version": "0.0.3.1",
+ "checksums": {
+ "Modulefile": "a1e2ebc12e069f72d0f680f07960cba1",
+ "README.textile": "3e05d3ae6bcc8f5143e3139b2297b5a4",
+ "files/httpd": "295f5e924afe6f752d29327e73fe6d0a",
+ "files/test.vhost": "0602022c19a7b6b289f218c7b93c1aea",
+ "manifests/dev.pp": "bc54a5af648cb04b7b3bb0e3f7be6543",
+ "manifests/init.pp": "7b6148d05837b31963ceddada3af2947",
+ "manifests/mod/python.pp": "f6314af3248dadc62f0bf73b606389df",
+ "manifests/mod/wsgi.pp": "e6447e4ee209cf967f09e6977dd83eaa",
+ "manifests/params.pp": "dd68e82c6f99b4d3d1f6ae58b97367f6",
+ "manifests/php.pp": "9396f36e3d1ed284f75f686532d4116b",
+ "manifests/python.pp": "1b36a39f7eee2749ed3c2dca46cd5de2",
+ "manifests/ssl.pp": "29de7197b9abd616a6bedeb0ff33325e",
+ "manifests/vhost.pp": "29035f1f2dfb4e8a0806830d2e13f306",
+ "manifests/vhost/proxy.pp": "062fdcb8ce895dc99073a7e00691faee",
+ "manifests/vhost/redirect.pp": "ae3cbfbd5c4b4a03c87598eee07e4fe0",
+ "templates/vhost-default.conf.erb": "b970c8b20481adb34a888630b8f3ce9e",
+ "templates/vhost-proxy.conf.erb": "816c62c090094203a1fb7b7077e93cdc",
+ "templates/vhost-redirect.conf.erb": "d6bb8a25aa761e424509bbd271663b7b",
+ "tests/apache.pp": "4eac4a7ef68499854c54a78879e25535",
+ "tests/dev.pp": "4cf15c1fecea3ca86009f182b402c7ab",
+ "tests/init.pp": "4eac4a7ef68499854c54a78879e25535",
+ "tests/php.pp": "ce7bb9eef69d32b42a32ce32d9653625",
+ "tests/ssl.pp": "191912535199531fd631f911c6329e56",
+ "tests/vhost.pp": "1b91e03c8ef89a7ecb6793831ac18399"
+ },
+ "dependencies": [
+ {
+ "name": "puppetlabs-firewall",
+ "versionRequirement": "\u003e\u003d0.0.1"
+ }
+ ]
+}
25 templates/vhost-default.conf.erb
@@ -0,0 +1,25 @@
+# ************************************
+# Default template in module puppetlabs-apache
+# Managed by Puppet
+# ************************************
+
+NameVirtualHost <%= vhost_name %>:<%= port %>
+<VirtualHost <%= vhost_name %>:<%= port %>>
+ ServerName <%= srvname %>
+<% if serveraliases.is_a? Array -%>
+<% serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%>
+<% elsif serveraliases != '' -%>
+<%= " ServerAlias #{serveraliases}" -%>
+<% end -%>
+ DocumentRoot <%= docroot %>
+ <Directory <%= docroot %>>
+ Options <%= options %>
+ AllowOverride None
+ Order allow,deny
+ Allow from all
+ </Directory>
+ ErrorLog /var/log/<%= apache_name %>/<%= name %>_error.log
+ LogLevel warn
+ CustomLog /var/log/<%= apache_name %>/<%= name %>_access.log combined
+ ServerSignature Off
+</VirtualHost>
28 templates/vhost-proxy.conf.erb
@@ -0,0 +1,28 @@
+NameVirtualHost <%= vhost_name %>:<%= port %>
+<VirtualHost <%= vhost_name %>:<%= port %>>
+ <% if ssl == true %>
+ SSLEngine on
+ SSLCertificateFile <%= ssl_path %>/certs/pl.cert
+ SSLCertificateKeyFile <%= ssl_path %>/private/pl.key
+ <% end %>
+ ServerName <%= srvname %>
+<% if serveraliases.is_a? Array %>
+<% serveraliases.each do |name| %><%= " ServerAlias #{name}\n" %><% end %>
+<% elsif serveraliases != '' %>
+<%= " ServerAlias #{serveraliases}" %>
+<% end %>
+ ProxyRequests Off
+ <Proxy *>
+ Order deny,allow
+ Allow from all
+ </Proxy>
+ ProxyPass / <%= dest %>
+ ProxyPassReverse / <%= dest %>
+ ProxyPreserveHost On
+
+ ErrorLog /var/log/<%= apache_name %>/<%= name %>_error.log
+ LogLevel warn
+ CustomLog /var/log/<%= apache_name %>/<%= name %>_access.log combined
+
+</VirtualHost>
+
11 templates/vhost-redirect.conf.erb
@@ -0,0 +1,11 @@
+NameVirtualHost <%= vhost_name %>:<%= port %>
+<VirtualHost <%= vhost_name %>:<%= port %>>
+ ServerName <%= srvname %>
+<% if serveraliases.is_a? Array %>
+<% serveraliases.each do |name| %><%= " ServerAlias #{name}\n" %><% end %>
+<% elsif serveraliases != '' %>
+<%= " ServerAlias #{serveraliases}" %>
+<% end %>
+ Redirect <%= status %> / <%= dest %>
+</VirtualHost>
+
1  tests/apache.pp
@@ -0,0 +1 @@
+include apache
1  tests/dev.pp
@@ -0,0 +1 @@
+include apache::dev
1  tests/init.pp
@@ -0,0 +1 @@
+include apache
1  tests/php.pp
@@ -0,0 +1 @@
+include apache::php
1  tests/ssl.pp
@@ -0,0 +1 @@
+include apache::ssl
2  tests/vhost.pp
@@ -0,0 +1,2 @@
+include apache
+apache::vhost { 'test.vhost': source => 'puppet:///modules/apache/test.vhost' }
Please sign in to comment.
Something went wrong with that request. Please try again.