diff --git a/spec/fixtures/releases/jamtur01-apache/Modulefile b/spec/fixtures/releases/jamtur01-apache/Modulefile new file mode 100644 index 000000000..35a1ab887 --- /dev/null +++ b/spec/fixtures/releases/jamtur01-apache/Modulefile @@ -0,0 +1,2 @@ +name 'jamtur01-apache' +version '0.0.1' diff --git a/spec/fixtures/releases/jamtur01-apache/files/httpd b/spec/fixtures/releases/jamtur01-apache/files/httpd new file mode 100644 index 000000000..438647cb8 --- /dev/null +++ b/spec/fixtures/releases/jamtur01-apache/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/spec/fixtures/releases/jamtur01-apache/files/test.vhost b/spec/fixtures/releases/jamtur01-apache/files/test.vhost new file mode 100644 index 000000000..801bb85a1 --- /dev/null +++ b/spec/fixtures/releases/jamtur01-apache/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/spec/fixtures/releases/jamtur01-apache/lib/puppet/provider/a2mod/debian.rb b/spec/fixtures/releases/jamtur01-apache/lib/puppet/provider/a2mod/debian.rb new file mode 100644 index 000000000..82ced05b7 --- /dev/null +++ b/spec/fixtures/releases/jamtur01-apache/lib/puppet/provider/a2mod/debian.rb @@ -0,0 +1,21 @@ +Puppet::Type.type(:a2mod).provide(:debian) do + desc "Manage Apache 2 modules on Debian-like OSes (e.g. 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/spec/fixtures/releases/jamtur01-apache/lib/puppet/type/a2mod.rb b/spec/fixtures/releases/jamtur01-apache/lib/puppet/type/a2mod.rb new file mode 100644 index 000000000..a53f07fb6 --- /dev/null +++ b/spec/fixtures/releases/jamtur01-apache/lib/puppet/type/a2mod.rb @@ -0,0 +1,12 @@ +Puppet::Type.newtype(:a2mod) do + @doc = "Manage Apache 2 modules" + + ensurable + + newparam(:name) do + desc "The name of the module to be managed" + + isnamevar + + end +end diff --git a/spec/fixtures/releases/jamtur01-apache/manifests/dev.pp b/spec/fixtures/releases/jamtur01-apache/manifests/dev.pp new file mode 100644 index 000000000..42605e505 --- /dev/null +++ b/spec/fixtures/releases/jamtur01-apache/manifests/dev.pp @@ -0,0 +1,5 @@ +class apache::dev { + include apache::params + + package{$apache::params::apache_dev: ensure => installed} +} diff --git a/spec/fixtures/releases/jamtur01-apache/manifests/init.pp b/spec/fixtures/releases/jamtur01-apache/manifests/init.pp new file mode 100644 index 000000000..bd3f7bae1 --- /dev/null +++ b/spec/fixtures/releases/jamtur01-apache/manifests/init.pp @@ -0,0 +1,34 @@ +# ensure apache is installed +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/spec/fixtures/releases/jamtur01-apache/manifests/params.pp b/spec/fixtures/releases/jamtur01-apache/manifests/params.pp new file mode 100644 index 000000000..520eccb44 --- /dev/null +++ b/spec/fixtures/releases/jamtur01-apache/manifests/params.pp @@ -0,0 +1,17 @@ +class apache::params{ + $user = 'www-data' + $group = 'www-data' + + case $operatingsystem { + "centos": { + $apache_name = httpd + $ssl_package = mod_ssl + $apache_dev = httpd-devel + } + "ubuntu": { + $apache_name = apache2 + $ssl_package = apache-ssl + $apache_dev = [ libaprutil1-dev, libapr1-dev, apache2-prefork-dev ] + } + } +} diff --git a/spec/fixtures/releases/jamtur01-apache/manifests/php.pp b/spec/fixtures/releases/jamtur01-apache/manifests/php.pp new file mode 100644 index 000000000..0827e8043 --- /dev/null +++ b/spec/fixtures/releases/jamtur01-apache/manifests/php.pp @@ -0,0 +1,5 @@ +class apache::php{ + package{'libapache2-mod-php5': + ensure => present, + } +} diff --git a/spec/fixtures/releases/jamtur01-apache/manifests/ssl.pp b/spec/fixtures/releases/jamtur01-apache/manifests/ssl.pp new file mode 100644 index 000000000..349f92288 --- /dev/null +++ b/spec/fixtures/releases/jamtur01-apache/manifests/ssl.pp @@ -0,0 +1,15 @@ +class apache::ssl { + include apache + + + case $operatingsystem { + "centos": { + package { $apache::params::ssl_package: + require => Package['httpd'], + } + } + "ubuntu": { + a2mod { "ssl": ensure => present, } + } + } +} diff --git a/spec/fixtures/releases/jamtur01-apache/manifests/vhost.pp b/spec/fixtures/releases/jamtur01-apache/manifests/vhost.pp new file mode 100644 index 000000000..2fe6ed204 --- /dev/null +++ b/spec/fixtures/releases/jamtur01-apache/manifests/vhost.pp @@ -0,0 +1,15 @@ +define apache::vhost( $port, $docroot, $ssl=true, $template='apache/vhost-default.conf.erb', $priority, $serveraliases = '' ) { + include apache + $vdir = $operatingsystem? { + 'ubuntu' => '/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/spec/fixtures/releases/jamtur01-apache/metadata.json b/spec/fixtures/releases/jamtur01-apache/metadata.json new file mode 100644 index 000000000..7fb6c0868 --- /dev/null +++ b/spec/fixtures/releases/jamtur01-apache/metadata.json @@ -0,0 +1 @@ +{"dependencies":[],"types":[{"providers":[{"name":"a2mod","doc":"Manage Apache 2 modules on Debian and Ubuntu Required binaries: ``a2enmod``, ``a2dismod``. Default for ``operatingsystem`` == ``debianubuntu``. "}],"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","doc":"Manage Apache 2 modules on Debian and Ubuntu"}],"checksums":{"manifests/params.pp":"71734796921dbdbfd58f503622527616","tests/ssl.pp":"191912535199531fd631f911c6329e56","tests/vhost.pp":"1b91e03c8ef89a7ecb6793831ac18399","manifests/php.pp":"b78cc593f1c4cd800c906e0891c9b11f","files/httpd":"295f5e924afe6f752d29327e73fe6d0a","tests/php.pp":"ce7bb9eef69d32b42a32ce32d9653625","lib/puppet/provider/a2mod/a2mod.rb":"18c5bb180b75a2375e95e07f88a94257","files/test.vhost":"0602022c19a7b6b289f218c7b93c1aea","manifests/ssl.pp":"b4334a161a2ba5fa8a62cf7b38f352c8","manifests/dev.pp":"510813942246cc9a7786d8f2d8874a35","manifests/vhost.pp":"cbc4657b0cce5cd432057393d5f6b0c2","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":"dc503e26e8021351078813b541c4bd3d","Modulefile":"d43334b4072cd1744121b3b25cd9ed15"},"version":"0.0.1","name":"jamtur01-apache"} \ No newline at end of file diff --git a/spec/fixtures/releases/jamtur01-apache/templates/vhost-default.conf.erb b/spec/fixtures/releases/jamtur01-apache/templates/vhost-default.conf.erb new file mode 100644 index 000000000..3aaf94594 --- /dev/null +++ b/spec/fixtures/releases/jamtur01-apache/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/spec/fixtures/releases/jamtur01-apache/tests/apache.pp b/spec/fixtures/releases/jamtur01-apache/tests/apache.pp new file mode 100644 index 000000000..b3f9f13aa --- /dev/null +++ b/spec/fixtures/releases/jamtur01-apache/tests/apache.pp @@ -0,0 +1 @@ +include apache diff --git a/spec/fixtures/releases/jamtur01-apache/tests/dev.pp b/spec/fixtures/releases/jamtur01-apache/tests/dev.pp new file mode 100644 index 000000000..805ad7e37 --- /dev/null +++ b/spec/fixtures/releases/jamtur01-apache/tests/dev.pp @@ -0,0 +1 @@ +include apache::dev diff --git a/spec/fixtures/releases/jamtur01-apache/tests/init.pp b/spec/fixtures/releases/jamtur01-apache/tests/init.pp new file mode 100644 index 000000000..b3f9f13aa --- /dev/null +++ b/spec/fixtures/releases/jamtur01-apache/tests/init.pp @@ -0,0 +1 @@ +include apache diff --git a/spec/fixtures/releases/jamtur01-apache/tests/php.pp b/spec/fixtures/releases/jamtur01-apache/tests/php.pp new file mode 100644 index 000000000..618e0ebd2 --- /dev/null +++ b/spec/fixtures/releases/jamtur01-apache/tests/php.pp @@ -0,0 +1 @@ +include apache::php diff --git a/spec/fixtures/releases/jamtur01-apache/tests/ssl.pp b/spec/fixtures/releases/jamtur01-apache/tests/ssl.pp new file mode 100644 index 000000000..cf2dacfb8 --- /dev/null +++ b/spec/fixtures/releases/jamtur01-apache/tests/ssl.pp @@ -0,0 +1 @@ +include apache::ssl diff --git a/spec/fixtures/releases/jamtur01-apache/tests/vhost.pp b/spec/fixtures/releases/jamtur01-apache/tests/vhost.pp new file mode 100644 index 000000000..c916596a6 --- /dev/null +++ b/spec/fixtures/releases/jamtur01-apache/tests/vhost.pp @@ -0,0 +1,2 @@ +include apache +apache::vhost { 'test.vhost': source => 'puppet:///modules/apache/test.vhost' }