Skip to content

Commit 235a114

Browse files
committed
changed vars to be parameters defaulting from puppet::master and added rspec tests
1 parent 036326b commit 235a114

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

manifests/masterenv.pp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,19 @@
1818
# manifest => 'dev'
1919
# }
2020
#
21-
define puppet::masterenv ($modulepath, $manifest, $puppet_conf = $::puppet::params::puppet_conf){
21+
define puppet::masterenv (
22+
$modulepath,
23+
$manifest,
24+
$puppet_conf = $::puppet::params::puppet_conf,
25+
$environments = $::puppet::master::environments,
26+
$environmentpath = $::puppet::master::environmentpath
27+
) {
2228

23-
case $::puppet::master::environments {
29+
case $environments {
2430
'directory': {
25-
$path = "${::puppet::master::environmentpath}/${name}/environment.conf"
31+
$path = "${environmentpath}/${name}/environment.conf"
2632
$section = ''
27-
file { "${::puppet::master::environmentpath}/${name}":
33+
file { "${environmentpath}/${name}":
2834
ensure => directory,
2935
}
3036
}

spec/defines/puppet_masterenv_spec.rb

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'spec_helper'
22

33
describe 'puppet::masterenv', :type => :define do
4-
context "Create environment" do
4+
context "Create config environment" do
55
let :title do
66
'dev'
77
end
@@ -30,4 +30,38 @@
3030
)
3131
}
3232
end
33+
context "Create directory environment" do
34+
let :title do
35+
'dev'
36+
end
37+
38+
let :params do
39+
{
40+
:manifest => '/etc/puppet/environments/dev.pp',
41+
:modulepath => '/etc/puppet/environments/modules/',
42+
:puppet_conf => '/etc/puppet/puppet.conf',
43+
:environments => 'directory',
44+
:environmentpath => '/etc/puppet/environments'
45+
}
46+
end
47+
it {
48+
should contain_ini_setting("masterenvmodule#{title}").with(
49+
:ensure => 'present',
50+
:section => '',
51+
:setting => 'modulepath',
52+
:path => '/etc/puppet/environments/dev/environment.conf',
53+
:value => params[:modulepath]
54+
)
55+
should contain_ini_setting("masterenvmanifest#{title}").with(
56+
:ensure => 'present',
57+
:section => '',
58+
:setting => 'manifest',
59+
:path => '/etc/puppet/environments/dev/environment.conf',
60+
:value => params[:manifest]
61+
)
62+
should contain_file("/etc/puppet/environments/dev").with(
63+
:ensure => 'directory'
64+
)
65+
}
66+
end
3367
end

0 commit comments

Comments
 (0)