vagrant-dsc 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +47 -13
- data/development/Vagrantfile +34 -5
- data/development/manifests/{ContosoWebsite.ps1 → MyWebsite.ps1} +1 -1
- data/lib/vagrant-dsc/config.rb +93 -42
- data/lib/vagrant-dsc/locales/en.yml +6 -0
- data/lib/vagrant-dsc/plugin.rb +2 -2
- data/lib/vagrant-dsc/provisioner.rb +73 -26
- data/lib/vagrant-dsc/templates/runner.ps1.erb +18 -10
- data/lib/vagrant-dsc/version.rb +1 -1
- data/spec/base.rb +48 -51
- data/spec/provisioner/config_spec.rb +107 -249
- data/spec/provisioner/provisioner_spec.rb +394 -34
- data/spec/spec_helper.rb +4 -1
- data/vagrant-dsc.gemspec +7 -7
- metadata +62 -20
@@ -1,46 +1,406 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'vagrant-dsc/provisioner'
|
3
|
+
require 'vagrant-dsc/config'
|
3
4
|
require 'rspec/its'
|
4
5
|
|
5
6
|
describe VagrantPlugins::DSC::Provisioner do
|
6
|
-
|
7
|
+
include_context "unit"
|
7
8
|
|
8
|
-
|
9
|
+
let(:root_path) { (Pathname.new(Dir.mktmpdir)).to_s }
|
10
|
+
let(:ui) { Vagrant::UI::Silent.new }
|
11
|
+
let(:machine) { double("machine", ui: ui) }
|
12
|
+
let(:env) { double("environment", root_path: root_path, ui: ui) }
|
13
|
+
let(:vm) { double ("vm") }
|
14
|
+
let(:communicator) { double ("communicator") }
|
15
|
+
let(:guest) { double ("guest") }
|
16
|
+
let(:configuration_file) { "manifests/MyWebsite.ps1" }
|
17
|
+
let(:module_path) { ["foo/modules", "foo/modules2"] }
|
18
|
+
let(:root_config) { VagrantPlugins::DSC::Config.new }
|
19
|
+
subject { described_class.new machine, root_config }
|
20
|
+
|
21
|
+
describe "configure" do
|
22
|
+
before do
|
23
|
+
allow(machine).to receive(:root_config).and_return(root_config)
|
24
|
+
machine.stub(config: root_config, env: env)
|
25
|
+
root_config.module_path = module_path
|
26
|
+
root_config.configuration_file = configuration_file
|
27
|
+
root_config.finalize!
|
28
|
+
root_config.validate(machine)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should confirm if the OS is Windows by confirming with the communicator" do
|
32
|
+
allow(root_config).to receive(:vm).and_return(vm)
|
33
|
+
allow(vm).to receive(:communicator).and_return(:winrm)
|
34
|
+
expect(subject.windows?).to eq(true)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "when given default configuration, should share module and manifest folders with the guest" do
|
38
|
+
allow(root_config).to receive(:vm).and_return(vm)
|
39
|
+
expect(vm).to receive(:synced_folder).with("#{root_path}/manifests", /\/tmp\/vagrant-dsc-[0-9]+\/manifests/, {:owner=>"root"})
|
40
|
+
expect(vm).to receive(:synced_folder).with("#{root_path}/foo/modules", /\/tmp\/vagrant-dsc-[0-9]+\/modules-0/, {:owner=>"root"})
|
41
|
+
expect(vm).to receive(:synced_folder).with("#{root_path}/foo/modules2", /\/tmp\/vagrant-dsc-[0-9]+\/modules-1/, {:owner=>"root"})
|
42
|
+
|
43
|
+
subject.configure(root_config)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "when given a specific folder type, should modify folder options when sharing module and manifest folders with the guest" do
|
47
|
+
root_config.synced_folder_type = "nfs"
|
48
|
+
allow(root_config).to receive(:vm).and_return(vm)
|
49
|
+
|
50
|
+
expect(vm).to receive(:synced_folder).with("#{root_path}/manifests", /\/tmp\/vagrant-dsc-[0-9]+\/manifests/, {:type=>"nfs"})
|
51
|
+
expect(vm).to receive(:synced_folder).with("#{root_path}/foo/modules", /\/tmp\/vagrant-dsc-[0-9]+\/modules-0/, {:type=>"nfs"})
|
52
|
+
expect(vm).to receive(:synced_folder).with("#{root_path}/foo/modules2", /\/tmp\/vagrant-dsc-[0-9]+\/modules-1/, {:type=>"nfs"})
|
53
|
+
|
54
|
+
subject.configure(root_config)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "when provided only manifests path, should only share manifest folders with the guest" do
|
58
|
+
root_config.synced_folder_type = "nfs"
|
59
|
+
root_config.module_path = nil
|
60
|
+
allow(root_config).to receive(:vm).and_return(vm)
|
61
|
+
|
62
|
+
expect(vm).to receive(:synced_folder).with("#{root_path}/manifests", /\/tmp\/vagrant-dsc-[0-9]+\/manifests/, {:type=>"nfs"})
|
63
|
+
|
64
|
+
subject.configure(root_config)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should install DSC for supported OS's" do
|
68
|
+
expect { subject.install_dsc }.to raise_error("\"Operation unsupported / not-yet implemented: install_dsc\"")
|
69
|
+
|
70
|
+
|
71
|
+
# "Operation unsupported / not-yet implemented: install_dsc"
|
72
|
+
# expect { subject.install_dsc }.to raise_error(VagrantPlugins::DSC::DSCError)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "verify shared folders" do
|
77
|
+
|
78
|
+
before do
|
79
|
+
allow(machine).to receive(:root_config).and_return(root_config)
|
80
|
+
machine.stub(config: root_config, env: env, communicate: communicator)
|
81
|
+
root_config.module_path = module_path
|
82
|
+
root_config.configuration_file = configuration_file
|
83
|
+
root_config.finalize!
|
84
|
+
root_config.validate(machine)
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should raise error if folders not shared" do
|
88
|
+
root_config.synced_folder_type = "nfs"
|
89
|
+
|
90
|
+
expect(communicator).to receive(:test).with("test -d foo/modules", {:sudo=>true}).and_return(false)
|
91
|
+
|
92
|
+
subject.configure(root_config)
|
93
|
+
|
94
|
+
folders = module_path << File.dirname(configuration_file)
|
95
|
+
expect { subject.verify_shared_folders(folders) }.to raise_error("Shared folders not properly configured. This is generally resolved by a 'vagrant halt && vagrant up'")
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should ensure shared folders are properly shared" do
|
99
|
+
root_config.synced_folder_type = "nfs"
|
100
|
+
|
101
|
+
expect(communicator).to receive(:test).with("test -d foo/modules", {:sudo=>true}).and_return(true)
|
102
|
+
expect(communicator).to receive(:test).with("test -d foo/modules2", {:sudo=>true}).and_return(true)
|
103
|
+
expect(communicator).to receive(:test).with("test -d manifests", {:sudo=>true}).and_return(true)
|
104
|
+
|
105
|
+
subject.configure(root_config)
|
106
|
+
|
107
|
+
folders = module_path << File.dirname(configuration_file)
|
108
|
+
subject.verify_shared_folders(folders)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "provision" do
|
113
|
+
|
114
|
+
before do
|
115
|
+
# allow(root_config).to receive(:vm).and_return(vm)
|
116
|
+
allow(machine).to receive(:root_config).and_return(root_config)
|
117
|
+
allow(machine).to receive(:env).and_return(env)
|
118
|
+
root_config.module_path = module_path
|
119
|
+
root_config.configuration_file = configuration_file
|
120
|
+
root_config.finalize!
|
121
|
+
root_config.validate(machine)
|
122
|
+
subject.configure(root_config)
|
123
|
+
# allow(root_config).to receive(:vm).and_return(vm)
|
124
|
+
machine.stub(config: root_config, env: env, communicate: communicator, guest: guest)
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should allow reboot capability when capability exists" do
|
128
|
+
allow(communicator).to receive(:sudo)
|
129
|
+
allow(communicator).to receive(:test)
|
130
|
+
allow(subject).to receive(:verify_shared_folders).and_return(true)
|
131
|
+
allow(subject).to receive(:verify_dsc).and_return(true)
|
132
|
+
allow(subject).to receive(:run_dsc_apply).and_return(true)
|
133
|
+
allow(guest).to receive(:capability?).with(:wait_for_reboot).and_return(true)
|
134
|
+
expect(guest).to receive(:capability).with(:wait_for_reboot)
|
135
|
+
|
136
|
+
subject.provision
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should not allow reboot capability when capability does not exist" do
|
140
|
+
allow(communicator).to receive(:sudo)
|
141
|
+
allow(communicator).to receive(:test)
|
142
|
+
allow(subject).to receive(:verify_shared_folders).and_return(true)
|
143
|
+
allow(subject).to receive(:verify_dsc).and_return(true)
|
144
|
+
allow(subject).to receive(:run_dsc_apply).and_return(true)
|
145
|
+
allow(guest).to receive(:capability?).with(:wait_for_reboot).and_return(false)
|
146
|
+
expect(guest).to_not receive(:capability).with(:wait_for_reboot)
|
147
|
+
|
148
|
+
subject.provision
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should create temporary folders on the guest" do
|
152
|
+
allow(communicator).to receive(:test)
|
153
|
+
allow(subject).to receive(:verify_shared_folders).and_return(true)
|
154
|
+
allow(subject).to receive(:verify_dsc).and_return(true)
|
155
|
+
allow(subject).to receive(:run_dsc_apply).and_return(true)
|
156
|
+
allow(guest).to receive(:capability?)
|
157
|
+
allow(guest).to receive(:capability)
|
158
|
+
|
159
|
+
expect(communicator).to receive(:sudo).with("mkdir -p #{root_config.temp_dir}")
|
160
|
+
expect(communicator).to receive(:sudo).with("chmod 0777 #{root_config.temp_dir}")
|
161
|
+
|
162
|
+
subject.provision
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should ensure shared folders are properly configured" do
|
166
|
+
allow(communicator).to receive(:test)
|
167
|
+
allow(communicator).to receive(:sudo)
|
168
|
+
allow(subject).to receive(:verify_dsc).and_return(true)
|
169
|
+
allow(subject).to receive(:run_dsc_apply).and_return(true)
|
170
|
+
allow(guest).to receive(:capability?)
|
171
|
+
allow(guest).to receive(:capability)
|
172
|
+
|
173
|
+
check = ["#{root_config.temp_dir}/manifests", "#{root_config.temp_dir}/modules-0", "#{root_config.temp_dir}/modules-1"]
|
174
|
+
expect(subject).to receive(:verify_shared_folders).with(check)
|
175
|
+
|
176
|
+
subject.provision
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should verify DSC binary exists" do
|
180
|
+
expect(communicator).to receive(:sudo).with("which Start-DscConfiguration", {:error_class=>VagrantPlugins::DSC::DSCError, :error_key=>:dsc_not_detected, :binary=>"Start-DscConfiguration"})
|
181
|
+
subject.verify_binary("Start-DscConfiguration")
|
182
|
+
end
|
183
|
+
|
184
|
+
it "should verify DSC and Powershell versions are valid" do
|
185
|
+
expect(communicator).to receive(:test).with("(($PSVersionTable | ConvertTo-json | ConvertFrom-Json).PSVersion.Major) -ge 4", {:error_class=>VagrantPlugins::DSC::DSCError, :error_key=>:dsc_incorrect_PowerShell_version}).and_return(true)
|
186
|
+
allow(subject).to receive(:verify_binary).and_return(true)
|
187
|
+
subject.verify_dsc
|
188
|
+
end
|
189
|
+
|
190
|
+
it "should raise an error if DSC version is invalid" do
|
191
|
+
# shell = double("WinRMShell")
|
192
|
+
# allow(communicator).to receive(:shell).and_return(shell)
|
193
|
+
# allow(communicator).to receive(:create_shell).and_return(shell)
|
194
|
+
|
195
|
+
# TODO: Create an actual Communicator object and mock out methods/calls to isolate this behaviour better
|
196
|
+
expect(communicator).to receive(:test).with("(($PSVersionTable | ConvertTo-json | ConvertFrom-Json).PSVersion.Major) -ge 4", {:error_class=>VagrantPlugins::DSC::DSCError, :error_key=>:dsc_incorrect_PowerShell_version})
|
197
|
+
allow(subject).to receive(:verify_binary).and_return(true)
|
198
|
+
# expect { subject.verify_dsc }.to raise_error("Unable to detect a working DSC environment. Please ensure powershell v4+ is installed, including WMF 4+.")
|
199
|
+
subject.verify_dsc
|
200
|
+
end
|
201
|
+
|
202
|
+
it "should raise an error if Powershell version is invalid" do
|
203
|
+
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
describe "DSC runner script" do
|
208
|
+
before do
|
209
|
+
# Prevent counters messing with output in tests
|
210
|
+
Vagrant::Util::Counter.class_eval do
|
211
|
+
def get_and_update_counter(name=nil) 1 end
|
212
|
+
end
|
213
|
+
|
214
|
+
allow(machine).to receive(:root_config).and_return(root_config)
|
215
|
+
root_config.configuration_file = configuration_file
|
216
|
+
machine.stub(config: root_config, env: env)
|
217
|
+
root_config.module_path = module_path
|
218
|
+
root_config.configuration_file = configuration_file
|
219
|
+
root_config.finalize!
|
220
|
+
root_config.validate(machine)
|
221
|
+
subject.configure(root_config)
|
222
|
+
|
223
|
+
end
|
224
|
+
|
225
|
+
context "with default parameters" do
|
226
|
+
it "should generate a valid powershell command" do
|
227
|
+
script = subject.generate_dsc_runner_script
|
228
|
+
expect_script = "#
|
229
|
+
# DSC Runner.
|
230
|
+
#
|
231
|
+
# Bootstraps the DSC environment, sets up configuration data
|
232
|
+
# and runs the DSC Configuration.
|
233
|
+
#
|
234
|
+
#
|
235
|
+
|
236
|
+
# Set the local PowerShell Module environment path
|
237
|
+
echo \"Adding to path: /tmp/vagrant-dsc-1/modules-0;/tmp/vagrant-dsc-1/modules-1\"
|
238
|
+
$env:PSModulePath=\"/tmp/vagrant-dsc-1/modules-0;/tmp/vagrant-dsc-1/modules-1;${env:PSModulePath}\"
|
239
|
+
|
240
|
+
$script = $(Join-Path \"/tmp/vagrant-dsc-1\" \"manifests/MyWebsite.ps1\")
|
241
|
+
echo \"PSModulePath Configured: ${env:PSModulePath}\"
|
242
|
+
echo \"Running Configuration file: ${script}\"
|
243
|
+
|
244
|
+
# Generate the MOF file, only if a MOF path not already provided.
|
245
|
+
# Import the Manifest
|
246
|
+
. $script
|
247
|
+
|
248
|
+
cd \"/tmp/vagrant-dsc-1\"
|
249
|
+
$StagingPath = $(Join-Path \"/tmp/vagrant-dsc-1\" \"staging\")
|
250
|
+
MyWebsite -MachineName \"localhost\" -OutputPath $StagingPath
|
251
|
+
|
252
|
+
# Start a DSC Configuration run
|
253
|
+
Start-DscConfiguration -Force -Wait -Verbose -Path $StagingPath
|
254
|
+
|
255
|
+
# Cleanup
|
256
|
+
del -Path $StagingPath -Recurse"
|
257
|
+
|
258
|
+
expect(script).to eq(expect_script)
|
259
|
+
end
|
260
|
+
|
261
|
+
it "should skip MOF file generation if one already provided" do
|
9
262
|
|
10
|
-
describe "defaults" do
|
11
|
-
subject do
|
12
|
-
instance.tap do |o|
|
13
|
-
o.finalize!
|
14
263
|
end
|
15
264
|
end
|
16
265
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
266
|
+
context "with custom DSC Parameters" do
|
267
|
+
it "should pass through arguments to the generated Powershell runner" do
|
268
|
+
root_config.configuration_params = {"-Foo" => "bar", "-ComputerName" => "catz"}
|
269
|
+
script = subject.generate_dsc_runner_script
|
270
|
+
|
271
|
+
expect_script = "#
|
272
|
+
# DSC Runner.
|
273
|
+
#
|
274
|
+
# Bootstraps the DSC environment, sets up configuration data
|
275
|
+
# and runs the DSC Configuration.
|
276
|
+
#
|
277
|
+
#
|
278
|
+
|
279
|
+
# Set the local PowerShell Module environment path
|
280
|
+
echo \"Adding to path: /tmp/vagrant-dsc-1/modules-0;/tmp/vagrant-dsc-1/modules-1\"
|
281
|
+
$env:PSModulePath=\"/tmp/vagrant-dsc-1/modules-0;/tmp/vagrant-dsc-1/modules-1;${env:PSModulePath}\"
|
282
|
+
|
283
|
+
$script = $(Join-Path \"/tmp/vagrant-dsc-1\" \"manifests/MyWebsite.ps1\")
|
284
|
+
echo \"PSModulePath Configured: ${env:PSModulePath}\"
|
285
|
+
echo \"Running Configuration file: ${script}\"
|
286
|
+
|
287
|
+
# Generate the MOF file, only if a MOF path not already provided.
|
288
|
+
# Import the Manifest
|
289
|
+
. $script
|
290
|
+
|
291
|
+
cd \"/tmp/vagrant-dsc-1\"
|
292
|
+
$StagingPath = $(Join-Path \"/tmp/vagrant-dsc-1\" \"staging\")
|
293
|
+
MyWebsite -MachineName \"localhost\" -OutputPath $StagingPath -Foo \"bar\" -ComputerName \"catz\"
|
294
|
+
|
295
|
+
# Start a DSC Configuration run
|
296
|
+
Start-DscConfiguration -Force -Wait -Verbose -Path $StagingPath
|
297
|
+
|
298
|
+
# Cleanup
|
299
|
+
del -Path $StagingPath -Recurse"
|
27
300
|
|
301
|
+
expect(script).to eq(expect_script)
|
302
|
+
end
|
303
|
+
|
304
|
+
it "should allow flags as arguments to the generated Powershell runner" do
|
305
|
+
root_config.configuration_params = {"-FooFlag" => nil, "-BarFlag" => nil, "-FooParam" => "FooVal"}
|
306
|
+
script = subject.generate_dsc_runner_script
|
307
|
+
|
308
|
+
expect_script = "#
|
309
|
+
# DSC Runner.
|
310
|
+
#
|
311
|
+
# Bootstraps the DSC environment, sets up configuration data
|
312
|
+
# and runs the DSC Configuration.
|
313
|
+
#
|
314
|
+
#
|
315
|
+
|
316
|
+
# Set the local PowerShell Module environment path
|
317
|
+
echo \"Adding to path: /tmp/vagrant-dsc-1/modules-0;/tmp/vagrant-dsc-1/modules-1\"
|
318
|
+
$env:PSModulePath=\"/tmp/vagrant-dsc-1/modules-0;/tmp/vagrant-dsc-1/modules-1;${env:PSModulePath}\"
|
319
|
+
|
320
|
+
$script = $(Join-Path \"/tmp/vagrant-dsc-1\" \"manifests/MyWebsite.ps1\")
|
321
|
+
echo \"PSModulePath Configured: ${env:PSModulePath}\"
|
322
|
+
echo \"Running Configuration file: ${script}\"
|
323
|
+
|
324
|
+
# Generate the MOF file, only if a MOF path not already provided.
|
325
|
+
# Import the Manifest
|
326
|
+
. $script
|
327
|
+
|
328
|
+
cd \"/tmp/vagrant-dsc-1\"
|
329
|
+
$StagingPath = $(Join-Path \"/tmp/vagrant-dsc-1\" \"staging\")
|
330
|
+
MyWebsite -MachineName \"localhost\" -OutputPath $StagingPath -FooFlag -BarFlag -FooParam \"FooVal\"
|
331
|
+
|
332
|
+
# Start a DSC Configuration run
|
333
|
+
Start-DscConfiguration -Force -Wait -Verbose -Path $StagingPath
|
334
|
+
|
335
|
+
# Cleanup
|
336
|
+
del -Path $StagingPath -Recurse"
|
337
|
+
|
338
|
+
expect(script).to eq(expect_script)
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
context "with a MOF file specified" do
|
343
|
+
it "should generate a script that does not generate a new MOF" do
|
344
|
+
root_config.configuration_params = {}
|
345
|
+
root_config.mof_path = "staging"
|
346
|
+
script = subject.generate_dsc_runner_script
|
347
|
+
|
348
|
+
expect_script = "#
|
349
|
+
# DSC Runner.
|
350
|
+
#
|
351
|
+
# Bootstraps the DSC environment, sets up configuration data
|
352
|
+
# and runs the DSC Configuration.
|
353
|
+
#
|
354
|
+
#
|
355
|
+
|
356
|
+
# Set the local PowerShell Module environment path
|
357
|
+
echo \"Adding to path: /tmp/vagrant-dsc-1/modules-0;/tmp/vagrant-dsc-1/modules-1\"
|
358
|
+
$env:PSModulePath=\"/tmp/vagrant-dsc-1/modules-0;/tmp/vagrant-dsc-1/modules-1;${env:PSModulePath}\"
|
359
|
+
|
360
|
+
$script = $(Join-Path \"/tmp/vagrant-dsc-1\" \"manifests/MyWebsite.ps1\")
|
361
|
+
echo \"PSModulePath Configured: ${env:PSModulePath}\"
|
362
|
+
echo \"Running Configuration file: ${script}\"
|
363
|
+
|
364
|
+
# Generate the MOF file, only if a MOF path not already provided.
|
365
|
+
$StagingPath = \"staging\"
|
366
|
+
|
367
|
+
# Start a DSC Configuration run
|
368
|
+
Start-DscConfiguration -Force -Wait -Verbose -Path $StagingPath
|
369
|
+
|
370
|
+
# Cleanup
|
371
|
+
del -Path $StagingPath -Recurse"
|
372
|
+
|
373
|
+
expect(script).to eq(expect_script)
|
374
|
+
end
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
describe "write DSC Runner script" do
|
379
|
+
it "should upload the customised DSC runner to the guest" do
|
380
|
+
script = "myscript"
|
381
|
+
path = "/local/runner/path"
|
382
|
+
guest_path = "c:/tmp/vagrant-dsc-runner.ps1"
|
383
|
+
machine.stub(config: root_config, env: env, communicate: communicator)
|
384
|
+
file = double("file")
|
385
|
+
allow(file).to receive(:path).and_return(path)
|
386
|
+
allow(Tempfile).to receive(:new) { file }
|
387
|
+
expect(file).to receive(:write).with(script)
|
388
|
+
expect(file).to receive(:fsync)
|
389
|
+
expect(file).to receive(:close).exactly(2).times
|
390
|
+
expect(file).to receive(:unlink)
|
391
|
+
expect(communicator).to receive(:upload).with(path, guest_path)
|
392
|
+
res = subject.write_dsc_runner_script(script)
|
393
|
+
expect(res.to_s).to eq(guest_path)
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
397
|
+
describe "Apply DSC" do
|
398
|
+
it "should invoke the DSC Runner and notify the User of provisioning status" do
|
399
|
+
expect(ui).to receive(:info).with(any_args).once
|
400
|
+
expect(ui).to receive(:info).with("provisioned!").once
|
401
|
+
allow(machine).to receive(:communicate).and_return(communicator)
|
402
|
+
expect(communicator).to receive(:sudo).with('.\\' + "'c:/tmp/vagrant-dsc-runner.ps1'",{:elevated=>true, :error_key=>:ssh_bad_exit_status_muted, :good_exit=>[0, 2]}).and_yield("type", "provisioned!")
|
403
|
+
subject.run_dsc_apply
|
404
|
+
end
|
28
405
|
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# describe "#vagrant_vagrantfile" do
|
32
|
-
# before { valid_defaults }
|
33
|
-
|
34
|
-
# it "should be valid if set to a file" do
|
35
|
-
# subject.vagrant_vagrantfile = temporary_file.to_s
|
36
|
-
# subject.finalize!
|
37
|
-
# assert_valid
|
38
|
-
# end
|
39
|
-
|
40
|
-
# it "should not be valid if set to a non-existent place" do
|
41
|
-
# subject.vagrant_vagrantfile = "/i/shouldnt/exist"
|
42
|
-
# subject.finalize!
|
43
|
-
# assert_invalid
|
44
|
-
# end
|
45
|
-
# end
|
46
|
-
# end
|
406
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,20 +4,23 @@ require 'coveralls'
|
|
4
4
|
require 'vagrant-dsc/version'
|
5
5
|
require 'vagrant-dsc/plugin'
|
6
6
|
require 'rspec/its'
|
7
|
+
require 'base'
|
7
8
|
|
8
9
|
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
9
10
|
SimpleCov::Formatter::HTMLFormatter,
|
10
11
|
Coveralls::SimpleCov::Formatter
|
11
12
|
]
|
13
|
+
|
12
14
|
SimpleCov.start do
|
13
15
|
coverage_dir('tmp/coverage')
|
14
16
|
add_filter '/spec/'
|
15
17
|
end
|
18
|
+
|
16
19
|
RSpec.configure do |config|
|
17
20
|
config.expect_with :rspec do |c|
|
18
21
|
c.syntax = :expect
|
19
22
|
end
|
20
23
|
config.color = true
|
21
24
|
config.tty = true
|
22
|
-
config.raise_errors_for_deprecations!
|
25
|
+
# config.raise_errors_for_deprecations!
|
23
26
|
end
|
data/vagrant-dsc.gemspec
CHANGED
@@ -18,11 +18,11 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "
|
22
|
-
spec.add_development_dependency "
|
23
|
-
spec.add_development_dependency "coveralls"
|
24
|
-
spec.add_development_dependency "rspec-core"
|
25
|
-
spec.add_development_dependency "rspec-expectations"
|
26
|
-
spec.add_development_dependency "rspec-mocks"
|
27
|
-
spec.add_development_dependency "rspec-its"
|
21
|
+
spec.add_development_dependency "rake", '~> 10.3', '>= 10.3.0'
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.6", '>= 1.6.0'
|
23
|
+
spec.add_development_dependency "coveralls", "~> 0.7.1", '>= 0.7.1'
|
24
|
+
spec.add_development_dependency "rspec-core", '~> 3.1', '>= 3.1.0'
|
25
|
+
spec.add_development_dependency "rspec-expectations", '~> 3.1', '>= 3.1.0'
|
26
|
+
spec.add_development_dependency "rspec-mocks", '~> 3.1', '>= 3.1.0'
|
27
|
+
spec.add_development_dependency "rspec-its", "~> 1.0.1", '>= 1.0.0'
|
28
28
|
end
|
metadata
CHANGED
@@ -1,113 +1,155 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-dsc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Fellows
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '10.3'
|
20
|
+
- - '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 10.3.0
|
20
23
|
type: :development
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
29
|
+
version: '10.3'
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 10.3.0
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
34
|
+
name: bundler
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
37
|
+
- - ~>
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.6'
|
31
40
|
- - '>='
|
32
41
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
42
|
+
version: 1.6.0
|
34
43
|
type: :development
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
37
46
|
requirements:
|
47
|
+
- - ~>
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '1.6'
|
38
50
|
- - '>='
|
39
51
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
52
|
+
version: 1.6.0
|
41
53
|
- !ruby/object:Gem::Dependency
|
42
54
|
name: coveralls
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|
44
56
|
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 0.7.1
|
45
60
|
- - '>='
|
46
61
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
62
|
+
version: 0.7.1
|
48
63
|
type: :development
|
49
64
|
prerelease: false
|
50
65
|
version_requirements: !ruby/object:Gem::Requirement
|
51
66
|
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.7.1
|
52
70
|
- - '>='
|
53
71
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
72
|
+
version: 0.7.1
|
55
73
|
- !ruby/object:Gem::Dependency
|
56
74
|
name: rspec-core
|
57
75
|
requirement: !ruby/object:Gem::Requirement
|
58
76
|
requirements:
|
77
|
+
- - ~>
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '3.1'
|
59
80
|
- - '>='
|
60
81
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
82
|
+
version: 3.1.0
|
62
83
|
type: :development
|
63
84
|
prerelease: false
|
64
85
|
version_requirements: !ruby/object:Gem::Requirement
|
65
86
|
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.1'
|
66
90
|
- - '>='
|
67
91
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
92
|
+
version: 3.1.0
|
69
93
|
- !ruby/object:Gem::Dependency
|
70
94
|
name: rspec-expectations
|
71
95
|
requirement: !ruby/object:Gem::Requirement
|
72
96
|
requirements:
|
97
|
+
- - ~>
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '3.1'
|
73
100
|
- - '>='
|
74
101
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
102
|
+
version: 3.1.0
|
76
103
|
type: :development
|
77
104
|
prerelease: false
|
78
105
|
version_requirements: !ruby/object:Gem::Requirement
|
79
106
|
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '3.1'
|
80
110
|
- - '>='
|
81
111
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
112
|
+
version: 3.1.0
|
83
113
|
- !ruby/object:Gem::Dependency
|
84
114
|
name: rspec-mocks
|
85
115
|
requirement: !ruby/object:Gem::Requirement
|
86
116
|
requirements:
|
117
|
+
- - ~>
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '3.1'
|
87
120
|
- - '>='
|
88
121
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
122
|
+
version: 3.1.0
|
90
123
|
type: :development
|
91
124
|
prerelease: false
|
92
125
|
version_requirements: !ruby/object:Gem::Requirement
|
93
126
|
requirements:
|
127
|
+
- - ~>
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '3.1'
|
94
130
|
- - '>='
|
95
131
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
132
|
+
version: 3.1.0
|
97
133
|
- !ruby/object:Gem::Dependency
|
98
134
|
name: rspec-its
|
99
135
|
requirement: !ruby/object:Gem::Requirement
|
100
136
|
requirements:
|
137
|
+
- - ~>
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: 1.0.1
|
101
140
|
- - '>='
|
102
141
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
142
|
+
version: 1.0.0
|
104
143
|
type: :development
|
105
144
|
prerelease: false
|
106
145
|
version_requirements: !ruby/object:Gem::Requirement
|
107
146
|
requirements:
|
147
|
+
- - ~>
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: 1.0.1
|
108
150
|
- - '>='
|
109
151
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
152
|
+
version: 1.0.0
|
111
153
|
description: Desired State Configuration (http://technet.microsoft.com/en-au/library/dn249912.aspx)
|
112
154
|
provisioning plugin for Vagrant.
|
113
155
|
email:
|
@@ -123,7 +165,7 @@ files:
|
|
123
165
|
- README.md
|
124
166
|
- Rakefile
|
125
167
|
- development/Vagrantfile
|
126
|
-
- development/manifests/
|
168
|
+
- development/manifests/MyWebsite.ps1
|
127
169
|
- lib/vagrant-dsc.rb
|
128
170
|
- lib/vagrant-dsc/config.rb
|
129
171
|
- lib/vagrant-dsc/locales/en.yml
|
@@ -159,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
201
|
version: '0'
|
160
202
|
requirements: []
|
161
203
|
rubyforge_project:
|
162
|
-
rubygems_version: 2.
|
204
|
+
rubygems_version: 2.0.14
|
163
205
|
signing_key:
|
164
206
|
specification_version: 4
|
165
207
|
summary: DSC Provisioner for Vagrant
|