vagrant-windows 0.1.2 → 1.0.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.
- checksums.yaml +7 -0
- data/Gemfile.lock +6 -26
- data/README.md +92 -44
- data/lib/vagrant-windows/communication/winrmcommunicator.rb +213 -0
- data/lib/vagrant-windows/config/windows.rb +20 -16
- data/lib/vagrant-windows/config/winrm.rb +35 -15
- data/lib/vagrant-windows/errors.rb +17 -12
- data/lib/vagrant-windows/guest/windows.rb +45 -40
- data/lib/vagrant-windows/monkey_patches/chef_solo.rb +61 -0
- data/lib/vagrant-windows/monkey_patches/machine.rb +25 -0
- data/lib/vagrant-windows/monkey_patches/puppet.rb +100 -0
- data/lib/vagrant-windows/plugin.rb +96 -0
- data/lib/vagrant-windows/scripts/command_alias.ps1 +13 -4
- data/lib/vagrant-windows/scripts/ps_runas.ps1.erb +56 -0
- data/lib/vagrant-windows/version.rb +1 -1
- data/lib/vagrant-windows.rb +33 -0
- data/locales/en.yml +29 -0
- data/vagrant-windows.gemspec +0 -1
- metadata +17 -36
- data/lib/vagrant-windows/communication/winrm.rb +0 -185
- data/lib/vagrant-windows/monkey_patches/driver.rb +0 -57
- data/lib/vagrant-windows/monkey_patches/vm.rb +0 -16
- data/lib/vagrant-windows/winrm.rb +0 -82
- data/lib/vagrant_init.rb +0 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6373e5fcaeafb284ed319640b162f38d2c1fbb42
|
4
|
+
data.tar.gz: f292ab1b6c18eb837fd7b5d8f9b2bc34dfda6aad
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e86f29b4b5661bd43041cda843cf062735b3f66ca80a20a0c097724572a3124a4131bb809201bc8e77767e845c2a998350be3af2028108eb40c6e781dd6d0c96
|
7
|
+
data.tar.gz: 770f88ccf1d8bc53f22921a56dc1a27c5176b93c6bc8e4eab9336ab21d19706558a1c1f02ac3136302110313518d8275c207074db8ad5b2b76ade076edeca977
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
vagrant-windows (0.
|
4
|
+
vagrant-windows (0.2.0)
|
5
5
|
highline
|
6
|
-
vagrant (~> 1.0.3)
|
7
6
|
winrm (~> 1.1.1)
|
8
7
|
|
9
8
|
GEM
|
@@ -12,32 +11,22 @@ GEM
|
|
12
11
|
akami (1.2.0)
|
13
12
|
gyoku (>= 0.4.0)
|
14
13
|
nokogiri (>= 1.4.0)
|
15
|
-
|
16
|
-
|
17
|
-
childprocess (0.3.5)
|
18
|
-
ffi (~> 1.0, >= 1.0.6)
|
19
|
-
erubis (2.7.0)
|
20
|
-
ffi (1.1.5)
|
14
|
+
builder (3.0.4)
|
15
|
+
ffi (1.4.0)
|
21
16
|
gssapi (1.0.3)
|
22
17
|
ffi (>= 1.0.1)
|
23
18
|
gyoku (0.4.6)
|
24
19
|
builder (>= 2.1.2)
|
25
|
-
highline (1.6.
|
20
|
+
highline (1.6.15)
|
26
21
|
httpclient (2.2.0.2)
|
27
22
|
httpi (0.9.7)
|
28
23
|
rack
|
29
|
-
i18n (0.6.1)
|
30
|
-
json (1.5.4)
|
31
24
|
little-plugger (1.1.3)
|
32
|
-
log4r (1.1.10)
|
33
25
|
logging (1.6.2)
|
34
26
|
little-plugger (>= 1.1.3)
|
35
|
-
|
36
|
-
net-ssh (>= 1.99.1)
|
37
|
-
net-ssh (2.2.2)
|
38
|
-
nokogiri (1.5.5)
|
27
|
+
nokogiri (1.5.6)
|
39
28
|
nori (1.1.3)
|
40
|
-
rack (1.
|
29
|
+
rack (1.5.2)
|
41
30
|
rubyntlm (0.1.1)
|
42
31
|
savon (0.9.5)
|
43
32
|
akami (~> 1.0)
|
@@ -48,15 +37,6 @@ GEM
|
|
48
37
|
nori (~> 1.0)
|
49
38
|
wasabi (~> 1.0)
|
50
39
|
uuidtools (2.1.3)
|
51
|
-
vagrant (1.0.3)
|
52
|
-
archive-tar-minitar (= 0.5.2)
|
53
|
-
childprocess (~> 0.3.1)
|
54
|
-
erubis (~> 2.7.0)
|
55
|
-
i18n (~> 0.6.0)
|
56
|
-
json (~> 1.5.1)
|
57
|
-
log4r (~> 1.1.9)
|
58
|
-
net-scp (~> 1.0.4)
|
59
|
-
net-ssh (~> 2.2.2)
|
60
40
|
wasabi (1.0.0)
|
61
41
|
nokogiri (>= 1.4.0)
|
62
42
|
winrm (1.1.2)
|
data/README.md
CHANGED
@@ -1,35 +1,33 @@
|
|
1
|
-
|
2
|
-
Installing
|
3
|
-
==========
|
4
1
|
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
Installing Vagrant-Windows
|
3
|
+
==========================
|
4
|
+
|
5
|
+
- Vagrant 1.0 should use <code>gem "vagrant-windows", "~> 0.1.2"</code>
|
6
|
+
- Vagrant 1.1 should use <code>gem "vagrant-windows", "~> 1.0.0"</code>
|
7
|
+
- Vagrant 1.2 is not yet supported. There needs to be a refactor to support capabilities. We are looking for a backwards compatiable way to implement this.
|
8
|
+
|
8
9
|
|
9
10
|
Building a Base Box
|
10
11
|
===================
|
11
12
|
|
12
13
|
All Windows Machines
|
13
14
|
--------------------
|
14
|
-
|
15
|
-
|
16
|
-
```
|
15
|
+
-Enable WinRM
|
16
|
+
```
|
17
17
|
winrm quickconfig -q
|
18
18
|
winrm set winrm/config/winrs @{MaxMemoryPerShellMB="512"}
|
19
19
|
winrm set winrm/config @{MaxTimeoutms="1800000"}
|
20
20
|
winrm set winrm/config/service @{AllowUnencrypted="true"}
|
21
21
|
winrm set winrm/config/service/auth @{Basic="true"}
|
22
|
-
|
23
|
-
- Create a vagrant user
|
24
|
-
- For things to work out of the box, username and password should both be vagrant
|
25
|
-
|
22
|
+
```
|
23
|
+
- Create a vagrant user, for things to work out of the box username and password should both be "vagrant".
|
26
24
|
- Turn off UAC (Msconfig)
|
27
25
|
- Disable complex passwords
|
28
26
|
|
29
27
|
Servers
|
30
28
|
--------
|
31
|
-
- Disable Shutdown Tracker
|
32
|
-
- Disable "Server Manager" Starting at login
|
29
|
+
- [Disable Shutdown Tracker](http://www.jppinto.com/2010/01/how-to-disable-the-shutdown-event-tracker-in-server-20032008/)
|
30
|
+
- [Disable "Server Manager" Starting at login](http://www.elmajdal.net/win2k8/How_to_Turn_Off_The_Automatic_Display_of_Server_Manager_At_logon.aspx)
|
33
31
|
|
34
32
|
The Vagrant File
|
35
33
|
================
|
@@ -37,51 +35,95 @@ The Vagrant File
|
|
37
35
|
Add the following to your Vagrantfile
|
38
36
|
|
39
37
|
```ruby
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
38
|
+
config.vm.guest = :windows
|
39
|
+
config.windows.halt_timeout = 15
|
40
|
+
config.winrm.username = "vagrant"
|
41
|
+
config.winrm.password = "vagrant"
|
42
|
+
config.vm.network :forwarded_port, guest: 3389, host: 3389
|
43
|
+
config.vm.network :forwarded_port, guest: 5985, host: 5985
|
44
44
|
```
|
45
45
|
|
46
46
|
Example:
|
47
47
|
```ruby
|
48
|
-
Vagrant
|
49
|
-
|
50
|
-
#
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
Vagrant.configure("2") do |config|
|
49
|
+
|
50
|
+
# Max time to wait for the guest to shutdown
|
51
|
+
config.windows.halt_timeout = 15
|
52
|
+
|
53
|
+
# Admin user name and password
|
54
|
+
config.winrm.username = "vagrant"
|
55
|
+
config.winrm.password = "vagrant"
|
54
56
|
|
55
57
|
# Configure base box parameters
|
56
|
-
config.vm.box = "windows2008r2"
|
57
|
-
config.vm.box_url = "./
|
58
|
+
config.vm.box = "vagrant-windows2008r2"
|
59
|
+
config.vm.box_url = "./vagrant-windows2008r2.box"
|
58
60
|
config.vm.guest = :windows
|
59
61
|
|
60
|
-
|
61
|
-
config.vm.
|
62
|
-
|
63
|
-
|
64
|
-
chef.add_recipe("your::recipe")
|
65
|
-
end
|
66
|
-
|
62
|
+
# Port forward WinRM and RDP
|
63
|
+
config.vm.network :forwarded_port, guest: 3389, host: 3389
|
64
|
+
config.vm.network :forwarded_port, guest: 5985, host: 5985
|
65
|
+
|
67
66
|
end
|
68
67
|
````
|
69
68
|
|
69
|
+
Available Config Parameters:
|
70
|
+
|
71
|
+
* ```config.windows.halt_timeout``` - How long Vagrant should wait for the guest to shutdown before forcing exit, defaults to 30 seconds
|
72
|
+
* ```config.windows.halt_check_interval``` - How often Vagrant should check if the system has shutdown, defaults to 1 second
|
73
|
+
* ```config.winrm.username``` - The Windows guest admin user name, defaults to vagrant.
|
74
|
+
* ```config.winrm.password``` - The above's password, defaults to vagrant.
|
75
|
+
* ```config.winrm.host``` - The IP of the guest, but because we use NAT with port forwarding this defaults to localhost.
|
76
|
+
* ```config.winrm.guest_port``` - The guest's WinRM port, defaults to 5985.
|
77
|
+
* ```config.winrm.port``` - The WinRM port on the host, defaults to 5985. You might need to change this if your hosts is also Windows.
|
78
|
+
* ```config.winrm.max_tries``` - The number of retries to connect to WinRM, defaults to 12.
|
79
|
+
* ```config.winrm.timeout``` - The max number of seconds to wait for a WinRM response, defaults to 1800 seconds.
|
80
|
+
|
81
|
+
Note - You need to ensure you specify a config.windows and a config.winrm in your Vagrantfile. Currently there's a problem where
|
82
|
+
Vagrant will not load the plugin config even with defaults if at least one of its values doesn't exist in the Vagrantfile.
|
83
|
+
|
84
|
+
|
70
85
|
What Works?
|
71
86
|
===========
|
72
|
-
- vagrant up|
|
87
|
+
- vagrant up|halt|reload|provision
|
73
88
|
- Chef Vagrant Provisioner
|
89
|
+
- Puppet Vagrant Provisioner
|
74
90
|
|
75
91
|
What has not been tested
|
76
92
|
========================
|
77
|
-
-
|
78
|
-
- Shell and Puppet Provisioners
|
79
|
-
- Shell should work, though I have not vetted it yet.
|
93
|
+
- Shell provisioning. Shell should work, though I have not vetted it yet.
|
80
94
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
95
|
+
TODOs
|
96
|
+
=========
|
97
|
+
1. Test it! We need to test on more hosts, guests, and VBox versions. Help wanted.
|
98
|
+
2. Vagrant 1.2 support. Unfortunately it appears there are some breaking changes with guests between Vagrant 1.1. and 1.2.
|
99
|
+
3. Chef-Client support.
|
100
|
+
3. Unit tests.
|
101
|
+
4. Better docs.
|
102
|
+
|
103
|
+
Troubleshooting
|
104
|
+
===============
|
105
|
+
|
106
|
+
I get a 401 auth error from WinRM
|
107
|
+
---------------------------------
|
108
|
+
- Ensure you've followed the WinRM configuration instructions above.
|
109
|
+
- Ensure you can manually login using the specified config.winrm.username you've specified in your Vagrantfile.
|
110
|
+
- Ensure your password hasn't expired.
|
111
|
+
- Ensure your password doesn't need to be changed because of policy.
|
112
|
+
|
113
|
+
I get a non-401 error from WinRM waiting for the VM to boot
|
114
|
+
-----------------------------------------------------------
|
115
|
+
- Ensure you've properly setup port forwarding of WinRM
|
116
|
+
- Make sure your VM can boot manually through VBox.
|
117
|
+
|
118
|
+
SQL Server cookbook fails to install through Vagrant
|
119
|
+
----------------------------------------------------
|
120
|
+
- Ensure UAC is turned off
|
121
|
+
- Ensure your vagrant user is an admin on the guest
|
122
|
+
- The SQL Server installer uses a lot of resources, ensure WinRM Quota Management is properly configured to give it enough resources.
|
123
|
+
- See [COOK-1172](http://tickets.opscode.com/browse/COOK-1172) and http://stackoverflow.com/a/15235996/82906 for more information.
|
124
|
+
|
125
|
+
If all else fails try running [vagrant with debug logging](http://docs.vagrantup.com/v2/debugging.html), perhaps that will give
|
126
|
+
you enough insight to fix the problem or file an issue.
|
85
127
|
|
86
128
|
What Can I do to help?
|
87
129
|
======================
|
@@ -100,10 +142,16 @@ Contributing
|
|
100
142
|
References and Shout Outs
|
101
143
|
=========================
|
102
144
|
- Chris McClimans - Vagrant Branch (https://github.com/hh/vagrant/blob/feature/winrm/)
|
103
|
-
-Dan Wanek - WinRM GEM (https://github.com/zenchild/WinRM)
|
145
|
+
- Dan Wanek - WinRM GEM (https://github.com/zenchild/WinRM)
|
104
146
|
- +1 For being super responsive to pull requests.
|
105
147
|
|
106
148
|
|
107
149
|
Changelog
|
108
150
|
=========
|
109
|
-
0.1.1 - Remove extra debug information from command output.
|
151
|
+
0.1.1 - Remove extra debug information from command output.
|
152
|
+
|
153
|
+
0.1.2 - Added virtual box 4.2 support.
|
154
|
+
|
155
|
+
0.1.3 - Added puppet provisioner.
|
156
|
+
|
157
|
+
1.0.0 - Converted to Vagrant 1.1.x plugin architecture.
|
@@ -0,0 +1,213 @@
|
|
1
|
+
require 'timeout'
|
2
|
+
require 'winrm'
|
3
|
+
require 'log4r'
|
4
|
+
require 'vagrant/util/ansi_escape_code_remover'
|
5
|
+
require 'vagrant/util/file_mode'
|
6
|
+
require 'vagrant/util/platform'
|
7
|
+
require 'vagrant/util/retryable'
|
8
|
+
|
9
|
+
module VagrantWindows
|
10
|
+
module Communication
|
11
|
+
# Provides communication with the VM via WinRM.
|
12
|
+
class WinRMCommunicator < Vagrant.plugin("2", :communicator)
|
13
|
+
|
14
|
+
include Vagrant::Util::ANSIEscapeCodeRemover
|
15
|
+
include Vagrant::Util::Retryable
|
16
|
+
|
17
|
+
attr_reader :logger
|
18
|
+
attr_reader :machine
|
19
|
+
|
20
|
+
def self.match?(machine)
|
21
|
+
machine.config.vm.guest.eql? :windows
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(machine)
|
25
|
+
@machine = machine
|
26
|
+
@logger = Log4r::Logger.new("vagrant_windows::communication::winrmcommunicator")
|
27
|
+
@logger.debug("initializing WinRMCommunicator")
|
28
|
+
end
|
29
|
+
|
30
|
+
def ready?
|
31
|
+
logger.debug("Checking whether WinRM is ready...")
|
32
|
+
|
33
|
+
Timeout.timeout(@machine.config.winrm.timeout) do
|
34
|
+
execute("hostname") do |type, data|
|
35
|
+
@logger.debug("hostname: #{data}")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# If we reached this point then we successfully connected
|
40
|
+
logger.debug("WinRM is ready!")
|
41
|
+
true
|
42
|
+
end
|
43
|
+
|
44
|
+
def execute(command, opts=nil, &block)
|
45
|
+
opts = {
|
46
|
+
:error_check => true,
|
47
|
+
:error_class => Errors::WinRMExecutionError,
|
48
|
+
:error_key => :winrm_bad_exit_status,
|
49
|
+
:command => command,
|
50
|
+
:sudo => false,
|
51
|
+
:shell => :powershell
|
52
|
+
}.merge(opts || {})
|
53
|
+
|
54
|
+
command = VagrantWindows.load_script("command_alias.ps1") << "\r\n" << command
|
55
|
+
exit_status = 0
|
56
|
+
|
57
|
+
begin
|
58
|
+
# Connect via WinRM and execute the command in the shell.
|
59
|
+
exceptions = [HTTPClient::KeepAliveDisconnected]
|
60
|
+
exit_status = retryable(:tries => @machine.config.winrm.max_tries, :on => exceptions, :sleep => 10) do
|
61
|
+
shell_execute(command, opts[:shell], &block)
|
62
|
+
end
|
63
|
+
rescue StandardError => e
|
64
|
+
# return a more specific auth error for 401 errors
|
65
|
+
if e.message.include?("401")
|
66
|
+
raise Errors::WinRMAuthorizationError,
|
67
|
+
:user => @machine.config.winrm.username,
|
68
|
+
:password => @machine.config.winrm.password,
|
69
|
+
:endpoint => endpoint,
|
70
|
+
:message => e.message
|
71
|
+
end
|
72
|
+
# failed for an unknown reason, didn't even get an exit status
|
73
|
+
raise Errors::WinRMExecutionError,
|
74
|
+
:shell => opts[:shell],
|
75
|
+
:command => command,
|
76
|
+
:message => e.message
|
77
|
+
end
|
78
|
+
|
79
|
+
# Check for any exit status errors
|
80
|
+
if opts[:error_check] && exit_status != 0
|
81
|
+
error_opts = opts.merge(:_key => opts[:error_key], :exit_status => exit_status)
|
82
|
+
raise error_opts[:error_class], error_opts
|
83
|
+
end
|
84
|
+
|
85
|
+
exit_status
|
86
|
+
end
|
87
|
+
|
88
|
+
# Wrap Sudo in execute.... One day we could integrate with UAC, but Icky
|
89
|
+
def sudo(command, opts=nil, &block)
|
90
|
+
execute(command, opts, &block)
|
91
|
+
end
|
92
|
+
|
93
|
+
def download(from, to=nil)
|
94
|
+
@logger.warn("Downloading: #{from} to #{to} not supported on Windows guests")
|
95
|
+
end
|
96
|
+
|
97
|
+
def test(command, opts=nil)
|
98
|
+
opts = { :error_check => false }.merge(opts || {})
|
99
|
+
execute(command, opts) == 0
|
100
|
+
end
|
101
|
+
|
102
|
+
def upload(from, to)
|
103
|
+
@logger.debug("Uploading: #{from} to #{to}")
|
104
|
+
|
105
|
+
file = "winrm-upload-#{rand()}"
|
106
|
+
file_name = (session.cmd("echo %TEMP%\\#{file}"))[:data][0][:stdout].chomp
|
107
|
+
session.powershell <<-EOH
|
108
|
+
if(Test-Path #{to})
|
109
|
+
{
|
110
|
+
rm #{to}
|
111
|
+
}
|
112
|
+
EOH
|
113
|
+
Base64.encode64(IO.binread(from)).gsub("\n",'').chars.to_a.each_slice(8000-file_name.size) do |chunk|
|
114
|
+
out = session.cmd( "echo #{chunk.join} >> \"#{file_name}\"" )
|
115
|
+
end
|
116
|
+
execute "mkdir [System.IO.Path]::GetDirectoryName(\"#{to}\")"
|
117
|
+
execute <<-EOH
|
118
|
+
$base64_string = Get-Content \"#{file_name}\"
|
119
|
+
$bytes = [System.Convert]::FromBase64String($base64_string)
|
120
|
+
$new_file = [System.IO.Path]::GetFullPath(\"#{to}\")
|
121
|
+
[System.IO.File]::WriteAllBytes($new_file,$bytes)
|
122
|
+
EOH
|
123
|
+
end
|
124
|
+
|
125
|
+
def new_session
|
126
|
+
opts = endpoint_options()
|
127
|
+
logger.debug("Creating WinRM session to #{endpoint} with options: #{opts}")
|
128
|
+
|
129
|
+
client = ::WinRM::WinRMWebService.new(endpoint, :plaintext, opts)
|
130
|
+
client.set_timeout(opts[:operation_timeout])
|
131
|
+
client.toggle_nori_type_casting(:off) #we don't want coersion of types
|
132
|
+
client
|
133
|
+
end
|
134
|
+
|
135
|
+
def session
|
136
|
+
@session ||= new_session
|
137
|
+
end
|
138
|
+
|
139
|
+
protected
|
140
|
+
|
141
|
+
def endpoint_options
|
142
|
+
{
|
143
|
+
:user => @machine.config.winrm.username,
|
144
|
+
:pass => @machine.config.winrm.password,
|
145
|
+
:host => @machine.config.winrm.host,
|
146
|
+
:port => winrm_port(),
|
147
|
+
:operation_timeout => @machine.config.winrm.timeout,
|
148
|
+
:basic_auth_only => true
|
149
|
+
}.merge ({})
|
150
|
+
end
|
151
|
+
|
152
|
+
def winrm_port
|
153
|
+
@winrm_port ||= find_winrm_host_port()
|
154
|
+
end
|
155
|
+
|
156
|
+
def find_winrm_host_port
|
157
|
+
expected_guest_port = @machine.config.winrm.guest_port
|
158
|
+
@logger.debug("Searching for WinRM port: #{expected_guest_port.inspect}")
|
159
|
+
|
160
|
+
# Look for the forwarded port only by comparing the guest port
|
161
|
+
@machine.provider.driver.read_forwarded_ports.each do |_, _, hostport, guestport|
|
162
|
+
return hostport if guestport == expected_guest_port
|
163
|
+
end
|
164
|
+
|
165
|
+
@machine.config.winrm.port
|
166
|
+
end
|
167
|
+
|
168
|
+
def endpoint
|
169
|
+
if !@winrm_endpoint
|
170
|
+
opts = endpoint_options()
|
171
|
+
@winrm_endpoint = "http://#{opts[:host]}:#{opts[:port]}/wsman"
|
172
|
+
end
|
173
|
+
@winrm_endpoint
|
174
|
+
end
|
175
|
+
|
176
|
+
# Executes the command on an SSH connection within a login shell.
|
177
|
+
def shell_execute(command, shell=:powershell, &block)
|
178
|
+
@logger.debug("#{shell} executing:\n#{command}")
|
179
|
+
|
180
|
+
if shell.eql? :cmd
|
181
|
+
output = session.cmd(command) do |out, err|
|
182
|
+
handle_out(:stdout, out, &block)
|
183
|
+
handle_out(:stderr, err, &block)
|
184
|
+
end
|
185
|
+
elsif shell.eql? :powershell
|
186
|
+
output = session.powershell(command) do |out, err|
|
187
|
+
handle_out(:stdout, out, &block)
|
188
|
+
handle_out(:stderr, err, &block)
|
189
|
+
end
|
190
|
+
else
|
191
|
+
raise Errors::WinRMInvalidShell, :shell => shell
|
192
|
+
end
|
193
|
+
|
194
|
+
exit_status = output[:exitcode]
|
195
|
+
@logger.debug("Exit status: #{exit_status.inspect}")
|
196
|
+
|
197
|
+
# Return the final exit status
|
198
|
+
return exit_status
|
199
|
+
end
|
200
|
+
|
201
|
+
def handle_out(type, data, &block)
|
202
|
+
if block_given? && data
|
203
|
+
if data =~ /\n/
|
204
|
+
data.split(/\n/).each { |d| block.call(type, d) }
|
205
|
+
else
|
206
|
+
block.call(type, data)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
end #WinRM class
|
212
|
+
end
|
213
|
+
end
|
@@ -1,27 +1,31 @@
|
|
1
|
-
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantWindows
|
2
4
|
module Config
|
3
|
-
class Windows < Vagrant
|
4
|
-
|
5
|
-
attr_accessor :winrm_password
|
5
|
+
class Windows < Vagrant.plugin("2", :config)
|
6
|
+
|
6
7
|
attr_accessor :halt_timeout
|
7
8
|
attr_accessor :halt_check_interval
|
8
|
-
attr_accessor :device
|
9
9
|
|
10
10
|
def initialize
|
11
|
-
@
|
12
|
-
@
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
@halt_timeout = UNSET_VALUE
|
12
|
+
@halt_check_interval = UNSET_VALUE
|
13
|
+
end
|
14
|
+
|
15
|
+
def validate(machine)
|
16
|
+
errors = []
|
17
|
+
|
18
|
+
errors << "windows.halt_timeout cannot be nil." if machine.config.windows.halt_timeout.nil?
|
19
|
+
errors << "windows.halt_check_interval cannot be nil." if machine.config.windows.halt_check_interval.nil?
|
20
|
+
|
21
|
+
{ "Windows Guest" => errors }
|
16
22
|
end
|
17
23
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
end
|
24
|
+
def finalize!
|
25
|
+
@halt_timeout = 30 if @halt_timeout == UNSET_VALUE
|
26
|
+
@halt_check_interval = 1 if @halt_check_interval == UNSET_VALUE
|
22
27
|
end
|
28
|
+
|
23
29
|
end
|
24
30
|
end
|
25
31
|
end
|
26
|
-
|
27
|
-
Vagrant.config_keys.register(:windows) { Vagrant::Config::Windows }
|
@@ -1,6 +1,9 @@
|
|
1
|
-
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantWindows
|
2
4
|
module Config
|
3
|
-
class WinRM < Vagrant
|
5
|
+
class WinRM < Vagrant.plugin("2", :config)
|
6
|
+
|
4
7
|
attr_accessor :username
|
5
8
|
attr_accessor :password
|
6
9
|
attr_accessor :host
|
@@ -8,24 +11,41 @@ module Vagrant
|
|
8
11
|
attr_accessor :guest_port
|
9
12
|
attr_accessor :max_tries
|
10
13
|
attr_accessor :timeout
|
11
|
-
|
14
|
+
|
12
15
|
def initialize
|
13
|
-
@username
|
14
|
-
@password
|
15
|
-
@
|
16
|
-
@
|
17
|
-
@
|
18
|
-
@
|
16
|
+
@username = UNSET_VALUE
|
17
|
+
@password = UNSET_VALUE
|
18
|
+
@host = UNSET_VALUE
|
19
|
+
@port = UNSET_VALUE
|
20
|
+
@guest_port = UNSET_VALUE
|
21
|
+
@max_tries = UNSET_VALUE
|
22
|
+
@timeout = UNSET_VALUE
|
19
23
|
end
|
20
24
|
|
21
|
-
def validate(
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
+
def validate(machine)
|
26
|
+
errors = []
|
27
|
+
|
28
|
+
errors << "winrm.username cannot be nil." if machine.config.winrm.username.nil?
|
29
|
+
errors << "winrm.password cannot be nil." if machine.config.winrm.password.nil?
|
30
|
+
errors << "winrm.host cannot be nil." if machine.config.winrm.host.nil?
|
31
|
+
errors << "winrm.port cannot be nil." if machine.config.winrm.port.nil?
|
32
|
+
errors << "winrm.guest_port cannot be nil." if machine.config.winrm.guest_port.nil?
|
33
|
+
errors << "winrm.max_tries cannot be nil." if machine.config.winrm.max_tries.nil?
|
34
|
+
errors << "winrm.timeout cannot be nil." if machine.config.winrm.timeout.nil?
|
25
35
|
|
36
|
+
{ "WinRM" => errors }
|
26
37
|
end
|
38
|
+
|
39
|
+
def finalize!
|
40
|
+
@username = "vagrant" if @username == UNSET_VALUE
|
41
|
+
@password = "vagrant" if @password == UNSET_VALUE
|
42
|
+
@host = "localhost" if @host == UNSET_VALUE
|
43
|
+
@port = 5985 if @port == UNSET_VALUE
|
44
|
+
@guest_port = 5985 if @guest_port == UNSET_VALUE
|
45
|
+
@max_tries = 12 if @max_tries == UNSET_VALUE
|
46
|
+
@timeout = 1800 if @timeout == UNSET_VALUE
|
47
|
+
end
|
48
|
+
|
27
49
|
end
|
28
50
|
end
|
29
51
|
end
|
30
|
-
|
31
|
-
Vagrant.config_keys.register(:winrm) { Vagrant::Config::WinRM }
|
@@ -1,22 +1,27 @@
|
|
1
|
-
|
1
|
+
require 'vagrant/errors'
|
2
|
+
|
3
|
+
module VagrantWindows
|
2
4
|
module Errors
|
3
|
-
|
4
|
-
|
5
|
+
|
6
|
+
class VagrantWindowsError < ::Vagrant::Errors::VagrantError
|
7
|
+
error_namespace("vagrant_windows.errors")
|
8
|
+
end
|
9
|
+
|
10
|
+
class WinRMPortNotDetected < VagrantWindowsError
|
5
11
|
error_key(:winrm_port_not_detected)
|
6
12
|
end
|
7
13
|
|
8
|
-
class WinRMInvalidShell <
|
9
|
-
status_code(551)
|
14
|
+
class WinRMInvalidShell < VagrantWindowsError
|
10
15
|
error_key(:winrm_invalid_shell)
|
11
16
|
end
|
12
|
-
|
13
|
-
|
14
|
-
error_key(:
|
15
|
-
end
|
16
|
-
class WinRMTimeout < VagrantError
|
17
|
-
status_code(553)
|
18
|
-
error_key(:winrm_timeout)
|
17
|
+
|
18
|
+
class WinRMExecutionError < VagrantWindowsError
|
19
|
+
error_key(:winrm_execution_error)
|
19
20
|
end
|
21
|
+
|
22
|
+
class WinRMAuthorizationError < VagrantWindowsError
|
23
|
+
error_key(:winrm_auth_error)
|
24
|
+
end
|
20
25
|
|
21
26
|
end
|
22
27
|
end
|