vagrant-windows-domain 1.1.9 → 1.1.10
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 095e05843eb3706414d810629f88d6e620564915
|
4
|
+
data.tar.gz: 12576a90db3eb7fb7378f214084f25847d114400
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aefd80b95d8ee2c56028fecb163ab635b20535e54657c2624707288fd738abc63242976c31da14d6fc592c6e4af30f004104e2c764340ed7f7476d9ec8640eb5
|
7
|
+
data.tar.gz: 9d195b673d48ed679cb00b82c737301253d55c9ad437a3c53031322a57e67fadb0b7146aa40f783752b085d66b6e5360cc1c38683932c4336497732900f1ed9a
|
@@ -20,13 +20,13 @@ module VagrantPlugins
|
|
20
20
|
# Default path for storing the transient script runner
|
21
21
|
WINDOWS_DOMAIN_GUEST_RUNNER_PATH = "c:/tmp/vagrant-windows-domain-runner.ps1"
|
22
22
|
|
23
|
-
attr_accessor :restart_sleep_duration
|
23
|
+
attr_accessor :restart_sleep_duration
|
24
24
|
|
25
25
|
# The current Computer Name.
|
26
26
|
#
|
27
27
|
# Used to determine whether or not we need to rename the computer
|
28
28
|
# on join. This parameter should not be manually set.
|
29
|
-
attr_accessor :old_computer_name
|
29
|
+
attr_accessor :old_computer_name
|
30
30
|
|
31
31
|
# Constructs the Provisioner Plugin.
|
32
32
|
#
|
@@ -105,7 +105,9 @@ module VagrantPlugins
|
|
105
105
|
def destroy
|
106
106
|
if @config && @config.include?("domain")
|
107
107
|
set_credentials
|
108
|
-
leave_domain
|
108
|
+
if leave_domain
|
109
|
+
restart_guest
|
110
|
+
end
|
109
111
|
else
|
110
112
|
@logger.debug("Not leaving domain on `destroy` action - no valid configuration detected")
|
111
113
|
return
|
@@ -223,11 +225,19 @@ module VagrantPlugins
|
|
223
225
|
@machine.ui.info(I18n.t(
|
224
226
|
"vagrant_windows_domain.running"))
|
225
227
|
|
228
|
+
opts = {
|
229
|
+
elevated: true,
|
230
|
+
error_check: true,
|
231
|
+
error_key: nil, # use the error_class message key
|
232
|
+
good_exit: 0,
|
233
|
+
shell: :powershell
|
234
|
+
}
|
235
|
+
|
226
236
|
# A bit of an ugly dance, but this is how we get neat, colourised output and exit codes from a Powershell run
|
227
237
|
last_type = nil
|
228
238
|
new_line = ""
|
229
239
|
error = false
|
230
|
-
machine.communicate.
|
240
|
+
machine.communicate.sudo("powershell -ExecutionPolicy Bypass -OutputFormat Text -file #{script_path}", opts) do |type, data|
|
231
241
|
if !data.chomp.empty?
|
232
242
|
error = true if type == :stderr
|
233
243
|
if [:stderr, :stdout].include?(type)
|
@@ -10,7 +10,7 @@ describe VagrantPlugins::WindowsDomain::LeaveDomain do
|
|
10
10
|
let(:instance) { described_class.new }
|
11
11
|
|
12
12
|
let(:root_path) { (Pathname.new(Dir.mktmpdir)).to_s }
|
13
|
-
let(:domain)
|
13
|
+
let(:domain) { "foo.com" }
|
14
14
|
let(:ui) { double("ui") }
|
15
15
|
let(:app) { double("app") }
|
16
16
|
let(:communicator) { double ("communicator") }
|
@@ -19,9 +19,9 @@ describe VagrantPlugins::WindowsDomain::LeaveDomain do
|
|
19
19
|
let(:guest) { double ("guest") }
|
20
20
|
let(:configuration_file) { "manifests/MyWebsite.ps1" }
|
21
21
|
let(:module_path) { ["foo/modules", "foo/modules2"] }
|
22
|
-
let(:config)
|
22
|
+
let(:config) { VagrantPlugins::WindowsDomain::Config.new }
|
23
23
|
let(:vm) { double("vm", provisioners: [double("prov", config: config)]) }
|
24
|
-
let(:root_config)
|
24
|
+
let(:root_config) { double("root_config", vm: vm) }
|
25
25
|
let(:env) { {:ui => ui, :machine => machine} }
|
26
26
|
let(:machine) { double("machine", ui: ui, id: "1234", config: root_config) }
|
27
27
|
let(:provisioner) { double("provisioner") }
|
@@ -34,7 +34,7 @@ describe VagrantPlugins::WindowsDomain::LeaveDomain do
|
|
34
34
|
allow(env).to receive(:machine).and_return(machine)
|
35
35
|
allow(communicator).to receive(:shell).and_return(shell)
|
36
36
|
allow(shell).to receive(:powershell).and_yield(:stdout, "myoldcomputername")
|
37
|
-
|
37
|
+
config.domain = domain
|
38
38
|
allow(env).to receive(:machine).and_return(machine)
|
39
39
|
allow(machine).to receive(:env).and_return(env)
|
40
40
|
allow(env).to receive(:ui).and_return(ui)
|
@@ -42,91 +42,88 @@ describe VagrantPlugins::WindowsDomain::LeaveDomain do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
context "when no configuration exists for the machine" do
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
it "should pass control to the next middleware Action" do
|
46
|
+
config.domain = nil
|
47
|
+
expect(app).to receive(:call).with(env)
|
48
|
+
subject.call(env)
|
49
|
+
end
|
50
50
|
end
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
context "when machine is running" do
|
53
|
+
it "should prompt the user if they would like to destroy & d/c the machine" do
|
54
|
+
state = double("state", id: :running)
|
55
|
+
expect(provisioner).to receive(:destroy)
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
expect(app).to receive(:call).with(env)
|
58
|
+
expect(ui).to receive(:ask).with("Are you sure you want to destroy this machine and disconnect from #{domain}? (y/n)").and_return("y")
|
59
|
+
expect(machine).to receive(:state).and_return(state).twice
|
60
|
+
subject.call(env)
|
61
61
|
|
62
|
-
|
62
|
+
end
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
it "should not continue if the user declines to destroy the machine" do
|
65
|
+
state = double("state", id: :running)
|
66
|
+
expect(provisioner).to_not receive(:destroy)
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
context "when machine is :paused, :saved or :poweroff" do
|
77
|
-
it "should prompt the user if they would like to force destroy the machine" do
|
78
|
-
state = double("state", id: :poweroff)
|
79
|
-
provisioner = double("provisioner")
|
80
|
-
subject.provisioner = provisioner
|
81
|
-
|
82
|
-
expect(ui).to receive(:say).with(:warn, "Machine is currently not running. To properly leave the #{domain} network the machine needs to be running and connected to the network in which it was provisioned. Please run `vagrant up` and then `vagrant destroy`.\n")
|
83
|
-
expect(ui).to receive(:ask).with("Would you like to continue destroying this machine, leaving this machine orphaned in the '#{domain}' network? (y/n)").and_return("y")
|
84
|
-
expect(ui).to receive(:say).with(:warn, "Force destroying this machine and not leaving the domain foo.com. May FSM have mercy on your soul.")
|
85
|
-
expect(machine).to receive(:state).and_return(state).twice
|
86
|
-
expect(app).to receive(:call).with(env)
|
87
|
-
# Can't call destroy on a non-running machine
|
88
|
-
expect(provisioner).to_not receive(:destroy)
|
89
|
-
|
90
|
-
subject.call(env)
|
91
|
-
|
92
|
-
expect(env[:force_confirm_destroy]).to be(true)
|
93
|
-
end
|
94
|
-
|
95
|
-
it "should not pass on to middleware if user declines force destroy" do
|
96
|
-
state = double("state", id: :poweroff)
|
97
|
-
provisioner = double("provisioner")
|
98
|
-
subject.provisioner = provisioner
|
99
|
-
|
100
|
-
expect(ui).to receive(:say).with(:warn, "Machine is currently not running. To properly leave the #{domain} network the machine needs to be running and connected to the network in which it was provisioned. Please run `vagrant up` and then `vagrant destroy`.\n")
|
101
|
-
expect(ui).to receive(:ask).with("Would you like to continue destroying this machine, leaving this machine orphaned in the '#{domain}' network? (y/n)").and_return("n")
|
102
|
-
expect(machine).to receive(:state).and_return(state).twice
|
103
|
-
expect(app).to_not receive(:call).with(env)
|
104
|
-
expect(provisioner).to_not receive(:destroy)
|
105
|
-
expect(env[:force_confirm_destroy]).to be(nil)
|
106
|
-
|
107
|
-
subject.call(env)
|
108
|
-
|
109
|
-
end
|
110
|
-
end
|
68
|
+
expect(ui).to receive(:ask).with("Are you sure you want to destroy this machine and disconnect from #{domain}? (y/n)").and_return("n")
|
69
|
+
expect(machine).to receive(:state).and_return(state).twice
|
70
|
+
expect(app).to_not receive(:call).with(env)
|
71
|
+
subject.call(env)
|
72
|
+
end
|
73
|
+
end
|
111
74
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
75
|
+
context "when machine is :paused, :saved or :poweroff" do
|
76
|
+
it "should prompt the user if they would like to force destroy the machine" do
|
77
|
+
state = double("state", id: :poweroff)
|
78
|
+
provisioner = double("provisioner")
|
79
|
+
subject.provisioner = provisioner
|
80
|
+
|
81
|
+
expect(ui).to receive(:say).with(:warn, "Machine is currently not running. To properly leave the #{domain} network the machine needs to be running and connected to the network in which it was provisioned. Please run `vagrant up` and then `vagrant destroy`.\n")
|
82
|
+
expect(ui).to receive(:ask).with("Would you like to continue destroying this machine, leaving this machine orphaned in the '#{domain}' network? (y/n)").and_return("y")
|
83
|
+
expect(ui).to receive(:say).with(:warn, "Force destroying this machine and not leaving the domain foo.com. May FSM have mercy on your soul.")
|
84
|
+
expect(machine).to receive(:state).and_return(state).twice
|
85
|
+
expect(app).to receive(:call).with(env)
|
86
|
+
# Can't call destroy on a non-running machine
|
87
|
+
expect(provisioner).to_not receive(:destroy)
|
88
|
+
|
89
|
+
subject.call(env)
|
90
|
+
|
91
|
+
expect(env[:force_confirm_destroy]).to be(true)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should not pass on to middleware if user declines force destroy" do
|
95
|
+
state = double("state", id: :poweroff)
|
96
|
+
provisioner = double("provisioner")
|
97
|
+
subject.provisioner = provisioner
|
98
|
+
|
99
|
+
expect(ui).to receive(:say).with(:warn, "Machine is currently not running. To properly leave the #{domain} network the machine needs to be running and connected to the network in which it was provisioned. Please run `vagrant up` and then `vagrant destroy`.\n")
|
100
|
+
expect(ui).to receive(:ask).with("Would you like to continue destroying this machine, leaving this machine orphaned in the '#{domain}' network? (y/n)").and_return("n")
|
101
|
+
expect(machine).to receive(:state).and_return(state).twice
|
102
|
+
expect(app).to_not receive(:call).with(env)
|
103
|
+
expect(provisioner).to_not receive(:destroy)
|
104
|
+
expect(env[:force_confirm_destroy]).to be(nil)
|
105
|
+
|
106
|
+
subject.call(env)
|
107
|
+
end
|
108
|
+
end
|
116
109
|
|
117
|
-
|
118
|
-
|
110
|
+
context "when machine is :not_created" do
|
111
|
+
it "should pass control to the next middleware action" do
|
112
|
+
state = double("state", id: :not_created)
|
113
|
+
expect(machine).to receive(:state).and_return(state)
|
119
114
|
|
120
|
-
|
121
|
-
|
115
|
+
expect(app).to receive(:call).with(env)
|
116
|
+
subject.call(env)
|
117
|
+
end
|
118
|
+
end
|
122
119
|
end
|
123
120
|
|
124
121
|
|
125
122
|
describe "initialize" do
|
126
123
|
|
127
|
-
its("env")
|
128
|
-
its("app")
|
129
|
-
its("config")
|
124
|
+
its("env") { should eq(env) }
|
125
|
+
its("app") { should eq(app) }
|
126
|
+
its("config") { should eq(config) }
|
130
127
|
its("machine") { should eq(machine) }
|
131
128
|
|
132
129
|
end
|
@@ -73,7 +73,7 @@ describe VagrantPlugins::WindowsDomain::Provisioner do
|
|
73
73
|
it "should join the domain" do
|
74
74
|
allow(communicator).to receive(:upload)
|
75
75
|
allow(ui).to receive(:info)
|
76
|
-
expect(
|
76
|
+
expect(communicator).to receive(:sudo).with("powershell -ExecutionPolicy Bypass -OutputFormat Text -file c:/tmp/vagrant-windows-domain-runner.ps1", {:elevated=>true, :error_check=>true, :error_key=>nil, :good_exit=>0, :shell=>:powershell})
|
77
77
|
expect(communicator).to receive(:sudo).with("del c:/tmp/vagrant-windows-domain-runner.ps1")
|
78
78
|
expect(machine).to receive(:action). with(:reload, {:provision_ignore_sentinel=>false})
|
79
79
|
expect(communicator).to receive(:ready?).and_return(true)
|
@@ -85,7 +85,7 @@ describe VagrantPlugins::WindowsDomain::Provisioner do
|
|
85
85
|
it "should restart the machine on a successful domain join" do
|
86
86
|
allow(communicator).to receive(:upload)
|
87
87
|
allow(ui).to receive(:info)
|
88
|
-
expect(
|
88
|
+
expect(communicator).to receive(:sudo).with("powershell -ExecutionPolicy Bypass -OutputFormat Text -file c:/tmp/vagrant-windows-domain-runner.ps1", {:elevated=>true, :error_check=>true, :error_key=>nil, :good_exit=>0, :shell=>:powershell})
|
89
89
|
expect(communicator).to receive(:sudo).with("del c:/tmp/vagrant-windows-domain-runner.ps1")
|
90
90
|
expect(machine).to receive(:action). with(:reload, {:provision_ignore_sentinel=>false})
|
91
91
|
expect(communicator).to receive(:ready?).and_return(true)
|
@@ -97,7 +97,7 @@ describe VagrantPlugins::WindowsDomain::Provisioner do
|
|
97
97
|
allow(communicator).to receive(:upload)
|
98
98
|
allow(ui).to receive(:info).with("some exception thrown!", {:color=>:red, :new_line=>false, :prefix=>false}) # Red output on error please!
|
99
99
|
allow(ui).to receive(:info).with("\"Running Windows Domain Provisioner\"")
|
100
|
-
expect(
|
100
|
+
expect(communicator).to receive(:sudo).with("powershell -ExecutionPolicy Bypass -OutputFormat Text -file c:/tmp/vagrant-windows-domain-runner.ps1", {:elevated=>true, :error_check=>true, :error_key=>nil, :good_exit=>0, :shell=>:powershell}).and_yield(:stderr, "some exception thrown!")
|
101
101
|
expect(communicator).to receive(:sudo).with("del c:/tmp/vagrant-windows-domain-runner.ps1")
|
102
102
|
expect(machine).to_not receive(:action). with(:reload, {:provision_ignore_sentinel=>false})
|
103
103
|
subject.restart_sleep_duration = 0
|
@@ -167,7 +167,7 @@ describe VagrantPlugins::WindowsDomain::Provisioner do
|
|
167
167
|
it "should leave domain" do
|
168
168
|
allow(machine).to receive(:communicate).and_return(communicator)
|
169
169
|
expect(communicator).to receive(:upload)
|
170
|
-
expect(
|
170
|
+
expect(communicator).to receive(:sudo).with("powershell -ExecutionPolicy Bypass -OutputFormat Text -file c:/tmp/vagrant-windows-domain-runner.ps1", {:elevated=>true, :error_check=>true, :error_key=>nil, :good_exit=>0, :shell=>:powershell}).and_yield(:stdout, "deleted")
|
171
171
|
expect(ui).to receive(:info).with("\"Running Windows Domain Provisioner\"")
|
172
172
|
expect(ui).to receive(:info).with("deleted", {:color=>:green, :new_line=>false, :prefix=>false})
|
173
173
|
|
@@ -177,13 +177,18 @@ describe VagrantPlugins::WindowsDomain::Provisioner do
|
|
177
177
|
|
178
178
|
it "should leave domain when a `vagrant destroy` is issued" do
|
179
179
|
allow(machine).to receive(:communicate).and_return(communicator)
|
180
|
+
|
180
181
|
expect(communicator).to receive(:upload)
|
181
|
-
expect(
|
182
|
+
expect(communicator).to receive(:sudo).with("powershell -ExecutionPolicy Bypass -OutputFormat Text -file c:/tmp/vagrant-windows-domain-runner.ps1", {:elevated=>true, :error_check=>true, :error_key=>nil, :good_exit=>0, :shell=>:powershell}).and_yield(:stdout, "deleted")
|
182
183
|
expect(ui).to receive(:info).with("\"Running Windows Domain Provisioner\"")
|
183
184
|
expect(ui).to receive(:info).with("deleted", {:color=>:green, :new_line=>false, :prefix=>false})
|
184
|
-
|
185
|
+
expect(ui).to receive(:say).with(:info, "Restarting computer for updates to take effect.")
|
186
|
+
expect(machine).to receive(:action). with(:reload, {:provision_ignore_sentinel=>false})
|
185
187
|
expect(ui).to_not receive(:say)
|
186
188
|
expect(ui).to_not receive(:ask)
|
189
|
+
expect(communicator).to receive(:ready?).and_return(true)
|
190
|
+
subject.restart_sleep_duration = 0
|
191
|
+
|
187
192
|
subject.destroy
|
188
193
|
end
|
189
194
|
|
@@ -201,11 +206,17 @@ describe VagrantPlugins::WindowsDomain::Provisioner do
|
|
201
206
|
root_config.password = nil
|
202
207
|
allow(machine).to receive(:communicate).and_return(communicator)
|
203
208
|
allow(machine).to receive(:env).and_return(env)
|
209
|
+
|
204
210
|
expect(communicator).to receive(:upload)
|
205
|
-
expect(
|
211
|
+
expect(communicator).to receive(:sudo).with("powershell -ExecutionPolicy Bypass -OutputFormat Text -file c:/tmp/vagrant-windows-domain-runner.ps1", {:elevated=>true, :error_check=>true, :error_key=>nil, :good_exit=>0, :shell=>:powershell}).and_yield(:stdout, "deleted")
|
206
212
|
expect(ui).to receive(:info).with(any_args).twice
|
207
213
|
expect(ui).to receive(:ask).with("Please enter your domain password (output will be hidden): ", {:echo=>false}).and_return("myusername")
|
208
|
-
expect(ui).to receive(:ask).with("Please enter your domain username: ")
|
214
|
+
expect(ui).to receive(:ask).with("Please enter your domain username: ")
|
215
|
+
expect(ui).to receive(:say).with(:info, "Restarting computer for updates to take effect.")
|
216
|
+
expect(machine).to receive(:action). with(:reload, {:provision_ignore_sentinel=>false})
|
217
|
+
expect(communicator).to receive(:ready?).and_return(true)
|
218
|
+
subject.restart_sleep_duration = 0
|
219
|
+
|
209
220
|
subject.destroy
|
210
221
|
end
|
211
222
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-windows-domain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Fellows
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -199,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
199
|
version: '0'
|
200
200
|
requirements: []
|
201
201
|
rubyforge_project:
|
202
|
-
rubygems_version: 2.
|
202
|
+
rubygems_version: 2.4.1
|
203
203
|
signing_key:
|
204
204
|
specification_version: 4
|
205
205
|
summary: Windows Domain Provisioner for Vagrant
|