|
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 | + /facts for my.client.cert/ |
| 101 | + ).with_content( |
| 102 | + /FQDN my.fq.hostname/ |
| 103 | + ).with_content( |
| 104 | + /Environment production/ |
| 105 | + ).with_content( |
| 106 | + /---/ |
| 107 | + ).with_validate_cmd( |
| 108 | + "/usr/bin/env ruby -ryaml -e \"YAML.load_file '%'\"" |
| 109 | + ) |
115 | 110 | end |
116 | 111 | end#no params |
117 | 112 | 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( |
| 113 | + let(:params) { {'custom_facts' => {'key1' => 'val1', 'key2' => 'val2'}} } |
| 114 | + it "should lay down #{facterbasepath}/facts.d/local.yaml" do |
| 115 | + should contain_file("#{facterbasepath}/facts.d/local.yaml").with({ |
| 116 | + :path=>"#{facterbasepath}/facts.d/local.yaml", |
| 117 | + :ensure=>'file', |
| 118 | + :owner=>'root', |
| 119 | + :group=>"#{facterbasepath_group}", |
| 120 | + :mode=>'0640' |
| 121 | + }).with_content( |
| 122 | + /facts for my.client.cert/ |
| 123 | + ).with_content( |
| 124 | + /FQDN my.fq.hostname/ |
| 125 | + ).with_content( |
| 126 | + /Environment production/ |
| 127 | + ).with_content( |
121 | 128 | /---/ |
122 | 129 | ).with_content( |
123 | 130 | /key1: val1/ |
|
129 | 136 | end |
130 | 137 | end#custom_facts set key values is string |
131 | 138 | 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( |
| 139 | + let(:params) { {'custom_facts' => {'key1' => [ 'val11', 'val12' ], 'key2' => [ 'val21', 'val22']}} } |
| 140 | + it "should lay down #{facterbasepath}/facts.d/local.yaml" do |
| 141 | + should contain_file("#{facterbasepath}/facts.d/local.yaml").with({ |
| 142 | + :path=>"#{facterbasepath}/facts.d/local.yaml", |
| 143 | + :ensure=>'file', |
| 144 | + :owner=>'root', |
| 145 | + :group=>"#{facterbasepath_group}", |
| 146 | + :mode=>'0640' |
| 147 | + }).with_content( |
| 148 | + /facts for my.client.cert/ |
| 149 | + ).with_content( |
| 150 | + /FQDN my.fq.hostname/ |
| 151 | + ).with_content( |
| 152 | + /Environment production/ |
| 153 | + ).with_content( |
135 | 154 | /---/ |
136 | 155 | ).with_content( |
137 | 156 | /key1:/ |
|
151 | 170 | end |
152 | 171 | end#custom_facts set key values is array |
153 | 172 | 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( |
| 173 | + let(:params) { {'custom_facts' => {'key1' => { 'key11' => 'val11' }, 'key2' => { 'key21' => 'val21'}}} } |
| 174 | + it "should lay down #{facterbasepath}/facts.d/local.yaml" do |
| 175 | + should contain_file("#{facterbasepath}/facts.d/local.yaml").with({ |
| 176 | + :path=>"#{facterbasepath}/facts.d/local.yaml", |
| 177 | + :ensure=>'file', |
| 178 | + :owner=>'root', |
| 179 | + :group=>"#{facterbasepath_group}", |
| 180 | + :mode=>'0640' |
| 181 | + }).with_content( |
| 182 | + /facts for my.client.cert/ |
| 183 | + ).with_content( |
| 184 | + /FQDN my.fq.hostname/ |
| 185 | + ).with_content( |
| 186 | + /Environment production/ |
| 187 | + ).with_content( |
157 | 188 | /---/ |
158 | 189 | ).with_content( |
159 | 190 | /key1:/ |
|
0 commit comments