1 require 'spec_helper_acceptance'
3 describe 'apache class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
9 package_name = 'apache2'
10 service_name = 'apache2'
12 package_name = 'apache24'
13 service_name = 'apache24'
15 package_name = 'www-servers/apache'
16 service_name = 'apache2'
19 context 'default parameters' do
20 it 'should work with no errors' do
25 # Run it twice and test for idempotency
26 apply_manifest(pp, :catch_failures => true)
27 expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
30 describe package(package_name) do
31 it { is_expected.to be_installed }
34 describe service(service_name) do
35 it { is_expected.to be_enabled }
36 it { is_expected.to be_running }
40 it { should be_listening }
44 context 'custom site/mod dir parameters' do
45 # Using puppet_apply as a helper
46 it 'should work with no errors' do
48 if $::osfamily == 'RedHat' and $::selinux {
49 $semanage_package = $::operatingsystemmajrelease ? {
50 '5' => 'policycoreutils',
51 default => 'policycoreutils-python',
54 package { $semanage_package: ensure => installed }
55 exec { 'set_apache_defaults':
56 command => 'semanage fcontext -a -t httpd_sys_content_t "/apache_spec(/.*)?"',
57 path => '/bin:/usr/bin/:/sbin:/usr/sbin',
58 subscribe => Package[$semanage_package],
61 exec { 'restorecon_apache':
62 command => 'restorecon -Rv /apache_spec',
63 path => '/bin:/usr/bin/:/sbin:/usr/sbin',
64 before => Service['httpd'],
65 require => Class['apache'],
66 subscribe => Exec['set_apache_defaults'],
70 file { '/apache_spec': ensure => directory, }
71 file { '/apache_spec/apache_custom': ensure => directory, }
73 mod_dir => '/apache_spec/apache_custom/mods',
74 vhost_dir => '/apache_spec/apache_custom/vhosts',
78 # Run it twice and test for idempotency
79 apply_manifest(pp, :catch_failures => true)
80 apply_manifest(pp, :catch_changes => true)
83 describe service(service_name) do
84 it { is_expected.to be_enabled }
85 it { is_expected.to be_running }