Skip to content

Commit

Permalink
proxy_html needs to load libxml2 library before loading module in Debian
Browse files Browse the repository at this point in the history
Allow passing list of files to load before loading the module to apache::mod
libxml2 path in i686 hardwaremodel is /usr/lib/i386-linux-gnu/libxml2.so.2
Add acceptance tests for proxy_html and debian 7.3
  • Loading branch information
Carlos Sanchez committed Mar 12, 2014
1 parent f30d212 commit eee54e9
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 24 deletions.
3 changes: 2 additions & 1 deletion manifests/mod.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
$lib_path = $::apache::params::lib_path,
$id = undef,
$path = undef,
$loadfiles = undef,
) {
if ! defined(Class['apache']) {
fail('You must include the apache base class before using any apache defined resources')
Expand Down Expand Up @@ -72,7 +73,7 @@
owner => 'root',
group => $::apache::params::root_group,
mode => '0644',
content => "LoadModule ${_id} ${_path}\n",
content => template('apache/mod/load.erb'),
require => [
Package['httpd'],
Exec["mkdir ${mod_dir}"],
Expand Down
23 changes: 15 additions & 8 deletions manifests/mod/proxy_html.pp
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
class apache::mod::proxy_html {
Class['::apache::mod::proxy'] -> Class['::apache::mod::proxy_html']
Class['::apache::mod::proxy_http'] -> Class['::apache::mod::proxy_html']
::apache::mod { 'proxy_html': }

# Add libxml2
case $::osfamily {
'RedHat': {
/RedHat|FreeBSD/: {
::apache::mod { 'xml2enc': }
}
'Debian': {
$proxy_html_loadfiles = $::apache::params::distrelease ? {
'6' => '/usr/lib/libxml2.so.2',
default => "/usr/lib/${::hardwaremodel}-linux-gnu/libxml2.so.2",
$gnu_path = $::hardwaremodel ? {
'i686' => 'i386',
default => $::hardwaremodel,
}
$loadfiles = $::apache::params::distrelease ? {
'6' => ['/usr/lib/libxml2.so.2'],
default => ["/usr/lib/${gnu_path}-linux-gnu/libxml2.so.2"],
}
}
'FreeBSD': {
::apache::mod { 'xml2enc': }
}
}

::apache::mod { 'proxy_html':
loadfiles => $loadfiles,
}

# Template uses $icons_path
file { 'proxy_html.conf':
ensure => file,
Expand Down
36 changes: 36 additions & 0 deletions spec/acceptance/mod_proxy_html_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require 'spec_helper_acceptance'

describe 'apache::mod::proxy_html class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
case fact('osfamily')
when 'Debian'
service_name = 'apache2'
when 'RedHat'
service_name = 'httpd'
when 'FreeBSD'
service_name = 'apache22'
end

context "default proxy_html config" do
if fact('osfamily') == 'RedHat'
it 'adds epel' do
pp = "class { 'epel': }"
apply_manifest(pp, :catch_failures => true)
end
end

it 'succeeds in puppeting proxy_html' do
pp= <<-EOS
class { 'apache': }
class { 'apache::mod::proxy': }
class { 'apache::mod::proxy_http': }
class { 'apache::mod::proxy_html': }
EOS
apply_manifest(pp, :catch_failures => true)
end

describe service(service_name) do
it { should be_enabled }
it { should be_running }
end
end
end
11 changes: 11 additions & 0 deletions spec/acceptance/nodesets/debian-73-i386.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
HOSTS:
debian-73-i386:
roles:
- master
platform: debian-7-i386
box : debian-73-i386-virtualbox-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-73-i386-virtualbox-nocm.box
hypervisor : vagrant
CONFIG:
log_level: debug
type: git
11 changes: 11 additions & 0 deletions spec/acceptance/nodesets/debian-73-x64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
HOSTS:
debian-73-x64:
roles:
- master
platform: debian-7-amd64
box : debian-73-x64-virtualbox-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-nocm.box
hypervisor : vagrant
CONFIG:
log_level: debug
type: git
42 changes: 33 additions & 9 deletions spec/classes/mod/proxy_html_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,41 @@
'include apache::mod::proxy_http',
]
end
context "on a Debian OS", :compile do
context "on a Debian OS" do
shared_examples "debian" do |loadfiles|
it { should contain_class("apache::params") }
it { should contain_apache__mod('proxy_html').with(:loadfiles => loadfiles) }
it { should contain_package("libapache2-mod-proxy-html") }
end
let :facts do
{
:osfamily => 'Debian',
:operatingsystemrelease => '6',
:concat_basedir => '/dne',
:osfamily => 'Debian',
:concat_basedir => '/dne',
:architecture => 'i386'
}
end
it { should contain_class("apache::params") }
it { should contain_apache__mod('proxy_html') }
it { should contain_package("libapache2-mod-proxy-html") }

context "on squeeze" do
let(:facts) { super().merge({ :operatingsystemrelease => '6' }) }
it_behaves_like "debian", ['/usr/lib/libxml2.so.2']
end
context "on wheezy" do
let(:facts) { super().merge({ :operatingsystemrelease => '7' }) }
context "i386" do
let(:facts) { super().merge({
:hardwaremodel => 'i686',
:architecture => 'i386'
})}
it_behaves_like "debian", ["/usr/lib/i386-linux-gnu/libxml2.so.2"]
end
context "x64" do
let(:facts) { super().merge({
:hardwaremodel => 'x86_64',
:architecture => 'amd64'
})}
it_behaves_like "debian", ["/usr/lib/x86_64-linux-gnu/libxml2.so.2"]
end
end
end
context "on a RedHat OS", :compile do
let :facts do
Expand All @@ -27,7 +51,7 @@
}
end
it { should contain_class("apache::params") }
it { should contain_apache__mod('proxy_html') }
it { should contain_apache__mod('proxy_html').with(:loadfiles => nil) }
it { should contain_package("mod_proxy_html") }
end
context "on a FreeBSD OS", :compile do
Expand All @@ -39,7 +63,7 @@
}
end
it { should contain_class("apache::params") }
it { should contain_apache__mod('proxy_html') }
it { should contain_apache__mod('proxy_html').with(:loadfiles => nil) }
it { should contain_package("www/mod_proxy_html") }
end
end
7 changes: 7 additions & 0 deletions templates/mod/load.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<% if @loadfiles -%>
<% Array(@loadfiles).each do |loadfile| -%>
LoadFile <%= loadfile %>
<% end -%>

<% end -%>
LoadModule <%= @_id %> <%= @_path %>
6 changes: 0 additions & 6 deletions templates/mod/proxy_html.conf.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
<% if @proxy_html_loadfiles -%>
<% Array(@proxy_html_loadfiles).each do |loadfile| -%>
LoadFile <%= loadfile %>
<% end -%>

<% end -%>
ProxyHTMLLinks a href
ProxyHTMLLinks area href
ProxyHTMLLinks link href
Expand Down

0 comments on commit eee54e9

Please sign in to comment.