Project

General

Profile

« Previous | Next » 

Revision 1441db01

Added by Ewoud Kohl van Wijngaarden over 7 years ago

Simplify fact usage

View differences:

spec/classes/puppet_server_config_spec.rb
require 'spec_helper'
describe 'puppet::server::config' do
on_os_under_test.each do |os, os_facts|
next if os_facts[:osfamily] == 'windows'
next if os_facts[:osfamily] == 'Archlinux'
on_os_under_test.each do |os, facts|
next if facts[:osfamily] == 'windows'
next if facts[:osfamily] == 'Archlinux'
context "on #{os}" do
let (:default_facts) do
os_facts.merge({
:clientcert => 'puppetmaster.example.com',
:concat_basedir => '/nonexistant',
:fqdn => 'puppetmaster.example.com',
:puppetversion => Puppet.version,
}) end
if Puppet.version < '4.0'
codedir = '/etc/puppet'
confdir = '/etc/puppet'
......
additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'}
end
if os_facts[:osfamily] == 'FreeBSD'
if facts[:osfamily] == 'FreeBSD'
codedir = '/usr/local/etc/puppet'
confdir = '/usr/local/etc/puppet'
conf_file = '/usr/local/etc/puppet/puppet.conf'
......
additional_facts = {}
end
let(:facts) { default_facts.merge(additional_facts) }
let(:facts) do
facts.merge({:clientcert => 'puppetmaster.example.com'}).merge(additional_facts)
end
describe 'with no custom parameters' do
let :pre_condition do
......
})
end
context 'with non-AIO packages', :if => (Puppet.version < '4.0' || os_facts[:osfamily] == 'FreeBSD') do
context 'with non-AIO packages', :if => (Puppet.version < '4.0' || facts[:osfamily] == 'FreeBSD') do
it 'CA cert generation should notify the Apache service' do
should contain_exec('puppet_server_config-generate_ca_cert').that_notifies('Service[httpd]')
end
end
context 'with AIO packages', :if => (Puppet.version > '4.0' && os_facts[:osfamily] != 'FreeBSD') do
context 'with AIO packages', :if => (Puppet.version > '4.0' && facts[:osfamily] != 'FreeBSD') do
it 'CA cert generation should notify the puppetserver service' do
should contain_exec('puppet_server_config-generate_ca_cert').that_notifies('Service[puppetserver]')
end
......
it 'should set up the ENC' do
should contain_class('foreman::puppetmaster').with({
:foreman_url => "https://puppetmaster.example.com",
:foreman_url => "https://foo.example.com",
:receive_facts => true,
:puppet_home => puppetserver_vardir,
:puppet_etcdir => etcdir,

Also available in: Unified diff