vagrant-r10k 0.2.0 → 0.3.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.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -2
  3. data/.pullreview.yml +4 -0
  4. data/.rspec +5 -0
  5. data/.ruby-version +1 -1
  6. data/.travis.yml +3 -1
  7. data/CHANGES.md +26 -0
  8. data/Gemfile +7 -2
  9. data/Gemfile.lock +181 -0
  10. data/README.md +122 -7
  11. data/Rakefile +111 -0
  12. data/lib/vagrant-r10k/action/base.rb +44 -0
  13. data/lib/vagrant-r10k/action/deploy.rb +91 -0
  14. data/lib/vagrant-r10k/action/validate.rb +46 -0
  15. data/lib/vagrant-r10k/config.rb +13 -4
  16. data/lib/vagrant-r10k/helpers.rb +174 -0
  17. data/lib/vagrant-r10k/plugin.rb +11 -5
  18. data/lib/vagrant-r10k/version.rb +2 -1
  19. data/spec/acceptance/skeletons/correct/Vagrantfile +21 -0
  20. data/spec/acceptance/skeletons/correct/gitcheck.sh +20 -0
  21. data/spec/acceptance/skeletons/correct/puppet/NOTmodules/.gitkeep +0 -0
  22. data/spec/acceptance/skeletons/correct/puppet/Puppetfile +12 -0
  23. data/spec/acceptance/skeletons/correct/puppet/manifests/default.pp +1 -0
  24. data/spec/acceptance/skeletons/correct/puppet/modules/.gitkeep +0 -0
  25. data/spec/acceptance/skeletons/could_not_resolve_host/Vagrantfile +21 -0
  26. data/spec/acceptance/skeletons/could_not_resolve_host/gitcheck.sh +20 -0
  27. data/spec/acceptance/skeletons/could_not_resolve_host/puppet/NOTmodules/.gitkeep +0 -0
  28. data/spec/acceptance/skeletons/could_not_resolve_host/puppet/Puppetfile +7 -0
  29. data/spec/acceptance/skeletons/could_not_resolve_host/puppet/manifests/default.pp +1 -0
  30. data/spec/acceptance/skeletons/could_not_resolve_host/puppet/modules/.gitkeep +0 -0
  31. data/spec/acceptance/skeletons/different_mod_path/Vagrantfile +19 -0
  32. data/spec/acceptance/skeletons/different_mod_path/gitcheck.sh +20 -0
  33. data/spec/acceptance/skeletons/different_mod_path/puppet/NOTmodules/.gitkeep +0 -0
  34. data/spec/acceptance/skeletons/different_mod_path/puppet/Puppetfile +12 -0
  35. data/spec/acceptance/skeletons/different_mod_path/puppet/manifests/default.pp +1 -0
  36. data/spec/acceptance/skeletons/different_mod_path/puppet/modules/.gitkeep +0 -0
  37. data/spec/acceptance/skeletons/no_mod_path/Vagrantfile +17 -0
  38. data/spec/acceptance/skeletons/no_mod_path/gitcheck.sh +20 -0
  39. data/spec/acceptance/skeletons/no_mod_path/puppet/NOTmodules/.gitkeep +0 -0
  40. data/spec/acceptance/skeletons/no_mod_path/puppet/Puppetfile +12 -0
  41. data/spec/acceptance/skeletons/no_mod_path/puppet/manifests/default.pp +1 -0
  42. data/spec/acceptance/skeletons/no_mod_path/puppet/modules/.gitkeep +0 -0
  43. data/spec/acceptance/skeletons/no_puppet_dir/Vagrantfile +18 -0
  44. data/spec/acceptance/skeletons/no_puppet_dir/gitcheck.sh +20 -0
  45. data/spec/acceptance/skeletons/no_vagrant_r10k/Vagrantfile +14 -0
  46. data/spec/acceptance/skeletons/no_vagrant_r10k/gitcheck.sh +20 -0
  47. data/spec/acceptance/skeletons/no_vagrant_r10k/puppet/NOTmodules/.gitkeep +0 -0
  48. data/spec/acceptance/skeletons/no_vagrant_r10k/puppet/Puppetfile +12 -0
  49. data/spec/acceptance/skeletons/no_vagrant_r10k/puppet/manifests/default.pp +1 -0
  50. data/spec/acceptance/skeletons/no_vagrant_r10k/puppet/modules/.gitkeep +0 -0
  51. data/spec/acceptance/skeletons/puppetfile_syntax_error/Vagrantfile +18 -0
  52. data/spec/acceptance/skeletons/puppetfile_syntax_error/gitcheck.sh +20 -0
  53. data/spec/acceptance/skeletons/puppetfile_syntax_error/puppet/Puppetfile +1 -0
  54. data/spec/acceptance/skeletons/puppetfile_syntax_error/puppet/manifests/default.pp +1 -0
  55. data/spec/acceptance/skeletons/puppetfile_syntax_error/puppet/modules/.gitkeep +0 -0
  56. data/spec/acceptance/vagrant-r10k/vagrant-r10k_spec.rb +255 -0
  57. data/spec/spec_helper.rb +10 -7
  58. data/spec/unit/action_base_spec.rb +57 -0
  59. data/spec/unit/action_deploy_spec.rb +550 -0
  60. data/spec/unit/action_validate_spec.rb +240 -0
  61. data/spec/unit/helpers_spec.rb +307 -0
  62. data/spec/unit/plugin_spec.rb +49 -0
  63. data/support/testrunner.py +189 -0
  64. data/vagrant-r10k.gemspec +1 -1
  65. data/vagrant-spec.config.rb +18 -0
  66. metadata +111 -19
  67. data/lib/vagrant-r10k/modulegetter.rb +0 -145
  68. data/spec/unit/modulegetter_spec.rb +0 -369
@@ -1,369 +0,0 @@
1
- require 'spec_helper'
2
- require_relative 'sharedcontext'
3
- require_relative 'shared_expectations'
4
-
5
- require 'r10k/puppetfile'
6
- require 'r10k/task_runner'
7
- require 'r10k/task/puppetfile'
8
- require 'vagrant-r10k/modulegetter'
9
-
10
- include SharedExpectations
11
-
12
- describe Log4r::Logger do
13
- subject { described_class.new('testlogger') }
14
- describe '#debug1' do
15
- it 'should pass through to debug' do
16
- expect(subject).to receive(:debug).with('a message').once
17
- subject.debug1('a message')
18
- end
19
- end
20
- describe '#debug2' do
21
- it 'should pass through to debug' do
22
- expect(subject).to receive(:debug).with('different message').once
23
- subject.debug2('different message')
24
- end
25
- end
26
- end
27
-
28
- describe R10K::TaskRunner do
29
- subject { described_class.new({}) }
30
- describe '#get_errors' do
31
- it 'returns @errors' do
32
- subject.instance_variable_set(:@errors, ['foo'])
33
- expect(subject).to receive(:get_errors).once.and_call_original
34
- foo = subject.get_errors
35
- expect(foo).to eq(['foo'])
36
- end
37
- end
38
- end
39
-
40
- describe VagrantPlugins::R10k::Modulegetter do
41
- subject { described_class.new(app, env) }
42
-
43
- describe '#call' do
44
- describe 'puppet_dir unset' do
45
- include_context 'unit' do
46
- let(:vagrantfile) { <<-EOF
47
- Vagrant.configure('2') do |config|
48
- config.vm.define :test
49
- # r10k plugin to deploy puppet modules
50
- # config.r10k.puppet_dir = 'puppet'
51
- config.r10k.puppetfile_path = 'puppet/Puppetfile'
52
-
53
- # Provision the machine with the appliction
54
- config.vm.provision "puppet" do |puppet|
55
- puppet.manifests_path = "puppet/manifests"
56
- puppet.manifest_file = "default.pp"
57
- puppet.module_path = "puppet/modules"
58
- end
59
- end
60
- EOF
61
- }
62
- end
63
- it 'should raise an error' do
64
- expect(ui).to receive(:detail).with("vagrant-r10k: puppet_dir and/or puppetfile_path not set in config; not running").once
65
- File.stub(:join).and_call_original
66
- File.stub(:join).with('/rootpath', 'puppet/Puppetfile').and_return('foobarbaz')
67
- expect(File).to receive(:join).with('/rootpath', 'puppet/Puppetfile').exactly(0).times
68
- expect_did_not_run(ui, app, env)
69
-
70
- retval = subject.call(env)
71
- expect(retval).to be_nil
72
- end
73
- end
74
- describe 'puppetfile_path unset' do
75
- include_context 'unit' do
76
- let(:vagrantfile) { <<-EOF
77
- Vagrant.configure('2') do |config|
78
- config.vm.define :test
79
- # r10k plugin to deploy puppet modules
80
- config.r10k.puppet_dir = 'puppet'
81
- # config.r10k.puppetfile_path = 'puppet/Puppetfile'
82
-
83
- # Provision the machine with the appliction
84
- config.vm.provision "puppet" do |puppet|
85
- puppet.manifests_path = "puppet/manifests"
86
- puppet.manifest_file = "default.pp"
87
- puppet.module_path = "puppet/modules"
88
- end
89
- end
90
- EOF
91
- }
92
- end
93
- it 'should raise an error' do
94
- expect(ui).to receive(:detail).with("vagrant-r10k: puppet_dir and/or puppetfile_path not set in config; not running").once
95
- File.stub(:join).and_call_original
96
- File.stub(:join).with('/rootpath', 'puppet/Puppetfile').and_return('foobarbaz')
97
- expect(File).to receive(:join).with('/rootpath', 'puppet/Puppetfile').exactly(0).times
98
- expect_did_not_run(ui, app, env)
99
-
100
- retval = subject.call(env)
101
- expect(retval).to be_nil
102
- end
103
- end
104
- describe 'r10k module_path set differently from puppet' do
105
- include_context 'unit' do
106
- let(:vagrantfile) { <<-EOF
107
- Vagrant.configure('2') do |config|
108
- config.vm.define :test
109
- # r10k plugin to deploy puppet modules
110
- config.r10k.puppet_dir = 'puppet'
111
- config.r10k.puppetfile_path = 'puppet/Puppetfile'
112
- config.r10k.module_path = "mymodulepath/foo"
113
-
114
- # Provision the machine with the appliction
115
- config.vm.provision "puppet" do |puppet|
116
- puppet.manifests_path = "puppet/manifests"
117
- puppet.manifest_file = "default.pp"
118
- puppet.module_path = "puppet/modules"
119
- end
120
- end
121
- EOF
122
- }
123
- end
124
- it 'should raise an error' do
125
- expect(ui).to receive(:detail).with("vagrant-r10k: module_path \"mymodulepath/foo\" is not the same as in puppet provisioner; not running").once
126
- File.stub(:file?).with('/rootpath/puppet/Puppetfile').and_return(true)
127
- expect(File).to receive(:join).with('/rootpath', 'default.pp').exactly(0).times
128
- expect_did_not_run(ui, app, env)
129
-
130
- retval = subject.call(env)
131
- expect(retval).to be_nil
132
- end
133
- end
134
- describe 'r10k module_path set differently from puppet array' do
135
- include_context 'unit' do
136
- let(:vagrantfile) { <<-EOF
137
- Vagrant.configure('2') do |config|
138
- config.vm.define :test
139
- # r10k plugin to deploy puppet modules
140
- config.r10k.puppet_dir = 'puppet'
141
- config.r10k.puppetfile_path = 'puppet/Puppetfile'
142
- config.r10k.module_path = "mymodulepath/foo"
143
-
144
- # Provision the machine with the appliction
145
- config.vm.provision "puppet" do |puppet|
146
- puppet.manifests_path = "puppet/manifests"
147
- puppet.manifest_file = "default.pp"
148
- puppet.module_path = ["puppet/modules", "foo/modules"]
149
- end
150
- end
151
- EOF
152
- }
153
- end
154
- it 'should raise an error' do
155
- expect(ui).to receive(:detail).with("vagrant-r10k: module_path \"mymodulepath/foo\" is not within the ones defined in puppet provisioner; not running").once
156
- File.stub(:file?).with('/rootpath/puppet/Puppetfile').and_return(true)
157
- expect(File).to receive(:join).with('/rootpath', 'default.pp').exactly(0).times
158
- expect_did_not_run(ui, app, env)
159
-
160
- retval = subject.call(env)
161
- expect(retval).to be_nil
162
- end
163
- end
164
- describe 'r10k module_path not set' do
165
- include_context 'unit' do
166
- let(:vagrantfile) { <<-EOF
167
- Vagrant.configure('2') do |config|
168
- config.vm.define :test
169
- # r10k plugin to deploy puppet modules
170
- config.r10k.puppet_dir = 'puppet'
171
- config.r10k.puppetfile_path = 'puppet/Puppetfile'
172
-
173
- # Provision the machine with the appliction
174
- config.vm.provision "puppet" do |puppet|
175
- puppet.manifests_path = "puppet/manifests"
176
- puppet.manifest_file = "default.pp"
177
- puppet.module_path = "puppet/modules"
178
- end
179
- end
180
- EOF
181
- }
182
- end
183
- it 'should use the module_path from provisioner' do
184
- expect_ran_successfully({:ui => ui,
185
- :subject => subject,
186
- :module_path => 'puppet/modules',
187
- :puppetfile_path => 'puppet/Puppetfile',
188
- :rootpath => '/rootpath',
189
- :puppet_dir => 'puppet',
190
- })
191
- retval = subject.call(env)
192
- expect(retval).to be_nil
193
- end
194
- end
195
- describe 'vagrant normal logging' do
196
- include_context 'unit' do
197
- let(:vagrantfile) { <<-EOF
198
- Vagrant.configure('2') do |config|
199
- config.vm.define :test
200
- # r10k plugin to deploy puppet modules
201
- config.r10k.puppet_dir = 'puppet'
202
- config.r10k.puppetfile_path = 'puppet/Puppetfile'
203
-
204
- # Provision the machine with the appliction
205
- config.vm.provision "puppet" do |puppet|
206
- puppet.manifests_path = "puppet/manifests"
207
- puppet.manifest_file = "default.pp"
208
- puppet.module_path = "puppet/modules"
209
- end
210
- end
211
- EOF
212
- }
213
- end
214
- it 'should set r10k normal logging' do
215
- expect_ran_successfully({:ui => ui,
216
- :subject => subject,
217
- :module_path => 'puppet/modules',
218
- :puppetfile_path => 'puppet/Puppetfile',
219
- :rootpath => '/rootpath',
220
- :puppet_dir => 'puppet',
221
- })
222
- retval = subject.call(env)
223
- expect(R10K::Logging.level).to eq(3)
224
- expect(retval).to be_nil
225
- end
226
- end
227
- describe 'vagrant debug logging' do
228
- include_context 'unit' do
229
- let(:vagrantfile) { <<-EOF
230
- Vagrant.configure('2') do |config|
231
- config.vm.define :test
232
- # r10k plugin to deploy puppet modules
233
- config.r10k.puppet_dir = 'puppet'
234
- config.r10k.puppetfile_path = 'puppet/Puppetfile'
235
-
236
- # Provision the machine with the appliction
237
- config.vm.provision "puppet" do |puppet|
238
- puppet.manifests_path = "puppet/manifests"
239
- puppet.manifest_file = "default.pp"
240
- puppet.module_path = "puppet/modules"
241
- end
242
- end
243
- EOF
244
- }
245
- end
246
- it 'should set r10k debug logging' do
247
- expect_ran_successfully({:ui => ui,
248
- :subject => subject,
249
- :module_path => 'puppet/modules',
250
- :puppetfile_path => 'puppet/Puppetfile',
251
- :rootpath => '/rootpath',
252
- :puppet_dir => 'puppet',
253
- })
254
- with_temp_env("VAGRANT_LOG" => "debug") do
255
- retval = subject.call(env)
256
- expect(R10K::Logging.level).to eq(0)
257
- expect(retval).to be_nil
258
- end
259
- end
260
- end
261
- describe 'puppetfile does not exist' do
262
- include_context 'unit' do
263
- let(:vagrantfile) { <<-EOF
264
- Vagrant.configure('2') do |config|
265
- config.vm.define :test
266
- # r10k plugin to deploy puppet modules
267
- config.r10k.puppet_dir = 'puppet'
268
- config.r10k.puppetfile_path = 'puppet/Puppetfile'
269
-
270
- # Provision the machine with the appliction
271
- config.vm.provision "puppet" do |puppet|
272
- puppet.manifests_path = "puppet/manifests"
273
- puppet.manifest_file = "default.pp"
274
- puppet.module_path = "puppet/modules"
275
- end
276
- end
277
- EOF
278
- }
279
- end
280
- it 'raise an error' do
281
- File.stub(:file?).with('/rootpath/puppet/Puppetfile').and_return(false)
282
- expect(ui).to receive(:info).with(/Building the r10k module path with puppet provisioner module_path/).once
283
- expect(ui).to receive(:info).with(/Beginning r10k deploy/).once
284
- expect_did_not_run(ui, app, env, nobegin=false, appcall=false)
285
- expect{subject.call(env)}.to raise_error(VagrantPlugins::R10k::ErrorWrapper, "RuntimeError: Puppetfile at /rootpath/puppet/Puppetfile does not exist.")
286
- end
287
- end
288
- describe 'puppetfile syntax error' do
289
- include_context 'unit' do
290
- let(:vagrantfile) { <<-EOF
291
- Vagrant.configure('2') do |config|
292
- config.vm.define :test
293
- # r10k plugin to deploy puppet modules
294
- config.r10k.puppet_dir = 'puppet'
295
- config.r10k.puppetfile_path = 'puppet/Puppetfile'
296
-
297
- # Provision the machine with the appliction
298
- config.vm.provision "puppet" do |puppet|
299
- puppet.manifests_path = "puppet/manifests"
300
- puppet.manifest_file = "default.pp"
301
- puppet.module_path = "puppet/modules"
302
- end
303
- end
304
- EOF
305
- }
306
- end
307
- it 'raise an error' do
308
- File.stub(:file?).with('/rootpath/puppet/Puppetfile').and_return(true)
309
- expect(ui).to receive(:info).with(/Building the r10k module path with puppet provisioner module_path/).once
310
- expect(ui).to receive(:info).with("vagrant-r10k: Building the r10k module path with puppet provisioner module_path \"puppet/modules\". (if module_path is an array, first element is used)").exactly(0).times
311
- full_puppetfile_path = File.join('/rootpath', 'puppet/Puppetfile')
312
- full_puppet_dir = File.join('/rootpath', 'puppet')
313
- full_module_path = File.join('/rootpath', 'puppet/modules')
314
- File.stub(:file?).with(full_puppetfile_path).and_return(true)
315
- File.stub(:readable?).with(full_puppetfile_path).and_return(true)
316
- File.stub(:read).with(full_puppetfile_path).and_return("mod 'branan/eight_hundred' :git => 'https://github.com/branan/eight_hundred'")
317
- errmsg = /SyntaxError: \/rootpath\/puppet\/Puppetfile:1: syntax error, unexpected ':', expecting end-of-input/
318
- expect(ui).to receive(:info).with(/Beginning r10k deploy/).once
319
- expect(ui).to receive(:info).with('vagrant-r10k: Deploy finished').exactly(0).times
320
- expect(ui).to receive(:error).with('Invalid syntax in Puppetfile at /rootpath/puppet/Puppetfile').exactly(1).times
321
- expect{subject.call(env)}.to raise_error(VagrantPlugins::R10k::ErrorWrapper, errmsg)
322
- end
323
- end
324
- describe 'runner failed' do
325
- include_context 'unit' do
326
- let(:vagrantfile) { <<-EOF
327
- Vagrant.configure('2') do |config|
328
- config.vm.define :test
329
- # r10k plugin to deploy puppet modules
330
- config.r10k.puppet_dir = 'puppet'
331
- config.r10k.puppetfile_path = 'puppet/Puppetfile'
332
-
333
- # Provision the machine with the appliction
334
- config.vm.provision "puppet" do |puppet|
335
- puppet.manifests_path = "puppet/manifests"
336
- puppet.manifest_file = "default.pp"
337
- puppet.module_path = "puppet/modules"
338
- end
339
- end
340
- EOF
341
- }
342
- end
343
- it 'raise an error' do
344
- File.stub(:file?).with('/rootpath/puppet/Puppetfile').and_return(true)
345
- expect(ui).to receive(:info).with(/Building the r10k module path with puppet provisioner module_path/).once
346
- expect(ui).to receive(:info).with("vagrant-r10k: Building the r10k module path with puppet provisioner module_path \"puppet/modules\". (if module_path is an array, first element is used)").exactly(0).times
347
- full_puppetfile_path = File.join('/rootpath', 'puppet/Puppetfile')
348
- full_puppet_dir = File.join('/rootpath', 'puppet')
349
- full_module_path = File.join('/rootpath', 'puppet/modules')
350
- File.stub(:file?).with(full_puppetfile_path).and_return(true)
351
- File.stub(:readable?).with(full_puppetfile_path).and_return(true)
352
- File.stub(:read).with(full_puppetfile_path).and_return("mod 'puppetlabs/apache'")
353
- expect(ui).to receive(:info).with(/Beginning r10k deploy/).once
354
- runner = R10K::TaskRunner.new([])
355
- R10K::TaskRunner.stub(:new).and_return(runner)
356
- R10K::TaskRunner.stub(:append_task).and_call_original
357
- runner.stub(:run)
358
- runner.stub(:succeeded?).and_return(false)
359
- runner.stub(:get_errors).and_return([['foo', 'this is an error']])
360
- expect(runner).to receive(:append_task).once
361
- expect(runner).to receive(:run).once
362
- expect(ui).to receive(:info).with('vagrant-r10k: Deploy finished').exactly(0).times
363
- expect{subject.call(env)}.to raise_error(VagrantPlugins::R10k::ErrorWrapper, /this is an error/)
364
- end
365
- end
366
-
367
-
368
- end
369
- end