vagrant-dsc 1.1.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d8b084bcba884bdf9fca4300290c80e2dc5ad4c
4
- data.tar.gz: 80b7d911f8205e82ed29dd6164c593db7161263f
3
+ metadata.gz: 257e8495b08c9b7b2a68472e1645fcc27e2d7b53
4
+ data.tar.gz: 55e75494825b1d264efa388af9983bbb42967c13
5
5
  SHA512:
6
- metadata.gz: fbc5c0dabb0a1695a724e4d329b7e0e6b77093255c9880617742a66226ec6d54774d369714daec0a2759c8894d9c19700054c677bb921454dc7c858a915d8415
7
- data.tar.gz: 3655d498d3f0e2df00815c603516af03e5178911eec15e8ca8da873c58ff0071726a39e01a3531eba816c0284410d3face44e213f54dd6a9b2fdcdb88acef08d
6
+ metadata.gz: b3e3b4d479b4a3f3c30355fbfbc4faabf0872bc0c21b00f2b1ed95527091b9abdea5d70449cd2d0694875950cec8aa179d127b5a14fd5cbf619bb5bfcf7e5e72
7
+ data.tar.gz: 1a0a3f4280c3d6d7bddd2d3d615d88b35b74d30712f6ad90672cd20ea1f0f05a2f98fa06a1719eb56fdf4440862bab1a1ed95be0395b0ef7876b5e71814abc17
data/README.md CHANGED
@@ -85,6 +85,11 @@ In your Vagrantfile, add the following plugin and configure to your needs:
85
85
  # For example, you can set this to "nfs" to use NFS synced folders.
86
86
  dsc.synced_folder_type = "nfs"
87
87
 
88
+ # Whether to abort the vagrant run if DSC fails.
89
+ #
90
+ # By default, this is false.
91
+ dsc.abort_on_dsc_failure = true
92
+
88
93
  # Temporary working directory on the guest machine.
89
94
  dsc.temp_dir = "/tmp/vagrant-dsc"
90
95
  end
@@ -74,19 +74,22 @@ module VagrantPlugins
74
74
  # Do not override this.
75
75
  attr_accessor :expanded_configuration_data_file
76
76
 
77
+ attr_accessor :abort_on_dsc_failure
78
+
77
79
  def initialize
78
80
  super
79
81
 
80
- @configuration_file = UNSET_VALUE
81
- @configuration_data_file = UNSET_VALUE
82
- @manifests_path = UNSET_VALUE
83
- @configuration_name = UNSET_VALUE
84
- @mof_path = UNSET_VALUE
85
- @module_path = UNSET_VALUE
86
- @configuration_params = {}
87
- @synced_folder_type = UNSET_VALUE
88
- @temp_dir = UNSET_VALUE
89
- @module_install = UNSET_VALUE
82
+ @configuration_file = UNSET_VALUE
83
+ @configuration_data_file = UNSET_VALUE
84
+ @manifests_path = UNSET_VALUE
85
+ @configuration_name = UNSET_VALUE
86
+ @mof_path = UNSET_VALUE
87
+ @module_path = UNSET_VALUE
88
+ @configuration_params = {}
89
+ @synced_folder_type = UNSET_VALUE
90
+ @temp_dir = UNSET_VALUE
91
+ @module_install = UNSET_VALUE
92
+ @abort_on_dsc_failure = UNSET_VALUE
90
93
  @logger = Log4r::Logger.new("vagrant::vagrant_dsc")
91
94
  end
92
95
 
@@ -98,15 +101,16 @@ module VagrantPlugins
98
101
  super
99
102
 
100
103
  # Null checks
101
- @configuration_file = "default.ps1" if @configuration_file == UNSET_VALUE
102
- @configuration_data_file = nil if @configuration_data_file == UNSET_VALUE
103
- @module_path = nil if @module_path == UNSET_VALUE
104
- @synced_folder_type = nil if @synced_folder_type == UNSET_VALUE
105
- @temp_dir = nil if @temp_dir == UNSET_VALUE
106
- @module_install = nil if @module_install == UNSET_VALUE
107
- @mof_path = nil if @mof_path == UNSET_VALUE
108
- @configuration_name = File.basename(@configuration_file, File.extname(@configuration_file)) if @configuration_name == UNSET_VALUE
109
- @manifests_path = File.dirname(@configuration_file) if @manifests_path == UNSET_VALUE
104
+ @configuration_file = "default.ps1" if @configuration_file == UNSET_VALUE
105
+ @configuration_data_file = nil if @configuration_data_file == UNSET_VALUE
106
+ @module_path = nil if @module_path == UNSET_VALUE
107
+ @synced_folder_type = nil if @synced_folder_type == UNSET_VALUE
108
+ @temp_dir = nil if @temp_dir == UNSET_VALUE
109
+ @module_install = nil if @module_install == UNSET_VALUE
110
+ @mof_path = nil if @mof_path == UNSET_VALUE
111
+ @configuration_name = File.basename(@configuration_file, File.extname(@configuration_file)) if @configuration_name == UNSET_VALUE
112
+ @manifests_path = File.dirname(@configuration_file) if @manifests_path == UNSET_VALUE
113
+ @abort_on_dsc_failure = false if @abort_on_dsc_failure == UNSET_VALUE
110
114
 
111
115
  # Can't supply them both!
112
116
  if (@configuration_file != nil && @mof_path != nil)
@@ -42,3 +42,5 @@ en:
42
42
  "DSC Status is \"Failure\"."
43
43
  winrm_authorization_error_recover: |-
44
44
  The host terminated the active connection. Try to wait for the completion of DSC.
45
+ dsc_configuration_failed: |-
46
+ Executing the DSC failed. Set 'abort_on_dsc_failure' to false to ignore DSC errors.
@@ -132,6 +132,7 @@ module VagrantPlugins
132
132
  if (get_configuration_status == "Failure")
133
133
  @machine.ui.error(I18n.t("failure_status"))
134
134
  show_dsc_failure_message
135
+ fail_vagrant_run_if_requested
135
136
  end
136
137
  end
137
138
 
@@ -157,6 +158,14 @@ module VagrantPlugins
157
158
  end
158
159
  end
159
160
 
161
+ def fail_vagrant_run_if_requested
162
+ if (@config.abort_on_dsc_failure)
163
+ raise DSCError, :dsc_configuration_failed
164
+ else
165
+ @machine.ui.info("DSC execution failed. Set 'abort_on_dsc_failure' to true to make this fail the build.")
166
+ end
167
+ end
168
+
160
169
  # Cleanup after a destroy action.
161
170
  #
162
171
  # This is the method called when destroying a machine that allows
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module Dsc
3
- VERSION = "1.1.2"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
@@ -29,17 +29,18 @@ describe VagrantPlugins::DSC::Config do
29
29
 
30
30
  before { subject.finalize! }
31
31
 
32
- its("configuration_file") { expect = "default.ps1" }
33
- its("configuration_data_file") { expect be_nil }
34
- its("manifests_path") { expect = "." }
35
- its("configuration_name") { expect = "default" }
36
- its("mof_path") { expect be_nil }
37
- its("module_path") { expect be_nil }
38
- its("options") { expect = [] }
39
- its("configuration_params") { expect = {} }
40
- its("synced_folder_type") { expect be_nil }
41
- its("temp_dir") { expect match /^\/tmp\/vagrant-dsc-*/ }
42
- its("working_directory") { expect be_nil }
32
+ its("configuration_file") { expect = "default.ps1" }
33
+ its("configuration_data_file") { expect be_nil }
34
+ its("manifests_path") { expect = "." }
35
+ its("configuration_name") { expect = "default" }
36
+ its("mof_path") { expect be_nil }
37
+ its("module_path") { expect be_nil }
38
+ its("options") { expect = [] }
39
+ its("configuration_params") { expect = {} }
40
+ its("synced_folder_type") { expect be_nil }
41
+ its("temp_dir") { expect match /^\/tmp\/vagrant-dsc-*/ }
42
+ its("working_directory") { expect be_nil }
43
+ its("abort_on_dsc_failure") { expect be_false }
43
44
  end
44
45
 
45
46
  describe "derived settings" do
@@ -283,6 +283,20 @@ describe VagrantPlugins::DSC::Provisioner do
283
283
  subject.wait_for_dsc_completion
284
284
  end
285
285
 
286
+ it "should throw on failure if requested" do
287
+ allow_any_instance_of(Object).to receive(:sleep)
288
+ allow(guest).to receive(:capability?).with(:wait_for_reboot).and_return(true)
289
+ allow(communicator).to receive(:shell).and_return(shell)
290
+ allow(guest).to receive(:capability).with(:wait_for_reboot)
291
+ allow(subject).to receive(:get_lcm_state).and_return("PendingConfiguration")
292
+ allow(subject).to receive(:get_configuration_status).and_return("Failure")
293
+ allow(subject).to receive(:get_guest_powershell_version).and_return("5")
294
+ expect(subject).to receive(:show_dsc_failure_message)
295
+ allow(root_config).to receive(:abort_on_dsc_failure).and_return(true)
296
+
297
+ expect{ subject.wait_for_dsc_completion }.to raise_error(VagrantPlugins::DSC::DSCError)
298
+ end
299
+
286
300
  it "should not get the lcm state if powershell version is 4" do
287
301
  allow(guest).to receive(:capability?).with(:wait_for_reboot).and_return(true)
288
302
  allow(communicator).to receive(:shell).and_return(shell)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-dsc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 2.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: 2016-10-21 00:00:00.000000000 Z
11
+ date: 2016-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  version: '0'
154
154
  requirements: []
155
155
  rubyforge_project:
156
- rubygems_version: 2.2.0
156
+ rubygems_version: 2.5.1
157
157
  signing_key:
158
158
  specification_version: 4
159
159
  summary: DSC Provisioner for Vagrant