Project

General

Profile

« Previous | Next » 

Revision 23978618

Added by Dominic Cleal almost 10 years ago

fixes #4700 - deploy directory environments on Puppet 3.6 or higher

- $server_dynamic_environments is deprecated when server_directory_environments
is enabled, set $server_environments = [] instead for a similar effect
- environment.conf deployed if custom manifest, config_version etc supplied to
puppet::server::env instead of puppet.conf fragment
- basemodulepath set in puppet.conf to the value of server_common_modules_path,
which had /etc/puppet/modules added to match the new Puppet default
- $environment_timeout added to puppet::server::env

View differences:

spec/defines/puppet_server_env_spec.rb
require 'spec_helper'
describe 'puppet::server::env' do
let(:title) { 'foo' }
let :facts do {
......
} end
context 'with no custom parameters' do
let :pre_condition do
"class {'puppet': server => true}"
context 'with directory environments' do
let :pre_condition do
"class {'puppet': server => true, server_directory_environments => true}"
end
it 'should only deploy directories' do
should contain_file('/etc/puppet/environments/foo').with({
:ensure => 'directory',
})
should contain_file('/etc/puppet/environments/foo/manifests').with({
:ensure => 'directory',
})
should contain_file('/etc/puppet/environments/foo/modules').with({
:ensure => 'directory',
})
should_not contain_file('/etc/puppet/environments/foo/environment.conf')
should_not contain_concat_fragment('puppet.conf+40-foo')
end
end
it 'should add an env section' do
should contain_file('/etc/puppet/environments/foo').with({
:ensure => 'directory',
})
should contain_file('/etc/puppet/environments/foo/modules').with({
:ensure => 'directory',
})
should contain_concat_fragment('puppet.conf+40-foo').
without_content(/^\s+manifest\s+=/).
without_content(/^\s+manifestdir\s+=/).
with_content(%r{^\s+modulepath\s+= /etc/puppet/environments/foo/modules:/etc/puppet/environments/common:/usr/share/puppet/modules$}).
without_content(/^\s+templatedir\s+=/).
with_content(/^\s+config_version\s+=/).
with({}) # So we can use a trailing dot on each with_content line
context 'with config environments' do
let :pre_condition do
"class {'puppet': server => true, server_directory_environments => false}"
end
it 'should add an env section' do
should contain_file('/etc/puppet/environments/foo').with({
:ensure => 'directory',
})
should contain_file('/etc/puppet/environments/foo/modules').with({
:ensure => 'directory',
})
should contain_concat_fragment('puppet.conf+40-foo').
without_content(/^\s+manifest\s+=/).
without_content(/^\s+manifestdir\s+=/).
with_content(%r{^\s+modulepath\s+= /etc/puppet/environments/foo/modules:/etc/puppet/environments/common:/etc/puppet/modules:/usr/share/puppet/modules$}).
without_content(/^\s+templatedir\s+=/).
with_content(/^\s+config_version\s+=/).
with({}) # So we can use a trailing dot on each with_content line
should_not contain_file('/etc/puppet/environments/foo/environment.conf')
end
end
end
context 'with server_config_version' do
let :pre_condition do
"class {'puppet': server => true, server_config_version => 'bar'}"
context 'with directory environments' do
let :pre_condition do
"class {'puppet': server => true, server_directory_environments => true, server_config_version => 'bar'}"
end
it 'should set config_version in environment.conf' do
should contain_file('/etc/puppet/environments/foo/environment.conf').
with_content(%r{\Aconfig_version\s+= bar\n\z}).
with({}) # So we can use a trailing dot on each with_content line
end
end
it 'should add an env section' do
should contain_file('/etc/puppet/environments/foo').with({
:ensure => 'directory',
})
should contain_file('/etc/puppet/environments/foo/modules').with({
:ensure => 'directory',
})
should contain_concat_fragment('puppet.conf+40-foo').
without_content(/^\s+manifest\s+=/).
without_content(/^\s+manifestdir\s+=/).
with_content(%r{^\s+modulepath\s+= /etc/puppet/environments/foo/modules:/etc/puppet/environments/common:/usr/share/puppet/modules$}).
without_content(/^\s+templatedir\s+=/).
with_content(/^\s+config_version\s+= bar/).
with({}) # So we can use a trailing dot on each with_content line
context 'with config environments' do
let :pre_condition do
"class {'puppet': server => true, server_directory_environments => false, server_config_version => 'bar'}"
end
it 'should add config_version to an env section' do
should contain_concat_fragment('puppet.conf+40-foo').
without_content(/^\s+manifest\s+=/).
without_content(/^\s+manifestdir\s+=/).
with_content(%r{^\s+modulepath\s+= /etc/puppet/environments/foo/modules:/etc/puppet/environments/common:/etc/puppet/modules:/usr/share/puppet/modules$}).
without_content(/^\s+templatedir\s+=/).
with_content(/^\s+config_version\s+= bar/).
with({}) # So we can use a trailing dot on each with_content line
end
end
end
context 'with config_version' do
let :pre_condition do
"class {'puppet': server => true, server_config_version => 'bar'}"
let :params do
{
:config_version => 'bar',
}
end
context 'with directory environments' do
let :pre_condition do
"class {'puppet': server => true, server_directory_environments => true}"
end
it 'should set config_version in environment.conf' do
should contain_file('/etc/puppet/environments/foo/environment.conf').
with_content(%r{\Aconfig_version\s+= bar\n\z}).
with({}) # So we can use a trailing dot on each with_content line
end
end
context 'with config environments' do
let :pre_condition do
"class {'puppet': server => true, server_directory_environments => false}"
end
it 'should add config_version to an env section' do
should contain_concat_fragment('puppet.conf+40-foo').
without_content(/^\s+manifest\s+=/).
without_content(/^\s+manifestdir\s+=/).
with_content(%r{^\s+modulepath\s+= /etc/puppet/environments/foo/modules:/etc/puppet/environments/common:/etc/puppet/modules:/usr/share/puppet/modules$}).
without_content(/^\s+templatedir\s+=/).
with_content(/^\s+config_version\s+= bar/).
with({}) # So we can use a trailing dot on each with_content line
end
end
end
context 'with modulepath' do
let :params do
{
:modulepath => ['/etc/puppet/example/modules', '/etc/puppet/vendor/modules'],
}
end
context 'with directory environments' do
let :pre_condition do
"class {'puppet': server => true, server_directory_environments => true}"
end
it 'should set modulepath in environment.conf' do
should contain_file('/etc/puppet/environments/foo/environment.conf').
with_content(%r{\Amodulepath\s+= /etc/puppet/example/modules:/etc/puppet/vendor/modules\n}).
with({}) # So we can use a trailing dot on each with_content line
end
end
end
context 'with undef modulepath' do
let :params do
{
:config_version => 'bar',
:modulepath => Undef.new,
}
end
it 'should add an env section' do
should contain_file('/etc/puppet/environments/foo').with({
:ensure => 'directory',
})
should contain_file('/etc/puppet/environments/foo/modules').with({
:ensure => 'directory',
})
should contain_concat_fragment('puppet.conf+40-foo').
without_content(/^\s+manifest\s+=/).
without_content(/^\s+manifestdir\s+=/).
with_content(%r{^\s+modulepath\s+= /etc/puppet/environments/foo/modules:/etc/puppet/environments/common:/usr/share/puppet/modules$}).
without_content(/^\s+templatedir\s+=/).
with_content(/^\s+config_version\s+= bar/).
with({}) # So we can use a trailing dot on each with_content line
context 'with directory environments' do
let :pre_condition do
"class {'puppet': server => true, server_directory_environments => true}"
end
it { should_not contain_file('/etc/puppet/environments/foo/environment.conf') }
end
end
context 'with manifest' do
let :params do
{
:manifest => 'manifests/local.pp',
}
end
context 'with directory environments' do
let :pre_condition do
"class {'puppet': server => true, server_directory_environments => true}"
end
it 'should set manifest in environment.conf' do
should contain_file('/etc/puppet/environments/foo/environment.conf').
with_content(%r{\Amanifest\s+= manifests/local.pp\n\z}).
with({}) # So we can use a trailing dot on each with_content line
end
end
end
context 'with environment_timeout' do
let :params do
{
:environment_timeout => 'unlimited',
}
end
context 'with directory environments' do
let :pre_condition do
"class {'puppet': server => true, server_directory_environments => true}"
end
it 'should set environment_timeout in environment.conf' do
should contain_file('/etc/puppet/environments/foo/environment.conf').
with_content(%r{\Aenvironment_timeout\s+= unlimited\n\z}).
with({}) # So we can use a trailing dot on each with_content line
end
end
end
end

Also available in: Unified diff