vagrant-windows-domain 1.1.1 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/development/Vagrantfile +5 -1
- data/lib/vagrant-windows-domain/action/leave_domain.rb +23 -0
- data/lib/vagrant-windows-domain/plugin.rb +10 -0
- data/lib/vagrant-windows-domain/provisioner.rb +4 -3
- data/lib/vagrant-windows-domain/templates/runner.ps1.erb +1 -1
- data/lib/vagrant-windows-domain/version.rb +1 -1
- data/spec/provisioner/provisioner_spec.rb +7 -7
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce86949685fe8c228f0bf2ecb5b5284f6fd85eac
|
4
|
+
data.tar.gz: da22799eb1a74e416c9c32178fca198256c5757b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05d2351ac7ae90cc26c49106ee8a0374d29cf8bd8341b5fb2fabdfaa59d6ebd408d93b0439bd839a58563a5694c4bec8a87a737aebe735c828011184069dea1a
|
7
|
+
data.tar.gz: 7b7299f283728ca184295b3c1c80532db8a309fff96c6a7867c32869bab22b8631814f7230ed52676a5a54cf97b220b44f9e5ad08b87292382bf967fef25bd02
|
data/development/Vagrantfile
CHANGED
@@ -10,11 +10,15 @@ VAGRANTFILE_API_VERSION = "2"
|
|
10
10
|
|
11
11
|
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
12
12
|
|
13
|
-
config.vm.box = "windows2012r2"
|
13
|
+
config.vm.box = "mfellows/windows2012r2"
|
14
14
|
config.vm.guest = :windows
|
15
15
|
config.vm.communicator = "winrm"
|
16
16
|
config.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true
|
17
17
|
|
18
|
+
config.vm.provider "virtualbox" do |v|
|
19
|
+
v.gui = true
|
20
|
+
end
|
21
|
+
|
18
22
|
# Run Windows Domain Provisioner
|
19
23
|
config.vm.provision :windows_domain do |domain|
|
20
24
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative '../provisioner'
|
2
|
+
require 'pp'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module WindowsDomain
|
6
|
+
class LeaveDomain
|
7
|
+
include VagrantPlugins::WindowsDomain
|
8
|
+
|
9
|
+
def initialize(app, env)
|
10
|
+
@app = app
|
11
|
+
@machine = env[:machine]
|
12
|
+
@config = env[:machine].config.windows_domain
|
13
|
+
@provisioner = VagrantPlugins::WindowsDomain::Provisioner.new(@machine, @config)
|
14
|
+
end
|
15
|
+
|
16
|
+
def call(env)
|
17
|
+
@provisioner.destroy
|
18
|
+
@app.call(env)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -13,11 +13,21 @@ module VagrantPlugins
|
|
13
13
|
require_relative 'config'
|
14
14
|
Config
|
15
15
|
end
|
16
|
+
|
17
|
+
config(:windows_domain) do
|
18
|
+
require_relative 'config'
|
19
|
+
Config
|
20
|
+
end
|
16
21
|
|
17
22
|
provisioner(:windows_domain) do
|
18
23
|
require_relative 'provisioner'
|
19
24
|
Provisioner
|
20
25
|
end
|
26
|
+
|
27
|
+
action_hook(:windows_domain, :machine_action_destroy) do |hook|
|
28
|
+
require_relative 'action/leave_domain'
|
29
|
+
hook.prepend(VagrantPlugins::WindowsDomain::LeaveDomain)
|
30
|
+
end
|
21
31
|
end
|
22
32
|
end
|
23
33
|
end
|
@@ -102,7 +102,7 @@ module VagrantPlugins
|
|
102
102
|
# This is the method called when destroying a machine that allows
|
103
103
|
# for any state related to the machine created by the provisioner
|
104
104
|
# to be cleaned up.
|
105
|
-
def
|
105
|
+
def destroy
|
106
106
|
set_credentials
|
107
107
|
leave_domain
|
108
108
|
end
|
@@ -155,9 +155,9 @@ module VagrantPlugins
|
|
155
155
|
|
156
156
|
# Generates the argument list
|
157
157
|
def generate_command_arguments(add_to_domain=true)
|
158
|
-
params = {"-DomainName" => @config.domain }
|
159
158
|
|
160
159
|
if add_to_domain
|
160
|
+
params = {"-DomainName" => @config.domain }
|
161
161
|
|
162
162
|
if @config.unsecure
|
163
163
|
params["-Unsecure"] = nil
|
@@ -173,6 +173,7 @@ module VagrantPlugins
|
|
173
173
|
params["-OUPath"] = "'#{@config.ou_path}'"
|
174
174
|
end
|
175
175
|
else
|
176
|
+
params = {}
|
176
177
|
if !@config.unsecure
|
177
178
|
params["-UnjoinDomainCredential $credentials"] = nil
|
178
179
|
end
|
@@ -237,7 +238,7 @@ module VagrantPlugins
|
|
237
238
|
end
|
238
239
|
end
|
239
240
|
|
240
|
-
result
|
241
|
+
result == 0
|
241
242
|
end
|
242
243
|
|
243
244
|
# Gets the Computer Name from the guest machine
|
@@ -5,5 +5,5 @@ $credentials = New-Object System.Management.Automation.PSCredential ("<%= option
|
|
5
5
|
<% if options[:add_to_domain] === true %>
|
6
6
|
Add-Computer <%= options[:parameters] %> -Verbose -Force
|
7
7
|
<% else %>
|
8
|
-
Remove-Computer <%= options[:parameters] %> -Verbose -Force
|
8
|
+
Remove-Computer <%= options[:parameters] %> -Workgroup "WORKGROUP" -Verbose -Force
|
9
9
|
<% 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(communicator).to receive(:sudo).with(". 'c:/tmp/vagrant-windows-domain-runner.ps1'", {:elevated=>true, :error_key=>:ssh_bad_exit_status_muted, :good_exit=>0, :shell=>:powershell}).and_return(
|
76
|
+
expect(communicator).to receive(:sudo).with(". 'c:/tmp/vagrant-windows-domain-runner.ps1'", {:elevated=>true, :error_key=>:ssh_bad_exit_status_muted, :good_exit=>0, :shell=>:powershell}).and_return(0)
|
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(communicator).to receive(:sudo).with(". 'c:/tmp/vagrant-windows-domain-runner.ps1'", {:elevated=>true, :error_key=>:ssh_bad_exit_status_muted, :good_exit=>0, :shell=>:powershell}).and_return(
|
88
|
+
expect(communicator).to receive(:sudo).with(". 'c:/tmp/vagrant-windows-domain-runner.ps1'", {:elevated=>true, :error_key=>:ssh_bad_exit_status_muted, :good_exit=>0, :shell=>:powershell}).and_return(0)
|
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)
|
@@ -156,7 +156,7 @@ describe VagrantPlugins::WindowsDomain::Provisioner do
|
|
156
156
|
it "should leave domain" do
|
157
157
|
allow(machine).to receive(:communicate).and_return(communicator)
|
158
158
|
expect(communicator).to receive(:upload)
|
159
|
-
expect(communicator).to receive(:sudo).with(". 'c:/tmp/vagrant-windows-domain-runner.ps1'", {:elevated=>true, :error_key=>:ssh_bad_exit_status_muted, :good_exit=>0, :shell=>:powershell}).and_return(
|
159
|
+
expect(communicator).to receive(:sudo).with(". 'c:/tmp/vagrant-windows-domain-runner.ps1'", {:elevated=>true, :error_key=>:ssh_bad_exit_status_muted, :good_exit=>0, :shell=>:powershell}).and_return(0)
|
160
160
|
expect(ui).to receive(:info).with(any_args).once
|
161
161
|
|
162
162
|
result = subject.leave_domain
|
@@ -169,7 +169,7 @@ describe VagrantPlugins::WindowsDomain::Provisioner do
|
|
169
169
|
expect(communicator).to receive(:sudo).with(". 'c:/tmp/vagrant-windows-domain-runner.ps1'", {:elevated=>true, :error_key=>:ssh_bad_exit_status_muted, :good_exit=>0, :shell=>:powershell})
|
170
170
|
expect(ui).to receive(:info).with(any_args).once
|
171
171
|
|
172
|
-
subject.
|
172
|
+
subject.destroy
|
173
173
|
end
|
174
174
|
|
175
175
|
it "should ask for credentials when leaving domain when no credentials were provided" do
|
@@ -183,7 +183,7 @@ describe VagrantPlugins::WindowsDomain::Provisioner do
|
|
183
183
|
expect(ui).to receive(:ask).with("Please enter your domain password (output will be hidden): ", {:echo=>false}).and_return("myusername")
|
184
184
|
expect(ui).to receive(:ask).with("Please enter your domain username: ")
|
185
185
|
|
186
|
-
subject.
|
186
|
+
subject.destroy
|
187
187
|
end
|
188
188
|
|
189
189
|
end
|
@@ -222,7 +222,7 @@ Add-Computer -DomainName foo.com -Credential $credentials -Verbose -Force
|
|
222
222
|
expect_script =
|
223
223
|
%Q{$secpasswd = ConvertTo-SecureString "password" -AsPlainText -Force
|
224
224
|
$credentials = New-Object System.Management.Automation.PSCredential ("username", $secpasswd)
|
225
|
-
Remove-Computer -
|
225
|
+
Remove-Computer -UnjoinDomainCredential $credentials -Workgroup "WORKGROUP" -Verbose -Force
|
226
226
|
}
|
227
227
|
expect(script).to eq(expect_script)
|
228
228
|
end
|
@@ -259,7 +259,7 @@ Add-Computer -DomainName foo.com -Credential $credentials -NewName 'mynewcompute
|
|
259
259
|
|
260
260
|
it "should generate a valid powershell command to remove the computer from a domain" do
|
261
261
|
script = subject.generate_command_runner_script(false).strip
|
262
|
-
expect_script = "Remove-Computer
|
262
|
+
expect_script = "Remove-Computer -Workgroup \"WORKGROUP\" -Verbose -Force"
|
263
263
|
expect(script).to eq(expect_script)
|
264
264
|
end
|
265
265
|
end
|
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.3
|
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-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -166,6 +166,7 @@ files:
|
|
166
166
|
- Rakefile
|
167
167
|
- development/Vagrantfile
|
168
168
|
- lib/vagrant-windows-domain.rb
|
169
|
+
- lib/vagrant-windows-domain/action/leave_domain.rb
|
169
170
|
- lib/vagrant-windows-domain/config.rb
|
170
171
|
- lib/vagrant-windows-domain/locales/en.yml
|
171
172
|
- lib/vagrant-windows-domain/plugin.rb
|