diff --git a/.gemfile b/.gemfile deleted file mode 100644 index 9aad840c0a..0000000000 --- a/.gemfile +++ /dev/null @@ -1,5 +0,0 @@ -source :rubygems - -puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 2.7'] -gem 'puppet', puppetversion -gem 'puppetlabs_spec_helper', '>= 0.1.0' diff --git a/.gitignore b/.gitignore index 5a6ed48b93..45b6d17d3e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .pkg +Gemfile.lock diff --git a/.travis.yml b/.travis.yml index fdbc95dc69..8f713e06b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,26 @@ language: ruby +bundler_args: --without development +script: "bundle exec rake spec SPEC_OPTS='--format documentation'" rvm: - 1.8.7 - 1.9.3 -script: "rake spec" -branches: - only: - - master + - ruby-head env: - - PUPPET_VERSION=2.6.17 - - PUPPET_VERSION=2.7.19 - #- PUPPET_VERSION=3.0.1 # Breaks due to rodjek/rspec-puppet#58 -notifications: - email: false -gemfile: .gemfile + - PUPPET_GEM_VERSION="~> 2.6.0" + - PUPPET_GEM_VERSION="~> 2.7.0" + - PUPPET_GEM_VERSION="~> 3.0.0" + - PUPPET_GEM_VERSION="~> 3.1.0" matrix: + allow_failures: + - rvm: ruby-head exclude: - - rvm: 1.9.3 - gemfile: .gemfile - env: PUPPET_VERSION=2.6.17 - - rvm: 1.8.7 - gemfile: .gemfile - env: PUPPET_VERSION=3.0.1 + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.7.0" + - rvm: ruby-head + env: PUPPET_GEM_VERSION="~> 2.7.0" + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.6.0" + - rvm: ruby-head + env: PUPPET_GEM_VERSION="~> 2.6.0" +notifications: + email: false diff --git a/CHANGELOG b/CHANGELOG index 7a7185ae33..1a2fa1a749 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +2013-03-2 Release 0.6.0 +- update travis tests (add more supported versions) +- add access log_parameter +- make purging of vhost dir configurable + 2012-08-24 Release 0.4.0 Changes: - `include apache` is now required when using apache::mod::* diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000000..8e5e04d744 --- /dev/null +++ b/Gemfile @@ -0,0 +1,13 @@ +source :rubygems + +group :development, :test do + gem 'puppetlabs_spec_helper', :require => false +end + +if puppetversion = ENV['PUPPET_GEM_VERSION'] + gem 'puppet', puppetversion, :require => false +else + gem 'puppet', :require => false +end + +# vim:ft=ruby diff --git a/Modulefile b/Modulefile index b229fdab78..300706fb4a 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-apache' -version '0.5.0-rc1' +version '0.6.0' source 'git://github.com/puppetlabs/puppetlabs-apache.git' author 'puppetlabs' license 'Apache 2.0' diff --git a/manifests/init.pp b/manifests/init.pp index 61430118f6..670068c5c0 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -16,7 +16,8 @@ $default_mods = true, $service_enable = true, $serveradmin = 'root@localhost', - $sendfile = false + $sendfile = false, + $purge_vdir = true ) { include apache::params @@ -39,7 +40,7 @@ ensure => directory, path => $apache::params::vdir, recurse => true, - purge => true, + purge => $purge_vdir, notify => Service['httpd'], require => Package['httpd'], } diff --git a/manifests/vhost.pp b/manifests/vhost.pp index 5d053899e9..0bba85cefe 100644 --- a/manifests/vhost.pp +++ b/manifests/vhost.pp @@ -20,6 +20,7 @@ # - The $vhost_name for name based virtualhosting, defaulting to * # - The $logroot specifies the location of the virtual hosts logfiles, default # to /var/log/<apache log location>/ +# - The $access_log specifies if *_access.log directives should be configured. # - The $ensure specifies if vhost file is present or absent. # # Actions: @@ -54,6 +55,7 @@ $apache_name = $apache::params::apache_name, $vhost_name = $apache::params::vhost_name, $logroot = "/var/log/$apache::params::apache_name", + $access_log = true, $ensure = 'present' ) { @@ -97,6 +99,18 @@ } } + # Template uses: + # - $vhost_name + # - $port + # - $srvname + # - $serveradmin + # - $serveraliases + # - $docroot + # - $options + # - $override + # - $logroot + # - $access_log + # - $name file { "${priority}-${name}.conf": ensure => $ensure, path => "${apache::params::vdir}/${priority}-${name}.conf", diff --git a/manifests/vhost/proxy.pp b/manifests/vhost/proxy.pp index a17031814f..ec9714698e 100644 --- a/manifests/vhost/proxy.pp +++ b/manifests/vhost/proxy.pp @@ -9,6 +9,7 @@ # URI that the requests will be proxied for # - $priority # - $template -- the template to use for the vhost +# - $access_log - specifies if *_access.log directives should be configured. # - $vhost_name - the name to use for the vhost, defaults to '*' # # Actions: @@ -27,6 +28,7 @@ $serveraliases = '', $ssl = false, $vhost_name = '*', + $access_log = true, $no_proxy_uris = [] ) { @@ -45,6 +47,18 @@ include apache::mod::ssl } + # Template uses: + # - $vhost_name + # - $port + # - $ssl + # - $ssl_path + # - $srvname + # - $serveraliases + # - $no_proxy_uris + # - $dest + # - $apache::params::apache_name + # - $access_log + # - $name file { "${priority}-${name}.conf": path => "${apache::params::vdir}/${priority}-${name}.conf", content => template($template), diff --git a/spec/defines/mod_spec.rb b/spec/defines/mod_spec.rb index 0e93019612..0bb686c0c4 100644 --- a/spec/defines/mod_spec.rb +++ b/spec/defines/mod_spec.rb @@ -3,7 +3,7 @@ describe 'apache::mod', :type => :define do context "On a Red Hat OS with shibboleth module and package param passed" do let :facts do - { :osfamily => 'redhat' } + { :osfamily => 'RedHat' } end # name/title for the apache::mod define let :title do diff --git a/spec/defines/vhost/proxy_spec.rb b/spec/defines/vhost/proxy_spec.rb index 50f78fd317..4ede33343b 100644 --- a/spec/defines/vhost/proxy_spec.rb +++ b/spec/defines/vhost/proxy_spec.rb @@ -30,7 +30,8 @@ :dest => 'example2.com', :servername => 'example3.com', :port => '80', - :ssl => true + :ssl => true, + :access_log => false, }, ].each do |param_set| @@ -70,5 +71,18 @@ ] ) end end + + [true,false].each do |value| + describe "when access_log is #{value}" do + let :params do + default_params.merge({:access_log => value}) + end + + it "#{value ? "should" : "should not"} contain access logs" do + lines = subject.resource('file', "#{params[:priority]}-#{title}.conf").send(:parameters)[:content].split("\n") + !!lines.grep('_access.log combined').should == value + end + end + end end end diff --git a/spec/defines/vhost_spec.rb b/spec/defines/vhost_spec.rb index a184fbe7ff..ed23822aef 100644 --- a/spec/defines/vhost_spec.rb +++ b/spec/defines/vhost_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'apache::vhost', :type => :define do - context "On a Debian OS" do + context "On a RedHat OS" do let :facts do { :osfamily => 'RedHat' } end @@ -29,14 +29,15 @@ end [{ - :apache_name => 'httpd', - :docroot => 'path/to/docroot', - :override => ['Options', 'FileInfo'], - :port => '80', - :priority => '25', - :serveradmin => 'serveradmin@puppet', - :ssl => false, - :template => 'apache/vhost-default.conf.erb', + :apache_name => 'httpd', + :docroot => 'path/to/docroot', + :override => ['Options', 'FileInfo'], + :port => '80', + :priority => '25', + :serveradmin => 'serveradmin@puppet', + :ssl => false, + :access_log => false, + :template => 'apache/vhost-default.conf.erb', }, ].each do |param_set| @@ -80,5 +81,18 @@ end end + + [true,false].each do |value| + describe "when access_log is #{value}" do + let :params do + default_params.merge({:access_log => value}) + end + + it "#{value ? "should" : "should not"} contain access logs" do + lines = subject.resource('file', "#{params[:priority]}-#{title}.conf").send(:parameters)[:content].split("\n") + !!lines.grep('_access.log combined').should == value + end + end + end end end diff --git a/templates/vhost-default.conf.erb b/templates/vhost-default.conf.erb index 511ac38596..658979fa23 100644 --- a/templates/vhost-default.conf.erb +++ b/templates/vhost-default.conf.erb @@ -23,7 +23,9 @@ NameVirtualHost <%= vhost_name %>:<%= port %> </Directory> ErrorLog <%= logroot %>/<%= name %>_error.log LogLevel warn +<% if access_log -%> CustomLog <%= logroot %>/<%= name %>_access.log combined +<% end -%> ServerSignature Off </VirtualHost> diff --git a/templates/vhost-proxy.conf.erb b/templates/vhost-proxy.conf.erb index 2f625572a4..9f804fc81b 100644 --- a/templates/vhost-proxy.conf.erb +++ b/templates/vhost-proxy.conf.erb @@ -26,6 +26,8 @@ NameVirtualHost <%= vhost_name %>:<%= port %> ErrorLog /var/log/<%= scope.lookupvar("apache::params::apache_name") %>/<%= name %>_error.log LogLevel warn +<% if access_log -%> CustomLog /var/log/<%= scope.lookupvar("apache::params::apache_name") %>/<%= name %>_access.log combined +<% end -%> </VirtualHost>