Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions spec/acceptance/apache_parameters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -428,34 +428,30 @@ class { 'apache':
describe 'logging' do
describe 'setup' do
pp = <<-MANIFEST
if $::osfamily == 'RedHat' and "$::selinux" == "true" {
$semanage_package = $::operatingsystemmajrelease ? {
'6' => 'policycoreutils-python',
'7' => 'policycoreutils-python',
default => 'policycoreutils-python-utils',
}
package { $semanage_package: ensure => installed }
if $facts['osfamily'] == 'RedHat' and $facts['selinux'] {
exec { 'set_apache_defaults':
command => 'semanage fcontext -a -t httpd_log_t "/apache_spec(/.*)?"',
command => 'semanage fcontext -a -t httpd_log_t "/apache_spec/logs(/.*)?"',
unless => 'semanage fcontext --list | grep /apache_spec/logs | grep httpd_log_t',
path => '/bin:/usr/bin/:/sbin:/usr/sbin',
require => Package[$semanage_package],
}
exec { 'restorecon_apache':
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, the explicit restorecon is needed because of https://tickets.puppetlabs.com/browse/PUP-10548. Otherwise the file type would take care of it.

command => 'restorecon -Rv /apache_spec',
path => '/bin:/usr/bin/:/sbin:/usr/sbin',
before => Service['httpd'],
require => Class['apache'],
command => 'restorecon -Rv /apache_spec',
path => '/bin:/usr/bin/:/sbin:/usr/sbin',
before => Service['httpd'],
require => [File['/apache_spec'], Class['apache']],
subscribe => Exec['set_apache_defaults'],
refreshonly => true,
}
}
file { '/apache_spec': ensure => directory, }
class { 'apache': logroot => '/apache_spec' }
file { ['/apache_spec', '/apache_spec/logs']: ensure => directory, }
class { 'apache': logroot => '/apache_spec/logs' }
MANIFEST
it 'applies cleanly' do
apply_manifest(pp, catch_failures: true)
end
end

describe file("/apache_spec/#{apache_hash['error_log']}") do
describe file("/apache_spec/logs/#{apache_hash['error_log']}") do
it { is_expected.to be_file }
end
end
Expand Down
22 changes: 8 additions & 14 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,24 @@
context 'custom site/mod dir parameters' do
let(:pp) do
<<-MANIFEST
if $::osfamily == 'RedHat' and "$::selinux" == "true" {
$semanage_package = $::operatingsystemmajrelease ? {
'6' => 'policycoreutils-python',
'7' => 'policycoreutils-python',
default => 'policycoreutils-python-utils',
}
package { $semanage_package: ensure => installed }
if $facts['osfamily'] == 'RedHat' and $facts['selinux'] {
exec { 'set_apache_defaults':
command => 'semanage fcontext -a -t httpd_sys_content_t "/apache_spec(/.*)?"',
path => '/bin:/usr/bin/:/sbin:/usr/sbin',
subscribe => Package[$semanage_package],
refreshonly => true,
command => 'semanage fcontext --add -t httpd_config_t "/apache_spec/apache_custom(/.*)?"',
unless => 'semanage fcontext --list | grep /apache_spec/apache_custom | grep httpd_config_t',
path => '/bin:/usr/bin/:/sbin:/usr/sbin',
}
exec { 'restorecon_apache':
command => 'restorecon -Rv /apache_spec',
path => '/bin:/usr/bin/:/sbin:/usr/sbin',
before => Service['httpd'],
require => Class['apache'],
require => [File['/apache_spec/apache_custom'], Class['apache']],
subscribe => Exec['set_apache_defaults'],
refreshonly => true,
}
}
file { '/apache_spec': ensure => directory, }
file { '/apache_spec/apache_custom': ensure => directory, }
file { ['/apache_spec', '/apache_spec/apache_custom']:
ensure => directory,
}
class { 'apache':
mod_dir => '/apache_spec/apache_custom/mods',
vhost_dir => '/apache_spec/apache_custom/vhosts',
Expand Down
27 changes: 12 additions & 15 deletions spec/acceptance/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1171,36 +1171,33 @@ class { 'apache::mod::wsgi': }

describe 'additional_includes' do
pp = <<-MANIFEST
if $::osfamily == 'RedHat' and "$::selinux" == "true" {
$semanage_package = $::operatingsystemmajrelease ? {
'6' => 'policycoreutils-python',
'7' => 'policycoreutils-python',
default => 'policycoreutils-python-utils',
}
package { $semanage_package: ensure => installed }
if $facts['osfamily'] == 'RedHat' and $facts['selinux'] {
exec { 'set_apache_defaults':
command => 'semanage fcontext -a -t httpd_sys_content_t "/apache_spec(/.*)?"',
command => 'semanage fcontext --add -t httpd_sys_content_t "/apache_spec/docroot(/.*)?"',
unless => 'semanage fcontext --list | grep /apache_spec/docroot | grep httpd_sys_content_t',
path => '/bin:/usr/bin/:/sbin:/usr/sbin',
require => Package[$semanage_package],
}
exec { 'restorecon_apache':
command => 'restorecon -Rv /apache_spec',
path => '/bin:/usr/bin/:/sbin:/usr/sbin',
before => Service['httpd'],
require => Class['apache'],
before => Service['httpd'],
require => [File['/apache_spec/include'], Class['apache']],
subscribe => Exec['set_apache_defaults'],
refreshonly => true,
}
}
class { 'apache': }
host { 'test.server': ip => '127.0.0.1' }
file { '/apache_spec': ensure => directory, }
file { ['/apache_spec', '/apache_spec/docroot']: ensure => directory, }
file { '/apache_spec/include': ensure => present, content => '#additional_includes' }
apache::vhost { 'test.server':
docroot => '/apache_spec',
docroot => '/apache_spec/docroot',
additional_includes => '/apache_spec/include',
}
MANIFEST
it 'applies cleanly' do
apply_manifest(pp, catch_failures: false)

it 'behaves idempotently' do
idempotent_apply(pp)
end

describe file("#{apache_hash['vhost_dir']}/25-test.server.conf") do
Expand Down
11 changes: 11 additions & 0 deletions spec/setup_acceptance_node.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
}
}

if $facts['selinux'] {
$semanage_package = $facts['os']['release']['major'] ? {
'6' => 'policycoreutils-python',
'7' => 'policycoreutils-python',
default => 'policycoreutils-python-utils',
}
package { $semanage_package:
ensure => installed,
}
}

if versioncmp($facts['os']['release']['major'], '8') >= 0 {
package { 'iproute':
ensure => installed,
Expand Down