Project

General

Profile

Download (3.38 KB) Statistics
| Branch: | Tag: | Revision:
require 'spec_helper_acceptance'

describe 'Scenario: install foreman with journald' do
before(:context) do
case fact('osfamily')
when 'RedHat'
on default, 'yum -y remove foreman* tfm-* && rm -rf /etc/yum.repos.d/foreman*.repo'
on default, 'service httpd stop', { :acceptable_exit_codes => [0, 5] }
when 'Debian'
on default, 'apt-get purge -y foreman*', { :acceptable_exit_codes => [0, 100] }
on default, 'apt-get purge -y ruby-hammer-cli-*', { :acceptable_exit_codes => [0, 100] }
on default, 'rm -rf /etc/apt/sources.list.d/foreman*'
on default, 'service apache2 stop', { :acceptable_exit_codes => [0, 5] }
end
end

service_name = ['debian', 'ubuntu'].include?(os[:family]) ? 'apache2' : 'httpd'

let(:pp) do
<<-EOS
# Workarounds

## Ensure repos are present before installing
Yumrepo <| |> -> Package <| |>

## We want passenger from EPEL
class { '::apache::mod::passenger':
manage_repo => false,
}

$directory = '/etc/foreman'
$certificate = "${directory}/certificate.pem"
$key = "${directory}/key.pem"
exec { 'Create certificate directory':
command => "mkdir -p ${directory}",
path => ['/bin', '/usr/bin'],
creates => $directory,
} ->
exec { 'Generate certificate':
command => "openssl req -nodes -x509 -newkey rsa:2048 -subj '/CN=${facts['fqdn']}' -keyout '${key}' -out '${certificate}' -days 365",
path => ['/bin', '/usr/bin'],
creates => $certificate,
umask => '0022',
} ->
file { [$key, $certificate]:
owner => 'root',
group => 'root',
mode => '0640',
} ->
class { '::foreman':
repo => 'nightly',
user_groups => [],
initial_admin_username => 'admin',
initial_admin_password => 'changeme',
server_ssl_ca => $certificate,
server_ssl_chain => $certificate,
server_ssl_cert => $certificate,
server_ssl_key => $key,
server_ssl_crl => '',
logging_type => 'journald',
}
EOS
end

it_behaves_like 'a idempotent resource'

describe service(service_name) do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe service('dynflowd') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe package('foreman-journald') do
it { is_expected.to be_installed }
end

describe port(80) do
it { is_expected.to be_listening }
end

describe port(443) do
it { is_expected.to be_listening }
end

describe command("curl -s --cacert /etc/foreman/certificate.pem https://#{host_inventory['fqdn']} -w '\%{redirect_url}' -o /dev/null") do
its(:stdout) { is_expected.to eq("https://#{host_inventory['fqdn']}/users/login") }
end

# Logging to the journal is broken on Travis and EL7 but works in Vagrant VMs
# and regular docker containers
describe command("journalctl -u #{service_name}"), unless: ENV['TRAVIS'] == 'true' && os[:family] == 'redhat' && os[:release] =~ /^7\./ do
its(:stdout) { is_expected.to match(%r{Redirected to https://#{host_inventory['fqdn']}/users/login}) }
end

describe command('journalctl -u dynflowd'), unless: ENV['TRAVIS'] == 'true' && os[:family] == 'redhat' && os[:release] =~ /^7\./ do
its(:stdout) { is_expected.to match(%r{Dynflow Executor: start in progress}) }
end
end
(4-4/6)