Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update yaml location for >PE3 #343

Merged
merged 2 commits into from
Mar 7, 2017
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
30 changes: 15 additions & 15 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,26 @@
# Charlie Sharpsteen <source@sharpsteen.net>
# Zack Smith <zack@puppetlabs.com>
class r10k::config (
$configfile,
$cachedir,
Boolean $manage_modulepath,
$root_user,
$root_group,
$modulepath = undef,
$remote = '',
Variant[String, Hash ] $sources = 'UNSET',
Optional[Array] $postrun = undef,
Stdlib::Absolutepath $puppetconf_path = $r10k::params::puppetconf_path,
$configfile = $r10k::params::r10k_config_file,
$cachedir = $r10k::params::r10k_cache_dir,
Optional[Hash] $sources = $r10k::params::sources,
$modulepath = $r10k::params::modulepath,
$remote = $r10k::params::remote,
Boolean $manage_modulepath = $r10k::params::manage_modulepath,
Stdlib::Absolutepath $r10k_basedir = $r10k::params::r10k_basedir,
Boolean $manage_configfile_symlink = $r10k::params::manage_configfile_symlink,
Stdlib::Absolutepath $configfile_symlink = '/etc/r10k.yaml',
Stdlib::Absolutepath $configfile_symlink = $r10k::params::configfile_symlink,
Hash $git_settings = $r10k::params::git_settings,
Hash $forge_settings = $r10k::params::forge_settings,
Hash $deploy_settings = $r10k::params::deploy_settings,
Optional[Array] $postrun = undef,
$root_user = $r10k::params::root_user,
$root_group = $r10k::params::root_group,
Stdlib::Absolutepath $puppetconf_path = $r10k::params::puppetconf_path,
String $r10k_yaml_template = 'r10k/r10k.yaml.erb',
Hash $git_settings = {},
Hash $forge_settings = {},
Hash $deploy_settings = {},
) inherits r10k::params {

if $sources == 'UNSET' {
if $sources == undef {
$r10k_sources = {
'puppet' => {
'remote' => $remote,
Expand Down
33 changes: 12 additions & 21 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
$sources = undef
$puppet_master = true

if versioncmp("${::puppetversion}", '4.0.0') >= 0 { #lint:ignore:only_variable_string
$r10k_basedir = $::settings::environmentpath
$r10k_cache_dir = "${::settings::vardir}/r10k"
} else {
$r10k_basedir = "${::settings::confdir}/environments"
$r10k_cache_dir = '/var/cache/r10k'
}
$r10k_basedir = $::settings::environmentpath
$r10k_cache_dir = "${::settings::vardir}/r10k"
$r10k_config_file = '/etc/puppetlabs/r10k/r10k.yaml'
$r10k_binary = 'r10k'
$puppetconf_path = '/etc/puppetlabs/puppet'
$manage_configfile_symlink = false
$configfile_symlink = '/etc/r10k.yaml'
$git_settings = {}
Expand Down Expand Up @@ -59,24 +57,20 @@
}

if getvar('::pe_server_version') {
#if $is_pe_server and versioncmp("${::puppetversion}", '4.0.0') >= 0 { #lint:ignore:only_variable_string
# PE 4 or greater specific settings
# r10k configuration
$r10k_config_file = '/etc/r10k.yaml'

$puppetconf_path = '/etc/puppetlabs/puppet'

$pe_module_path = '/opt/puppetlabs/puppet/modules'

# Mcollective configuration dynamic
$mc_service_name = 'mcollective'
$plugins_dir = '/opt/puppetlabs/mcollective/plugins/mcollective'
$r10k_binary = 'r10k'
$modulepath = "${r10k_basedir}/\$environment/modules:${pe_module_path}"

# webhook
$webhook_user = 'peadmin'
$webhook_pass = 'peadmin'
$webhook_group = 'peadmin'
$webhook_user = 'peadmin'
$webhook_pass = 'peadmin'
$webhook_group = 'peadmin'
$webhook_public_key_path = '/var/lib/peadmin/.mcollective.d/peadmin-cert.pem'
$webhook_private_key_path = '/var/lib/peadmin/.mcollective.d/peadmin-private.pem'
$webhook_certname = 'peadmin'
Expand All @@ -87,21 +81,18 @@
elsif versioncmp("${::puppetversion}", '4.0.0') >= 0 { #lint:ignore:only_variable_string
#FOSS 4 or greater specific settings
# r10k configuration
$r10k_config_file = '/etc/puppetlabs/r10k/r10k.yaml'

$puppetconf_path = '/etc/puppetlabs/puppet'
$module_path = '/opt/puppetlabs/puppet/code/modules'

# Mcollective configuration dynamic
$mc_service_name = 'mcollective'
$plugins_dir = '/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/mcollective'
$modulepath = undef
$r10k_binary = 'r10k'

# webhook
$webhook_user = 'puppet'
$webhook_pass = 'puppet'
$webhook_group = 'puppet'
$webhook_user = 'puppet'
$webhook_pass = 'puppet'
$webhook_group = 'puppet'
$webhook_public_key_path = undef
$webhook_private_key_path = undef
$webhook_certname = undef
Expand Down
121 changes: 27 additions & 94 deletions spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
facts
end

context 'on Puppet Opensource' do
context 'with defaults' do
it { is_expected.to compile.with_all_deps }
end

context 'modified file locations and ownership' do
let :params do
{
configfile: '/etc/r10k.yaml',
Expand All @@ -27,92 +31,28 @@
path: '/etc/r10k.yaml'
)
end
it { is_expected.to contain_file('r10k.yaml').without_content(%r{^:postrun: .*$}) }
it { is_expected.not_to contain_ini_setting('R10k Modulepath') }
end

describe 'with manage_configfile_symlink' do
context 'set to value true and a configfile specified' do
let :params do
{
manage_configfile_symlink: true,
configfile: '/etc/puppet/r10k.yaml',
cachedir: '/var/cache/r10k',
manage_modulepath: false,
root_user: 'root',
root_group: 'root'
}
end

it do
is_expected.to contain_file('symlink_r10k.yaml').with(
ensure: 'link',
path: '/etc/r10k.yaml',
target: '/etc/puppet/r10k.yaml'
)
end
end

context 'set to value false and a configfile specified' do
let :params do
{
manage_configfile_symlink: false,
configfile: '/etc/puppet/r10k.yaml',
cachedir: '/var/cache/r10k',
manage_modulepath: false,
root_user: 'root',
root_group: 'root'
}
end

it { is_expected.not_to contain_file('symlink_r10k.yaml') }
end

context 'set to a non-boolean value' do
let :params do
{
manage_configfile_symlink: 'invalid',
configfile: '/etc/r10k.yaml',
cachedir: '/var/cache/r10k',
manage_modulepath: false,
root_user: 'root',
root_group: 'root'
}
end

it 'fails' do
expect { catalogue }.to raise_error(Puppet::Error)
end
end
end

context 'with configfile_symlink specified as a non fully qualified path' do
context 'set to value true and a configfile specified' do
let :params do
{
manage_configfile_symlink: true,
configfile: '/etc/r10k.yaml',
configfile_symlink: 'invalid/path',
cachedir: '/var/cache/r10k',
manage_modulepath: false,
root_user: 'root',
root_group: 'root'
manage_configfile_symlink: true
}
end

it 'fails' do
expect { catalogue }.to raise_error(Puppet::Error)
it do
is_expected.to contain_file('symlink_r10k.yaml').with(
ensure: 'link',
path: '/etc/r10k.yaml',
target: '/etc/puppetlabs/r10k/r10k.yaml'
)
end
end

context 'Managing r10k with rugged turned on via git_settings' do
let :params do
{
configfile: '/etc/r10k.yaml',
cachedir: '/var/cache/r10k',
manage_modulepath: false,
git_settings: { 'provider' => 'rugged', 'private_key' => '/root/.ssh/id_dsa' },
root_user: 'root',
root_group: 'root'
git_settings: { 'provider' => 'rugged', 'private_key' => '/root/.ssh/id_dsa' }
}
end

Expand All @@ -122,33 +62,26 @@
context 'manage forge settings of r10k via forge_settings' do
let :params do
{
configfile: '/etc/r10k.yaml',
cachedir: '/var/cache/r10k',
manage_modulepath: false,
forge_settings: { 'proxy' => 'https://proxy.example.com:3128', 'baseurl' => 'https://forgeapi.puppetlabs.com' },
root_user: 'root',
root_group: 'root'
forge_settings: { 'proxy' => 'https://proxy.example.com:3128', 'baseurl' => 'https://forgeapi.puppetlabs.com' }
}
end

it { is_expected.to contain_file('r10k.yaml').with_content(%r{forge:\n.*baseurl: https:\/\/forgeapi\.puppetlabs\.com\n.*proxy: https:\/\/proxy\.example\.com:3128\n}) }
end

describe 'with optional parameter postrun specified' do
context 'with array of system call "/usr/bin/curl -F deploy=done http://my-app.site/endpoint"' do
let :params do
{
configfile: '/etc/r10k.yaml',
cachedir: '/var/cache/r10k',
manage_modulepath: false,
postrun: ['/usr/bin/curl', '-F', 'deploy=done', 'http://my-app.site/endpoint'],
root_user: 'root',
root_group: 'root'
}
end

it { is_expected.to contain_file('r10k.yaml').with_content(%r{^.*:postrun: \[\"/usr/bin/curl\", \"-F\", \"deploy=done\", \"http://my-app\.site/endpoint\"\]\n.*$}) }
context 'with optional parameter postrun specified with array of system call "/usr/bin/curl -F deploy=done http://my-app.site/endpoint"' do
let :params do
{
configfile: '/etc/r10k.yaml',
cachedir: '/var/cache/r10k',
manage_modulepath: false,
postrun: ['/usr/bin/curl', '-F', 'deploy=done', 'http://my-app.site/endpoint'],
root_user: 'root',
root_group: 'root'
}
end

it { is_expected.to contain_file('r10k.yaml').with_content(%r{^.*:postrun: \[\"/usr/bin/curl\", \"-F\", \"deploy=done\", \"http://my-app\.site/endpoint\"\]\n.*$}) }
end
end
end
Expand Down