From 3d0ffaad71520ce381ecfbd88cb4bf6bdebc3ca8 Mon Sep 17 00:00:00 2001 From: Sander Hoentjen <sander@hoentjen.eu> Date: Fri, 19 Jul 2013 13:28:09 +0200 Subject: [PATCH 1/6] Use a more specific match for changing to worker httpd from centos.alt.ru has both #HTTPD=/usr/sbin/httpd.worker and confused --- manifests/mod/prefork.pp | 4 ++-- manifests/mod/worker.pp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/mod/prefork.pp b/manifests/mod/prefork.pp index 675cbe841d..c49c7ab649 100644 --- a/manifests/mod/prefork.pp +++ b/manifests/mod/prefork.pp @@ -35,8 +35,8 @@ file_line { '/etc/sysconfig/httpd prefork enable': ensure => present, path => '/etc/sysconfig/httpd', - line => '#HTTPD=/usr/sbin/httpd.prefork', - match => '#?HTTPD=', + line => '#HTTPD=/usr/sbin/httpd.worker', + match => '#?HTTPD=/usr/sbin/httpd.worker', require => Package['httpd'], notify => Service['httpd'], } diff --git a/manifests/mod/worker.pp b/manifests/mod/worker.pp index 71fbcf8c3b..12b5f4bc01 100644 --- a/manifests/mod/worker.pp +++ b/manifests/mod/worker.pp @@ -38,7 +38,7 @@ ensure => present, path => '/etc/sysconfig/httpd', line => 'HTTPD=/usr/sbin/httpd.worker', - match => '#?HTTPD=', + match => '#?HTTPD=/usr/sbin/httpd.worker', notify => Service['httpd'], } } From 0a8fef22c6230da2452f20dfd25fa64c5a1280d6 Mon Sep 17 00:00:00 2001 From: Hunter Haugen <h.haugen@gmail.com> Date: Fri, 19 Jul 2013 15:37:18 -0700 Subject: [PATCH 2/6] Add Serverspec matchers --- Gemfile | 12 ++++++++---- spec/spec_helper_system.rb | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 14d532985e..90824211bd 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,14 @@ source 'https://rubygems.org' group :development, :test do - gem 'rake', :require => false - gem 'puppetlabs_spec_helper', :require => false - gem 'rspec-system-puppet', :require => false - gem 'puppet-lint', :require => false + gem 'rake', :require => false + gem 'rspec-puppet', :require => false + gem 'puppetlabs_spec_helper', :require => false + gem 'serverspec', :require => false + gem 'rspec-system', :require => false + gem 'rspec-system-puppet', :require => false + gem 'rspec-system-serverspec', :require => false + gem 'puppet-lint', :require => false end if puppetversion = ENV['PUPPET_GEM_VERSION'] diff --git a/spec/spec_helper_system.rb b/spec/spec_helper_system.rb index 638c562aa8..7c2feae8a8 100644 --- a/spec/spec_helper_system.rb +++ b/spec/spec_helper_system.rb @@ -1,6 +1,8 @@ require 'rspec-system/spec_helper' require 'rspec-system-puppet/helpers' - +require 'rspec-system-serverspec/helpers' +include Serverspec::Helper::RSpecSystem +include Serverspec::Helper::DetectOS include RSpecSystemPuppet::Helpers RSpec.configure do |c| From 4edb1a7334662b99f3423c46c8edefc97bc05845 Mon Sep 17 00:00:00 2001 From: Hunter Haugen <h.haugen@gmail.com> Date: Fri, 19 Jul 2013 15:37:29 -0700 Subject: [PATCH 3/6] Disable selinux first --- spec/system/basic_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/system/basic_spec.rb b/spec/system/basic_spec.rb index 60b8374b4f..a87f908411 100644 --- a/spec/system/basic_spec.rb +++ b/spec/system/basic_spec.rb @@ -9,3 +9,14 @@ end end +describe 'disable selinux:' do + context puppet_apply ' + exec { "setenforce 0": + path => "/bin:/sbin:/usr/bin:/usr/sbin", + onlyif => "which setenforce && getenforce | grep Enforcing", + } + ' do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + end +end From 917505c0b9c31882eade5c3ac0cd36e098370ed1 Mon Sep 17 00:00:00 2001 From: Hunter Haugen <h.haugen@gmail.com> Date: Fri, 19 Jul 2013 15:37:59 -0700 Subject: [PATCH 4/6] Add system tests for prefork / worker mpm module --- spec/system/prefork_worker_spec.rb | 60 ++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 spec/system/prefork_worker_spec.rb diff --git a/spec/system/prefork_worker_spec.rb b/spec/system/prefork_worker_spec.rb new file mode 100644 index 0000000000..ae7eae9ed7 --- /dev/null +++ b/spec/system/prefork_worker_spec.rb @@ -0,0 +1,60 @@ +require 'spec_helper_system' + +case node.facts['osfamily'] +when 'RedHat' + servicename = 'httpd' +when 'Debian' + servicename = 'apache2' +else + raise Error, "Unconfigured OS for apache service on #{node.facts['osfamily']}" +end + +describe 'apache::mod::worker class' do + describe 'running puppet code' do + # Using puppet_apply as a helper + it 'should work with no errors' do + pp = <<-EOS + class { 'apache': + mpm_module => 'worker', + } + EOS + + # Run it twice and test for idempotency + puppet_apply(pp) do |r| + r.exit_code.should_not == 1 + r.refresh + r.exit_code.should be_zero + end + end + end + + describe service(servicename) do + it { should be_running } + it { should be_enabled } + end +end + +describe 'apache::mod::prefork class' do + describe 'running puppet code' do + # Using puppet_apply as a helper + it 'should work with no errors' do + pp = <<-EOS + class { 'apache': + mpm_module => 'prefork', + } + EOS + + # Run it twice and test for idempotency + puppet_apply(pp) do |r| + r.exit_code.should_not == 1 + r.refresh + r.exit_code.should be_zero + end + end + end + + describe service(servicename) do + it { should be_running } + it { should be_enabled } + end +end From c234b5e09cda70809d2fd3efdbc852c4b8c975b1 Mon Sep 17 00:00:00 2001 From: Hunter Haugen <h.haugen@gmail.com> Date: Tue, 23 Jul 2013 17:15:26 -0700 Subject: [PATCH 5/6] Correct cgi/cgid loading on worker/prefork --- manifests/default_mods.pp | 10 ++++++++-- manifests/mod/cgi.pp | 1 + manifests/mod/cgid.pp | 23 +++++++++++++++-------- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/manifests/default_mods.pp b/manifests/default_mods.pp index 3d363696ce..0cebaa07fb 100644 --- a/manifests/default_mods.pp +++ b/manifests/default_mods.pp @@ -16,11 +16,9 @@ if $all { case $::osfamily { 'debian': { - include apache::mod::cgid # Debian uses mpm_worker include apache::mod::reqtimeout } 'redhat': { - include apache::mod::cgi # RedHat uses mpm_prefork include apache::mod::cache include apache::mod::disk_cache include apache::mod::info @@ -56,6 +54,14 @@ } default: {} } + case $apache::mpm_module { + 'prefork': { + include apache::mod::cgi + } + 'worker': { + include apache::mod::cgid + } + } include apache::mod::alias include apache::mod::autoindex include apache::mod::dav diff --git a/manifests/mod/cgi.pp b/manifests/mod/cgi.pp index 4c44c92fe8..2ad368a0ef 100644 --- a/manifests/mod/cgi.pp +++ b/manifests/mod/cgi.pp @@ -1,3 +1,4 @@ class apache::mod::cgi { + Class['apache::mod::prefork'] -> Class['apache::mod::cgi'] apache::mod { 'cgi': } } diff --git a/manifests/mod/cgid.pp b/manifests/mod/cgid.pp index e26ed70406..1a0a082494 100644 --- a/manifests/mod/cgid.pp +++ b/manifests/mod/cgid.pp @@ -1,15 +1,22 @@ class apache::mod::cgid { + Class['apache::mod::worker'] -> Class['apache::mod::cgid'] + + # Debian specifies it's cgid sock path, but RedHat uses the default value + # with no config file $cgisock_path = $::osfamily ? { 'debian' => '${APACHE_RUN_DIR}/cgisock', + default => undef, } apache::mod { 'cgid': } - # Template uses $cgisock_path - file { 'cgid.conf': - ensure => file, - path => "${apache::mod_dir}/cgid.conf", - content => template('apache/mod/cgid.conf.erb'), - require => Exec["mkdir ${apache::mod_dir}"], - before => File[$apache::mod_dir], - notify => Service['httpd'], + if $cgisock_path { + # Template uses $cgisock_path + file { 'cgid.conf': + ensure => file, + path => "${apache::mod_dir}/cgid.conf", + content => template('apache/mod/cgid.conf.erb'), + require => Exec["mkdir ${apache::mod_dir}"], + before => File[$apache::mod_dir], + notify => Service['httpd'], + } } } From 8fd6400c38a2b174bcea7225ebebb00ac35174fa Mon Sep 17 00:00:00 2001 From: Hunter Haugen <h.haugen@gmail.com> Date: Fri, 26 Jul 2013 10:45:46 -0700 Subject: [PATCH 6/6] Release 0.8.1 Bugfixes: - Update `apache::mpm_module` detection for worker/prefork - Update `apache::mod::cgi` and `apache::mod::cgid` detection for worker/prefork --- CHANGELOG | 6 ++++++ Modulefile | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 9b77277e4c..8c5c104f8a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +2013-07-26 Release 0.8.1 +Bugfixes: +- Update `apache::mpm_module` detection for worker/prefork +- Update `apache::mod::cgi` and `apache::mod::cgid` detection for +worker/prefork + 2013-07-16 Release 0.8.0 Features: - Add `servername` parameter to `apache` class diff --git a/Modulefile b/Modulefile index 4f8a57abf8..b510927fc0 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-apache' -version '0.8.0' +version '0.8.1' source 'git://github.com/puppetlabs/puppetlabs-apache.git' author 'puppetlabs' license 'Apache 2.0'