kitchen-puppet 3.4.2 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +283 -283
- data/kitchen-puppet.gemspec +33 -32
- data/lib/kitchen-puppet/version.rb +7 -7
- data/lib/kitchen/provisioner/puppet/librarian.rb +111 -111
- data/lib/kitchen/provisioner/puppet/r10k.rb +73 -73
- data/lib/kitchen/provisioner/puppet_agent.rb +430 -430
- data/lib/kitchen/provisioner/puppet_apply.rb +1465 -1465
- data/lib/kitchen/provisioner/puppet_bolt.rb +307 -307
- data/provisioner_options.md +412 -411
- metadata +19 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7fcc49522264bb6d83cee5a31000c140d83536f2507a68c692ff8380151eb1c
|
4
|
+
data.tar.gz: 10a29639fe65b203126924043bea21985079a30474ee5e96845740607fb0fe6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5ca8e7313984cfeb090cabab0ba60dde71b9e1914716a14ddf740b8b5d0fda16bd830b589c8b518c890af019d3a9d86d542849cb0ea2d2058e4d7a9b8285cf8
|
7
|
+
data.tar.gz: 3ccff74e15853f85b39d588c630c6378d4f75ea3d776d5b383fa780cf27e31fc20f096c6ef65c18edd848f21a74bf91c79842c3eef13563e4893e03102a9d8f2
|
data/README.md
CHANGED
@@ -1,283 +1,283 @@
|
|
1
|
-
# Kitchen Puppet
|
2
|
-
|
3
|
-
[](http://badge.fury.io/rb/kitchen-puppet)
|
4
|
-
[](https://rubygems.org/gems/kitchen-puppet)
|
5
|
-
[](https://travis-ci.org/neillturner/kitchen-puppet)
|
6
|
-
|
7
|
-
# kitchen-puppet
|
8
|
-
A Test Kitchen Provisioner for Puppet
|
9
|
-
|
10
|
-
The providers supports both puppet apply and puppet agent clients and puppet bolt.
|
11
|
-
|
12
|
-
The PuppetApply provider works by passing the puppet repository based on attributes in .kitchen.yml & calling puppet apply.
|
13
|
-
|
14
|
-
The PuppetAgent provider works by passing the puppetmaster and other attributes in .kitchen.yml & calling puppet agent.
|
15
|
-
|
16
|
-
The PuppetBolt provider works by passing the puppet bolt commands based on attributes in .kitchen.yml & calling puppet bolt.
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
This provider has been tested against the Ubuntu 1604 and Centos 7 boxes running in docker and vagrant/virtualbox.
|
21
|
-
|
22
|
-
## Template
|
23
|
-
|
24
|
-
Template project for using kitchen for puppet development:
|
25
|
-
|
26
|
-
https://github.com/scoopex/puppet-kitchen_template
|
27
|
-
|
28
|
-
## Resources
|
29
|
-
* http://ehaselwanter.com/en/blog/2014/05/08/using-test-kitchen-with-puppet
|
30
|
-
* http://www.slideshare.net/MartinEtmajer/testdriven-infrastructure-with-puppet-test-kitchen-serverspec-and-rspec
|
31
|
-
* http://www.slideshare.net/YuryTsarev/containercon-test-driven-infrastructure
|
32
|
-
* http://events.linuxfoundation.org/sites/events/files/slides/ContainerCon%20-%20Test%20Driven%20Infrastructure_0.pdf
|
33
|
-
* https://www.cedric-meury.ch/2016/10/test-driven-infrastructure-with-puppet-docker-test-kitchen-and-serverspec-yury-tsarev-gooddata
|
34
|
-
* https://docs.puppet.com/puppet/latest/puppet_platform.html
|
35
|
-
|
36
|
-
## Install
|
37
|
-
|
38
|
-
1. install the latest Ruby on your workstations (for windows see https://rubyinstaller.org/downloads/)
|
39
|
-
|
40
|
-
2. From a Command prompt:
|
41
|
-
* gem install librarian-puppet
|
42
|
-
* gem install test-kitchen (or gem install test-kitchen -v 1.16.0 if using ruby version less than 2.3)
|
43
|
-
* gem install kitchen-puppet
|
44
|
-
|
45
|
-
## Requirements
|
46
|
-
It is recommended to have a metadata.json file of your puppet module. It is used by kitchen-puppet to configure the module path.
|
47
|
-
The puppet docs describe (https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html#write-a-metadatajson-file) how to create one.
|
48
|
-
|
49
|
-
You'll need a driver box without a chef installation so puppet can be installed. Puppet have one at http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box or http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box.
|
50
|
-
|
51
|
-
For PuppetAgent a server with a puppet master is required that can resolve the hostname ip address of the server. The server must also be able to resolve the hostname ip address of the puppet master.
|
52
|
-
|
53
|
-
You can also use the PuppetApply driver with a docker container, provided the necessary box requirements to install puppet are included inside the container. The easiest way to do this is to supply Kitchen-Docker with a custom dockerfile to install the needed dependencies for puppet installation.
|
54
|
-
|
55
|
-
## Windows Support
|
56
|
-
|
57
|
-
There is windows/winrm support, currently not all functionality is supported.
|
58
|
-
* `require_chef_for_busser: false` (it is possible to call rspec over winrm to run the tests)
|
59
|
-
* `resolve_with_librarian_puppet: false` (librarian-puppet is not working on windows server)
|
60
|
-
|
61
|
-
Sample Puppet Repositories
|
62
|
-
* A sample hello world example puppet repository: https://github.com/neillturner/puppet_windows_repo
|
63
|
-
* A sample hello world example puppet repository for vagrant: https://github.com/neillturner/puppet_vagrant_windows_repo
|
64
|
-
* A more extensive sample installing virtualbox on windows: https://github.com/red-gate/puppet-virtualbox_windows
|
65
|
-
|
66
|
-
## Using Environments
|
67
|
-
|
68
|
-
In the root directory for your puppet repository:
|
69
|
-
|
70
|
-
Create a `.kitchen.yml`, much like one the described above:
|
71
|
-
|
72
|
-
```yaml
|
73
|
-
---
|
74
|
-
driver:
|
75
|
-
name: vagrant
|
76
|
-
|
77
|
-
provisioner:
|
78
|
-
name: puppet_apply
|
79
|
-
puppet_environment: dev
|
80
|
-
# the puppet environmnt files can be in this repository
|
81
|
-
puppet_environment_config_path: environment/dev/environment.conf
|
82
|
-
manifests_path: environment/dev/manifests
|
83
|
-
modules_path: environment/dev/modules_mycompany
|
84
|
-
# or external to this repository as long as they are accessible
|
85
|
-
# puppet_environment_config_path: /my_environments/dev/environment.conf
|
86
|
-
# manifests_path: /my_environments/dev/manifests
|
87
|
-
# modules_path: /my_environments/dev/modules_mycompany
|
88
|
-
hiera_data_path: /repository/puppet_repo/hieradata
|
89
|
-
|
90
|
-
platforms:
|
91
|
-
- name: nocm_ubuntu-12.04
|
92
|
-
driver_plugin: vagrant
|
93
|
-
driver_config:
|
94
|
-
box: nocm_ubuntu-12.04
|
95
|
-
box_url: http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
|
96
|
-
|
97
|
-
suites:
|
98
|
-
- name: default
|
99
|
-
```
|
100
|
-
|
101
|
-
Sample Puppet Repositories
|
102
|
-
* A sample hello world example puppet repository with docker : https://github.com/neillturner/puppet_docker_repo
|
103
|
-
* A sample hello world example puppet repository without environents : https://github.com/neillturner/puppet_vagrant_repo
|
104
|
-
* A sample hello world example puppet repository with environents : https://github.com/neillturner/puppet_vagrant_environment_repo
|
105
|
-
* A sample puppet bolt example puppet repository with docker : https://github.com/neillturner/bolt_docker_repo
|
106
|
-
|
107
|
-
## Test-Kitchen Serverspec
|
108
|
-
|
109
|
-
To run the verify step with the test-kitchen serverspec setup your puppet repository as follows:
|
110
|
-
|
111
|
-
In the root directory for your puppet repository:
|
112
|
-
|
113
|
-
Create a `.kitchen.yml`, much like one the described above:
|
114
|
-
|
115
|
-
```yaml
|
116
|
-
---
|
117
|
-
driver:
|
118
|
-
name: vagrant
|
119
|
-
|
120
|
-
provisioner:
|
121
|
-
name: puppet_apply
|
122
|
-
manifests_path: /repository/puppet_repo/manifests
|
123
|
-
modules_path: /repository/puppet_repo/modules-mycompany
|
124
|
-
hiera_data_path: /repository/puppet_repo/hieradata
|
125
|
-
|
126
|
-
platforms:
|
127
|
-
- name: nocm_ubuntu-12.04
|
128
|
-
driver_plugin: vagrant
|
129
|
-
driver_config:
|
130
|
-
box: nocm_ubuntu-12.04
|
131
|
-
box_url: http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
|
132
|
-
|
133
|
-
suites:
|
134
|
-
- name: default
|
135
|
-
```
|
136
|
-
|
137
|
-
Then for serverspec:
|
138
|
-
|
139
|
-
```bash
|
140
|
-
mkdir -p test/integration/default/serverspec/localhost
|
141
|
-
echo "require 'serverspec'" >> test/integration/default/serverspec/spec_helper.rb
|
142
|
-
echo "set :backend, :exec" >> test/integration/default/serverspec/spec_helper.rb
|
143
|
-
```
|
144
|
-
|
145
|
-
Create your serverspec tests in `test/integration/default/serverspec/localhost/xxxxxx_spec.rb`:
|
146
|
-
|
147
|
-
```ruby
|
148
|
-
require 'spec_helper'
|
149
|
-
|
150
|
-
if os[:family] == 'ubuntu'
|
151
|
-
describe '/etc/lsb-release' do
|
152
|
-
it "exists" do
|
153
|
-
expect(file('/etc/lsb-release')).to be_file
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
if os[:family] == 'redhat'
|
159
|
-
describe '/etc/redhat-release' do
|
160
|
-
it "exists" do
|
161
|
-
expect(file('/etc/redhat-release')).to be_file
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
165
|
-
```
|
166
|
-
|
167
|
-
## Test-Kitchen Beaker
|
168
|
-
|
169
|
-
test-kitchen normally uses tests setup in `test/integration/....` directory. Beaker format puts the tests with the
|
170
|
-
`spec/acceptance` directory in the puppet repository and the `spec_helper.rb` under the `spec` directory which is more logical.
|
171
|
-
|
172
|
-
For examples see:
|
173
|
-
* https://gitlab.com/joshbeard/puppet-module-test
|
174
|
-
* https://github.com/puppetlabs/puppetlabs-mysql/tree/master/spec
|
175
|
-
|
176
|
-
To implement this with test-kitchen setup the puppet repository with:
|
177
|
-
|
178
|
-
* the spec files with the spec/acceptance directory.
|
179
|
-
|
180
|
-
* the spec_helper in the spec folder.
|
181
|
-
|
182
|
-
* install kitchen-verifier-serverspec on your workstation i.e. 'gem install kitchen-verifier-serverspec'
|
183
|
-
|
184
|
-
See examples:
|
185
|
-
* [https://github.com/neillturner/puppet_vagrant_repo](https://github.com/neillturner/puppet_vagrant_repo)
|
186
|
-
|
187
|
-
* [https://github.com/neillturner/puppet_repo](https://github.com/neillturner/puppet_repo)
|
188
|
-
|
189
|
-
```
|
190
|
-
.
|
191
|
-
+-- spec
|
192
|
-
¦ +-- acceptance
|
193
|
-
¦ ¦ +-- mariadb_spec.rb
|
194
|
-
¦ ¦ +-- nginx_spec.rb
|
195
|
-
¦ ¦
|
196
|
-
+-- spec_helper.rb
|
197
|
-
|
198
|
-
```
|
199
|
-
|
200
|
-
In the root directory for your puppet repository create a `.kitchen.yml` with
|
201
|
-
|
202
|
-
* a verifier of 'serverspec'
|
203
|
-
* a pattern parameter with the spec tests to run
|
204
|
-
|
205
|
-
```yaml
|
206
|
-
verifier:
|
207
|
-
name: serverspec
|
208
|
-
|
209
|
-
suites:
|
210
|
-
- name: base
|
211
|
-
verifier:
|
212
|
-
patterns:
|
213
|
-
- modules/mycompany_base/spec/acceptance/base_spec.rb
|
214
|
-
```
|
215
|
-
|
216
|
-
See [kitchen-verifier-serverspec](https://github.com/neillturner/kitchen-verifier-serverspec)
|
217
|
-
|
218
|
-
## hiera_writer_files option
|
219
|
-
|
220
|
-
Allows creation of arbitrary YAML files in the target instance's `hieradata/`
|
221
|
-
dir in test-kitchen configuration (eg `kitchen.yml`). Like setting chef
|
222
|
-
attributes in `kitchen.yml`, except for Hiera YAML files.
|
223
|
-
|
224
|
-
set `hiera_writer_files` in `kitchen.yml`
|
225
|
-
|
226
|
-
```
|
227
|
-
---
|
228
|
-
driver:
|
229
|
-
name: vagrant
|
230
|
-
|
231
|
-
provisioner:
|
232
|
-
name: puppet_apply
|
233
|
-
manifests_path: /repository/puppet_repo/manifests
|
234
|
-
modules_path: /repository/puppet_repo/modules-mycompany
|
235
|
-
hiera_data_path: /repository/puppet_repo/hieradata
|
236
|
-
hiera_writer_files:
|
237
|
-
- datacenter/vagrant.yaml:
|
238
|
-
logstash_servers: []
|
239
|
-
hosts:
|
240
|
-
10.1.2.3:
|
241
|
-
- puppet
|
242
|
-
- puppetdb
|
243
|
-
|
244
|
-
platforms:
|
245
|
-
- name: nocm_ubuntu-12.04
|
246
|
-
driver_plugin: vagrant
|
247
|
-
driver_config:
|
248
|
-
box: nocm_ubuntu-12.04
|
249
|
-
box_url: http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
|
250
|
-
|
251
|
-
suites:
|
252
|
-
- name: default
|
253
|
-
```
|
254
|
-
|
255
|
-
The above configuration will result in the creation of a file on the guest named
|
256
|
-
`${hieradata}/datacenter/vagrant.yaml` containing:
|
257
|
-
|
258
|
-
```
|
259
|
-
---
|
260
|
-
logstash_servers: []
|
261
|
-
hosts:
|
262
|
-
10.1.2.3:
|
263
|
-
- puppet
|
264
|
-
- puppetdb
|
265
|
-
```
|
266
|
-
|
267
|
-
It will overwrite any existing Hiera YAML files with the same name (on the
|
268
|
-
guest), not merge.
|
269
|
-
|
270
|
-
## Provisioner Options
|
271
|
-
Please see the Provisioner Options (https://github.com/neillturner/kitchen-puppet/blob/master/provisioner_options.md).
|
272
|
-
|
273
|
-
## Contributing
|
274
|
-
To contribute to the repository, please follow the Fork / PR model:
|
275
|
-
|
276
|
-
1. Fork The Repository
|
277
|
-
2. Work on epic changes
|
278
|
-
3. Write tests for your changes, see [TESTING](TESTING.md)
|
279
|
-
4. Update Documentation
|
280
|
-
5. Commit
|
281
|
-
6. Push
|
282
|
-
7. Create PR
|
283
|
-
8. Profit(?)
|
1
|
+
# Kitchen Puppet
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/kitchen-puppet)
|
4
|
+
[](https://rubygems.org/gems/kitchen-puppet)
|
5
|
+
[](https://travis-ci.org/neillturner/kitchen-puppet)
|
6
|
+
|
7
|
+
# kitchen-puppet
|
8
|
+
A Test Kitchen Provisioner for Puppet
|
9
|
+
|
10
|
+
The providers supports both puppet apply and puppet agent clients and puppet bolt.
|
11
|
+
|
12
|
+
The PuppetApply provider works by passing the puppet repository based on attributes in .kitchen.yml & calling puppet apply.
|
13
|
+
|
14
|
+
The PuppetAgent provider works by passing the puppetmaster and other attributes in .kitchen.yml & calling puppet agent.
|
15
|
+
|
16
|
+
The PuppetBolt provider works by passing the puppet bolt commands based on attributes in .kitchen.yml & calling puppet bolt.
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
This provider has been tested against the Ubuntu 1604 and Centos 7 boxes running in docker and vagrant/virtualbox.
|
21
|
+
|
22
|
+
## Template
|
23
|
+
|
24
|
+
Template project for using kitchen for puppet development:
|
25
|
+
|
26
|
+
https://github.com/scoopex/puppet-kitchen_template
|
27
|
+
|
28
|
+
## Resources
|
29
|
+
* http://ehaselwanter.com/en/blog/2014/05/08/using-test-kitchen-with-puppet
|
30
|
+
* http://www.slideshare.net/MartinEtmajer/testdriven-infrastructure-with-puppet-test-kitchen-serverspec-and-rspec
|
31
|
+
* http://www.slideshare.net/YuryTsarev/containercon-test-driven-infrastructure
|
32
|
+
* http://events.linuxfoundation.org/sites/events/files/slides/ContainerCon%20-%20Test%20Driven%20Infrastructure_0.pdf
|
33
|
+
* https://www.cedric-meury.ch/2016/10/test-driven-infrastructure-with-puppet-docker-test-kitchen-and-serverspec-yury-tsarev-gooddata
|
34
|
+
* https://docs.puppet.com/puppet/latest/puppet_platform.html
|
35
|
+
|
36
|
+
## Install
|
37
|
+
|
38
|
+
1. install the latest Ruby on your workstations (for windows see https://rubyinstaller.org/downloads/)
|
39
|
+
|
40
|
+
2. From a Command prompt:
|
41
|
+
* gem install librarian-puppet
|
42
|
+
* gem install test-kitchen (or gem install test-kitchen -v 1.16.0 if using ruby version less than 2.3)
|
43
|
+
* gem install kitchen-puppet
|
44
|
+
|
45
|
+
## Requirements
|
46
|
+
It is recommended to have a metadata.json file of your puppet module. It is used by kitchen-puppet to configure the module path.
|
47
|
+
The puppet docs describe (https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html#write-a-metadatajson-file) how to create one.
|
48
|
+
|
49
|
+
You'll need a driver box without a chef installation so puppet can be installed. Puppet have one at http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box or http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box.
|
50
|
+
|
51
|
+
For PuppetAgent a server with a puppet master is required that can resolve the hostname ip address of the server. The server must also be able to resolve the hostname ip address of the puppet master.
|
52
|
+
|
53
|
+
You can also use the PuppetApply driver with a docker container, provided the necessary box requirements to install puppet are included inside the container. The easiest way to do this is to supply Kitchen-Docker with a custom dockerfile to install the needed dependencies for puppet installation.
|
54
|
+
|
55
|
+
## Windows Support
|
56
|
+
|
57
|
+
There is windows/winrm support, currently not all functionality is supported.
|
58
|
+
* `require_chef_for_busser: false` (it is possible to call rspec over winrm to run the tests)
|
59
|
+
* `resolve_with_librarian_puppet: false` (librarian-puppet is not working on windows server)
|
60
|
+
|
61
|
+
Sample Puppet Repositories
|
62
|
+
* A sample hello world example puppet repository: https://github.com/neillturner/puppet_windows_repo
|
63
|
+
* A sample hello world example puppet repository for vagrant: https://github.com/neillturner/puppet_vagrant_windows_repo
|
64
|
+
* A more extensive sample installing virtualbox on windows: https://github.com/red-gate/puppet-virtualbox_windows
|
65
|
+
|
66
|
+
## Using Environments
|
67
|
+
|
68
|
+
In the root directory for your puppet repository:
|
69
|
+
|
70
|
+
Create a `.kitchen.yml`, much like one the described above:
|
71
|
+
|
72
|
+
```yaml
|
73
|
+
---
|
74
|
+
driver:
|
75
|
+
name: vagrant
|
76
|
+
|
77
|
+
provisioner:
|
78
|
+
name: puppet_apply
|
79
|
+
puppet_environment: dev
|
80
|
+
# the puppet environmnt files can be in this repository
|
81
|
+
puppet_environment_config_path: environment/dev/environment.conf
|
82
|
+
manifests_path: environment/dev/manifests
|
83
|
+
modules_path: environment/dev/modules_mycompany
|
84
|
+
# or external to this repository as long as they are accessible
|
85
|
+
# puppet_environment_config_path: /my_environments/dev/environment.conf
|
86
|
+
# manifests_path: /my_environments/dev/manifests
|
87
|
+
# modules_path: /my_environments/dev/modules_mycompany
|
88
|
+
hiera_data_path: /repository/puppet_repo/hieradata
|
89
|
+
|
90
|
+
platforms:
|
91
|
+
- name: nocm_ubuntu-12.04
|
92
|
+
driver_plugin: vagrant
|
93
|
+
driver_config:
|
94
|
+
box: nocm_ubuntu-12.04
|
95
|
+
box_url: http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
|
96
|
+
|
97
|
+
suites:
|
98
|
+
- name: default
|
99
|
+
```
|
100
|
+
|
101
|
+
Sample Puppet Repositories
|
102
|
+
* A sample hello world example puppet repository with docker : https://github.com/neillturner/puppet_docker_repo
|
103
|
+
* A sample hello world example puppet repository without environents : https://github.com/neillturner/puppet_vagrant_repo
|
104
|
+
* A sample hello world example puppet repository with environents : https://github.com/neillturner/puppet_vagrant_environment_repo
|
105
|
+
* A sample puppet bolt example puppet repository with docker : https://github.com/neillturner/bolt_docker_repo
|
106
|
+
|
107
|
+
## Test-Kitchen Serverspec
|
108
|
+
|
109
|
+
To run the verify step with the test-kitchen serverspec setup your puppet repository as follows:
|
110
|
+
|
111
|
+
In the root directory for your puppet repository:
|
112
|
+
|
113
|
+
Create a `.kitchen.yml`, much like one the described above:
|
114
|
+
|
115
|
+
```yaml
|
116
|
+
---
|
117
|
+
driver:
|
118
|
+
name: vagrant
|
119
|
+
|
120
|
+
provisioner:
|
121
|
+
name: puppet_apply
|
122
|
+
manifests_path: /repository/puppet_repo/manifests
|
123
|
+
modules_path: /repository/puppet_repo/modules-mycompany
|
124
|
+
hiera_data_path: /repository/puppet_repo/hieradata
|
125
|
+
|
126
|
+
platforms:
|
127
|
+
- name: nocm_ubuntu-12.04
|
128
|
+
driver_plugin: vagrant
|
129
|
+
driver_config:
|
130
|
+
box: nocm_ubuntu-12.04
|
131
|
+
box_url: http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
|
132
|
+
|
133
|
+
suites:
|
134
|
+
- name: default
|
135
|
+
```
|
136
|
+
|
137
|
+
Then for serverspec:
|
138
|
+
|
139
|
+
```bash
|
140
|
+
mkdir -p test/integration/default/serverspec/localhost
|
141
|
+
echo "require 'serverspec'" >> test/integration/default/serverspec/spec_helper.rb
|
142
|
+
echo "set :backend, :exec" >> test/integration/default/serverspec/spec_helper.rb
|
143
|
+
```
|
144
|
+
|
145
|
+
Create your serverspec tests in `test/integration/default/serverspec/localhost/xxxxxx_spec.rb`:
|
146
|
+
|
147
|
+
```ruby
|
148
|
+
require 'spec_helper'
|
149
|
+
|
150
|
+
if os[:family] == 'ubuntu'
|
151
|
+
describe '/etc/lsb-release' do
|
152
|
+
it "exists" do
|
153
|
+
expect(file('/etc/lsb-release')).to be_file
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
if os[:family] == 'redhat'
|
159
|
+
describe '/etc/redhat-release' do
|
160
|
+
it "exists" do
|
161
|
+
expect(file('/etc/redhat-release')).to be_file
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
```
|
166
|
+
|
167
|
+
## Test-Kitchen Beaker
|
168
|
+
|
169
|
+
test-kitchen normally uses tests setup in `test/integration/....` directory. Beaker format puts the tests with the
|
170
|
+
`spec/acceptance` directory in the puppet repository and the `spec_helper.rb` under the `spec` directory which is more logical.
|
171
|
+
|
172
|
+
For examples see:
|
173
|
+
* https://gitlab.com/joshbeard/puppet-module-test
|
174
|
+
* https://github.com/puppetlabs/puppetlabs-mysql/tree/master/spec
|
175
|
+
|
176
|
+
To implement this with test-kitchen setup the puppet repository with:
|
177
|
+
|
178
|
+
* the spec files with the spec/acceptance directory.
|
179
|
+
|
180
|
+
* the spec_helper in the spec folder.
|
181
|
+
|
182
|
+
* install kitchen-verifier-serverspec on your workstation i.e. 'gem install kitchen-verifier-serverspec'
|
183
|
+
|
184
|
+
See examples:
|
185
|
+
* [https://github.com/neillturner/puppet_vagrant_repo](https://github.com/neillturner/puppet_vagrant_repo)
|
186
|
+
|
187
|
+
* [https://github.com/neillturner/puppet_repo](https://github.com/neillturner/puppet_repo)
|
188
|
+
|
189
|
+
```
|
190
|
+
.
|
191
|
+
+-- spec
|
192
|
+
¦ +-- acceptance
|
193
|
+
¦ ¦ +-- mariadb_spec.rb
|
194
|
+
¦ ¦ +-- nginx_spec.rb
|
195
|
+
¦ ¦
|
196
|
+
+-- spec_helper.rb
|
197
|
+
|
198
|
+
```
|
199
|
+
|
200
|
+
In the root directory for your puppet repository create a `.kitchen.yml` with
|
201
|
+
|
202
|
+
* a verifier of 'serverspec'
|
203
|
+
* a pattern parameter with the spec tests to run
|
204
|
+
|
205
|
+
```yaml
|
206
|
+
verifier:
|
207
|
+
name: serverspec
|
208
|
+
|
209
|
+
suites:
|
210
|
+
- name: base
|
211
|
+
verifier:
|
212
|
+
patterns:
|
213
|
+
- modules/mycompany_base/spec/acceptance/base_spec.rb
|
214
|
+
```
|
215
|
+
|
216
|
+
See [kitchen-verifier-serverspec](https://github.com/neillturner/kitchen-verifier-serverspec)
|
217
|
+
|
218
|
+
## hiera_writer_files option
|
219
|
+
|
220
|
+
Allows creation of arbitrary YAML files in the target instance's `hieradata/`
|
221
|
+
dir in test-kitchen configuration (eg `kitchen.yml`). Like setting chef
|
222
|
+
attributes in `kitchen.yml`, except for Hiera YAML files.
|
223
|
+
|
224
|
+
set `hiera_writer_files` in `kitchen.yml`
|
225
|
+
|
226
|
+
```
|
227
|
+
---
|
228
|
+
driver:
|
229
|
+
name: vagrant
|
230
|
+
|
231
|
+
provisioner:
|
232
|
+
name: puppet_apply
|
233
|
+
manifests_path: /repository/puppet_repo/manifests
|
234
|
+
modules_path: /repository/puppet_repo/modules-mycompany
|
235
|
+
hiera_data_path: /repository/puppet_repo/hieradata
|
236
|
+
hiera_writer_files:
|
237
|
+
- datacenter/vagrant.yaml:
|
238
|
+
logstash_servers: []
|
239
|
+
hosts:
|
240
|
+
10.1.2.3:
|
241
|
+
- puppet
|
242
|
+
- puppetdb
|
243
|
+
|
244
|
+
platforms:
|
245
|
+
- name: nocm_ubuntu-12.04
|
246
|
+
driver_plugin: vagrant
|
247
|
+
driver_config:
|
248
|
+
box: nocm_ubuntu-12.04
|
249
|
+
box_url: http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
|
250
|
+
|
251
|
+
suites:
|
252
|
+
- name: default
|
253
|
+
```
|
254
|
+
|
255
|
+
The above configuration will result in the creation of a file on the guest named
|
256
|
+
`${hieradata}/datacenter/vagrant.yaml` containing:
|
257
|
+
|
258
|
+
```
|
259
|
+
---
|
260
|
+
logstash_servers: []
|
261
|
+
hosts:
|
262
|
+
10.1.2.3:
|
263
|
+
- puppet
|
264
|
+
- puppetdb
|
265
|
+
```
|
266
|
+
|
267
|
+
It will overwrite any existing Hiera YAML files with the same name (on the
|
268
|
+
guest), not merge.
|
269
|
+
|
270
|
+
## Provisioner Options
|
271
|
+
Please see the Provisioner Options (https://github.com/neillturner/kitchen-puppet/blob/master/provisioner_options.md).
|
272
|
+
|
273
|
+
## Contributing
|
274
|
+
To contribute to the repository, please follow the Fork / PR model:
|
275
|
+
|
276
|
+
1. Fork The Repository
|
277
|
+
2. Work on epic changes
|
278
|
+
3. Write tests for your changes, see [TESTING](TESTING.md)
|
279
|
+
4. Update Documentation
|
280
|
+
5. Commit
|
281
|
+
6. Push
|
282
|
+
7. Create PR
|
283
|
+
8. Profit(?)
|