|
77 | 77 | :clientcert => 'my.client.cert', |
78 | 78 | :fqdn => 'my.fq.hostname', |
79 | 79 | :environment => 'production', |
80 | | - :puppetversion => Puppet.version |
| 80 | + :puppetversion => Puppet.version |
81 | 81 | }) |
82 | 82 | end |
83 | 83 | it { is_expected.to compile.with_all_deps } |
84 | 84 | if Puppet.version.to_f >= 4.0 |
85 | 85 | facterbasepath = '/opt/puppetlabs/facter' |
| 86 | + facterbasepath_group = 'root' |
86 | 87 | else |
87 | 88 | facterbasepath = '/etc/facter' |
| 89 | + facterbasepath_group = 'puppet' |
88 | 90 | end |
89 | 91 | context 'when fed no parameters' do |
90 | | - if Puppet.version.to_f >= 4.0 |
91 | | - # setting environemnt doesn't work in puppet 4 |
92 | | - it "should lay down #{facterbasepath}/facts.d/local.yaml" do |
93 | | - should contain_file("#{facterbasepath}/facts.d/local.yaml").with_content( |
94 | | - /facts for my.client.cert/ |
95 | | - ).with_content( |
96 | | - /FQDN my.fq.hostname/ |
97 | | - ).with_validate_cmd( |
98 | | - "/usr/bin/env ruby -ryaml -e \"YAML.load_file '%'\"" |
99 | | - )#.with_content( |
100 | | - # /Environment production/ |
101 | | - #) |
102 | | - end |
103 | | - else |
104 | | - it "should lay down #{facterbasepath}/facts.d/local.yaml" do |
105 | | - should contain_file("#{facterbasepath}/facts.d/local.yaml").with_content( |
106 | | - /facts for my.client.cert/ |
107 | | - ).with_content( |
108 | | - /FQDN my.fq.hostname/ |
109 | | - ).with_content( |
110 | | - /Environment production/ |
111 | | - ).with_validate_cmd( |
112 | | - "/usr/bin/env ruby -ryaml -e \"YAML.load_file '%'\"" |
113 | | - ) |
114 | | - end |
| 92 | + it "should lay down #{facterbasepath}/facts.d/local.yaml" do |
| 93 | + should contain_file("#{facterbasepath}/facts.d/local.yaml").with({ |
| 94 | + :path=>"#{facterbasepath}/facts.d/local.yaml", |
| 95 | + :ensure=>'file', |
| 96 | + :owner=>'root', |
| 97 | + :group=>"#{facterbasepath_group}", |
| 98 | + :mode=>'0640' |
| 99 | + }).with_content( |
| 100 | + /custom facts for my.client.cert/ |
| 101 | + ).with_content( |
| 102 | + /FQDN my.fq.hostname/ |
| 103 | + ).with_content( |
| 104 | + /---/ |
| 105 | + ).with_validate_cmd( |
| 106 | + "/usr/bin/env ruby -ryaml -e \"YAML.load_file '%'\"" |
| 107 | + ) |
| 108 | + should contain_file("#{facterbasepath}/facts.d/local.yaml").with_content( |
| 109 | + /Environment production/ |
| 110 | + ) if Puppet.version.to_f < 4.0 # setting environemnt doesn't work in puppet 4 |
115 | 111 | end |
116 | 112 | end#no params |
117 | 113 | context 'when the custom_facts parameter is properly set key values is string' do |
118 | | - let(:params) {{'custom_facts' => {'key1' => 'val1', 'key2' => 'val2'}}} |
119 | | - it 'should iterate through the hash and properly populate the local_facts.yaml file' do |
120 | | - should contain_file("#{facterbasepath}/facts.d/local.yaml").with_content( |
| 114 | + let(:params) { {'custom_facts' => {'key1' => 'val1', 'key2' => 'val2'}} } |
| 115 | + it "should lay down #{facterbasepath}/facts.d/local.yaml" do |
| 116 | + should contain_file("#{facterbasepath}/facts.d/local.yaml").with({ |
| 117 | + :path=>"#{facterbasepath}/facts.d/local.yaml", |
| 118 | + :ensure=>'file', |
| 119 | + :owner=>'root', |
| 120 | + :group=>"#{facterbasepath_group}", |
| 121 | + :mode=>'0640' |
| 122 | + }).with_content( |
| 123 | + /custom facts for my.client.cert/ |
| 124 | + ).with_content( |
| 125 | + /FQDN my.fq.hostname/ |
| 126 | + ).with_content( |
121 | 127 | /---/ |
122 | 128 | ).with_content( |
123 | 129 | /key1: val1/ |
|
126 | 132 | ).with_validate_cmd( |
127 | 133 | "/usr/bin/env ruby -ryaml -e \"YAML.load_file '%'\"" |
128 | 134 | ) |
| 135 | + should contain_file("#{facterbasepath}/facts.d/local.yaml").with_content( |
| 136 | + /Environment production/ |
| 137 | + ) if Puppet.version.to_f < 4.0 # setting environemnt doesn't work in puppet 4 |
129 | 138 | end |
130 | 139 | end#custom_facts set key values is string |
131 | 140 | context 'when the custom_facts parameter is properly set key values is array' do |
132 | | - let(:params) {{'custom_facts' => {'key1' => [ 'val11', 'val12' ], 'key2' => [ 'val21', 'val22']}}} |
133 | | - it 'should iterate through the hash and properly populate the local_facts.yaml file' do |
134 | | - should contain_file("#{facterbasepath}/facts.d/local.yaml").with_content( |
| 141 | + let(:params) { {'custom_facts' => {'key1' => [ 'val11', 'val12' ], 'key2' => [ 'val21', 'val22']}} } |
| 142 | + it "should lay down #{facterbasepath}/facts.d/local.yaml" do |
| 143 | + should contain_file("#{facterbasepath}/facts.d/local.yaml").with({ |
| 144 | + :path=>"#{facterbasepath}/facts.d/local.yaml", |
| 145 | + :ensure=>'file', |
| 146 | + :owner=>'root', |
| 147 | + :group=>"#{facterbasepath_group}", |
| 148 | + :mode=>'0640' |
| 149 | + }).with_content( |
| 150 | + /custom facts for my.client.cert/ |
| 151 | + ).with_content( |
| 152 | + /FQDN my.fq.hostname/ |
| 153 | + ).with_content( |
135 | 154 | /---/ |
136 | 155 | ).with_content( |
137 | 156 | /key1:/ |
|
148 | 167 | ).with_validate_cmd( |
149 | 168 | "/usr/bin/env ruby -ryaml -e \"YAML.load_file '%'\"" |
150 | 169 | ) |
| 170 | + should contain_file("#{facterbasepath}/facts.d/local.yaml").with_content( |
| 171 | + /Environment production/ |
| 172 | + ) if Puppet.version.to_f < 4.0 # setting environemnt doesn't work in puppet 4 |
151 | 173 | end |
152 | 174 | end#custom_facts set key values is array |
153 | 175 | context 'when the custom_facts parameter is properly set key values is hash' do |
154 | | - let(:params) {{'custom_facts' => {'key1' => { 'key11' => 'val11' }, 'key2' => { 'key21' => 'val21'}}}} |
155 | | - it 'should iterate through the hash and properly populate the local_facts.yaml file' do |
156 | | - should contain_file("#{facterbasepath}/facts.d/local.yaml").with_content( |
| 176 | + let(:params) { {'custom_facts' => {'key1' => { 'key11' => 'val11' }, 'key2' => { 'key21' => 'val21'}}} } |
| 177 | + it "should lay down #{facterbasepath}/facts.d/local.yaml" do |
| 178 | + should contain_file("#{facterbasepath}/facts.d/local.yaml").with({ |
| 179 | + :path=>"#{facterbasepath}/facts.d/local.yaml", |
| 180 | + :ensure=>'file', |
| 181 | + :owner=>'root', |
| 182 | + :group=>"#{facterbasepath_group}", |
| 183 | + :mode=>'0640' |
| 184 | + }).with_content( |
| 185 | + /custom facts for my.client.cert/ |
| 186 | + ).with_content( |
| 187 | + /FQDN my.fq.hostname/ |
| 188 | + ).with_content( |
157 | 189 | /---/ |
158 | 190 | ).with_content( |
159 | 191 | /key1:/ |
|
166 | 198 | ).with_validate_cmd( |
167 | 199 | "/usr/bin/env ruby -ryaml -e \"YAML.load_file '%'\"" |
168 | 200 | ) |
| 201 | + should contain_file("#{facterbasepath}/facts.d/local.yaml").with_content( |
| 202 | + /Environment production/ |
| 203 | + ) if Puppet.version.to_f < 4.0 # setting environemnt doesn't work in puppet 4 |
169 | 204 | end |
170 | 205 | end#custom_facts set key values is hash |
171 | 206 | end |
|
0 commit comments