vagrant-windows 1.0.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/README.md +34 -12
- data/lib/vagrant-windows.rb +0 -9
- data/lib/vagrant-windows/communication/winrmcommunicator.rb +5 -3
- data/lib/vagrant-windows/helper.rb +13 -0
- data/lib/vagrant-windows/monkey_patches/chef_solo.rb +1 -1
- data/lib/vagrant-windows/monkey_patches/provisioner.rb +89 -0
- data/lib/vagrant-windows/monkey_patches/puppet.rb +2 -2
- data/lib/vagrant-windows/plugin.rb +4 -1
- data/lib/vagrant-windows/version.rb +1 -1
- data/spec/vagrant-windows/helper_spec.rb +27 -0
- metadata +35 -11
- checksums.yaml +0 -7
data/Gemfile
CHANGED
@@ -7,5 +7,5 @@ group :development do
|
|
7
7
|
# We depend on Vagrant for development, but we don't add it as a
|
8
8
|
# gem dependency because we expect to be installed within the
|
9
9
|
# Vagrant environment itself using `vagrant plugin`.
|
10
|
-
gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
|
10
|
+
gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag => 'v1.1.5'
|
11
11
|
end
|
data/README.md
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
Installing Vagrant-Windows
|
3
2
|
==========================
|
4
3
|
|
@@ -6,6 +5,15 @@ Installing Vagrant-Windows
|
|
6
5
|
- Vagrant 1.1 should use <code>gem "vagrant-windows", "~> 1.0.0"</code>
|
7
6
|
- 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
7
|
|
8
|
+
Supported Guest Operating Systems (Your VM)
|
9
|
+
===========================================
|
10
|
+
_Does NOT work with Windows 2003 or XP_
|
11
|
+
|
12
|
+
- Windows 7
|
13
|
+
- Windows 2008
|
14
|
+
- Windows 2008 R2
|
15
|
+
- Windows 2012
|
16
|
+
- Windows 8
|
9
17
|
|
10
18
|
Building a Base Box
|
11
19
|
===================
|
@@ -39,7 +47,6 @@ config.vm.guest = :windows
|
|
39
47
|
config.windows.halt_timeout = 15
|
40
48
|
config.winrm.username = "vagrant"
|
41
49
|
config.winrm.password = "vagrant"
|
42
|
-
config.vm.network :forwarded_port, guest: 3389, host: 3389
|
43
50
|
config.vm.network :forwarded_port, guest: 5985, host: 5985
|
44
51
|
```
|
45
52
|
|
@@ -87,10 +94,7 @@ What Works?
|
|
87
94
|
- vagrant up|halt|reload|provision
|
88
95
|
- Chef Vagrant Provisioner
|
89
96
|
- Puppet Vagrant Provisioner
|
90
|
-
|
91
|
-
What has not been tested
|
92
|
-
========================
|
93
|
-
- Shell provisioning. Shell should work, though I have not vetted it yet.
|
97
|
+
- Shell Vagrant provisioner. Batch files or PowerShell (ps1) scripts are supported as well as inline scripts.
|
94
98
|
|
95
99
|
TODOs
|
96
100
|
=========
|
@@ -161,13 +165,31 @@ References and Shout Outs
|
|
161
165
|
|
162
166
|
Changelog
|
163
167
|
=========
|
164
|
-
0.1.1
|
168
|
+
0.1.1
|
169
|
+
|
170
|
+
- Remove extra debug information from command output.
|
171
|
+
|
172
|
+
0.1.2
|
173
|
+
|
174
|
+
- Added virtual box 4.2 support.
|
175
|
+
|
176
|
+
0.1.3
|
177
|
+
|
178
|
+
- Added puppet provisioner.
|
179
|
+
|
180
|
+
1.0.0
|
181
|
+
|
182
|
+
- Converted to Vagrant 1.1.x plugin architecture.
|
183
|
+
|
184
|
+
1.0.1
|
165
185
|
|
166
|
-
|
186
|
+
- Fix #29 Monkey Patch the 4.2 driver to include read_mac_addresses.
|
187
|
+
- use read_mac_addresses in all cases.
|
167
188
|
|
168
|
-
0.
|
189
|
+
1.0.3
|
169
190
|
|
170
|
-
|
191
|
+
- Added vagrant shell provisioner.
|
192
|
+
The built-in shell provisioner tried to chmod the target script which doesn't make sense on windows.
|
171
193
|
|
172
|
-
|
173
|
-
|
194
|
+
- Can now run the vagrant-windows plugin via bundle exec instead of vagrant plugin install (for plugin dev).The vagrant src root finding logic didn't work from a bundle, but the native Vagrant src root does.
|
195
|
+
- Readme fixes/updates.
|
data/lib/vagrant-windows.rb
CHANGED
@@ -2,15 +2,6 @@ require "pathname"
|
|
2
2
|
|
3
3
|
module VagrantWindows
|
4
4
|
|
5
|
-
def self.vagrant_lib_root
|
6
|
-
# example match: /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.2/lib
|
7
|
-
@vagrant_lib_root ||= $LOAD_PATH.select { |p| p =~ /\/vagrant-[1-9].[0-9].[0-9]\/lib/ }.first
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.vagrant_root
|
11
|
-
@vagrant_root ||= Pathname.new(File.expand_path("../", vagrant_lib_root))
|
12
|
-
end
|
13
|
-
|
14
5
|
def self.vagrant_windows_root
|
15
6
|
@vagrant_windows_root ||= Pathname.new(File.expand_path("../../", __FILE__))
|
16
7
|
end
|
@@ -51,7 +51,9 @@ module VagrantWindows
|
|
51
51
|
:shell => :powershell
|
52
52
|
}.merge(opts || {})
|
53
53
|
|
54
|
-
|
54
|
+
if opts[:shell].eql? :powershell
|
55
|
+
command = VagrantWindows.load_script("command_alias.ps1") << "\r\n" << command
|
56
|
+
end
|
55
57
|
exit_status = 0
|
56
58
|
|
57
59
|
begin
|
@@ -113,7 +115,7 @@ module VagrantWindows
|
|
113
115
|
Base64.encode64(IO.binread(from)).gsub("\n",'').chars.to_a.each_slice(8000-file_name.size) do |chunk|
|
114
116
|
out = session.cmd( "echo #{chunk.join} >> \"#{file_name}\"" )
|
115
117
|
end
|
116
|
-
execute "mkdir [System.IO.Path]::GetDirectoryName(\"#{to}\")"
|
118
|
+
execute "mkdir $([System.IO.Path]::GetDirectoryName(\"#{to}\"))"
|
117
119
|
execute <<-EOH
|
118
120
|
$base64_string = Get-Content \"#{file_name}\"
|
119
121
|
$bytes = [System.Convert]::FromBase64String($base64_string)
|
@@ -210,4 +212,4 @@ module VagrantWindows
|
|
210
212
|
|
211
213
|
end #WinRM class
|
212
214
|
end
|
213
|
-
end
|
215
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require "#{Vagrant::source_root}/plugins/provisioners/shell/provisioner"
|
2
|
+
require "vagrant-windows/helper"
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module Shell
|
6
|
+
class Provisioner < Vagrant.plugin("2", :provisioner)
|
7
|
+
|
8
|
+
include VagrantWindows::Helper
|
9
|
+
|
10
|
+
# This patch is needed until Vagrant supports Puppet on Windows guests
|
11
|
+
provision_on_linux = instance_method(:provision)
|
12
|
+
|
13
|
+
define_method(:provision) do
|
14
|
+
is_windows ? provision_on_windows() : provision_on_linux.bind(self).()
|
15
|
+
end
|
16
|
+
|
17
|
+
def provision_on_windows
|
18
|
+
args = ""
|
19
|
+
args = " #{config.args}" if config.args
|
20
|
+
|
21
|
+
with_script_file do |path|
|
22
|
+
# Upload the script to the machine
|
23
|
+
@machine.communicate.tap do |comm|
|
24
|
+
# Ensure the uploaded script has a file extension, by default
|
25
|
+
# config.upload_path from vagrant core does not
|
26
|
+
fixed_upload_path = if File.extname(config.upload_path) == ""
|
27
|
+
"#{config.upload_path}#{File.extname(path.to_s)}"
|
28
|
+
else
|
29
|
+
config.upload_path
|
30
|
+
end
|
31
|
+
comm.upload(path.to_s, fixed_upload_path)
|
32
|
+
|
33
|
+
command = <<-EOH
|
34
|
+
$old = Get-ExecutionPolicy;
|
35
|
+
Set-ExecutionPolicy Unrestricted -force;
|
36
|
+
#{win_friendly_path(fixed_upload_path)}#{args};
|
37
|
+
Set-ExecutionPolicy $old -force
|
38
|
+
EOH
|
39
|
+
|
40
|
+
# Execute it with sudo
|
41
|
+
comm.sudo(command) do |type, data|
|
42
|
+
if [:stderr, :stdout].include?(type)
|
43
|
+
# Output the data with the proper color based on the stream.
|
44
|
+
color = type == :stdout ? :green : :red
|
45
|
+
|
46
|
+
# Note: Be sure to chomp the data to avoid the newlines that the
|
47
|
+
# Chef outputs.
|
48
|
+
@machine.env.ui.info(data.chomp, :color => color, :prefix => false)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
protected
|
58
|
+
|
59
|
+
# This method yields the path to a script to upload and execute
|
60
|
+
# on the remote server. This method will properly clean up the
|
61
|
+
# script file if needed.
|
62
|
+
def with_script_file
|
63
|
+
if config.path
|
64
|
+
# Just yield the path to that file...
|
65
|
+
yield config.path
|
66
|
+
else
|
67
|
+
# Otherwise we have an inline script, we need to Tempfile it,
|
68
|
+
# and handle it specially...
|
69
|
+
file = Tempfile.new(['vagrant-powershell', '.ps1'])
|
70
|
+
|
71
|
+
begin
|
72
|
+
file.write(config.inline)
|
73
|
+
file.fsync
|
74
|
+
file.close
|
75
|
+
yield file.path
|
76
|
+
ensure
|
77
|
+
file.close
|
78
|
+
file.unlink
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def is_windows
|
84
|
+
@machine.config.vm.guest.eql? :windows
|
85
|
+
end
|
86
|
+
|
87
|
+
end # Provisioner class
|
88
|
+
end
|
89
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require "#{
|
1
|
+
require "#{Vagrant::source_root}/plugins/provisioners/puppet/provisioner/puppet"
|
2
2
|
|
3
3
|
module VagrantPlugins
|
4
4
|
module Puppet
|
@@ -85,7 +85,7 @@ module VagrantPlugins
|
|
85
85
|
@module_paths.each do |from, to|
|
86
86
|
# Sorry for the cryptic key here, but VirtualBox has a strange limit on
|
87
87
|
# maximum size for it and its something small (around 10)
|
88
|
-
root_config.vm.synced_folder(from, to)
|
88
|
+
root_config.vm.synced_folder(from, to, :id => "v-modules-#{count}")
|
89
89
|
count += 1
|
90
90
|
end
|
91
91
|
end
|
@@ -16,7 +16,7 @@ require "vagrant-windows/errors"
|
|
16
16
|
# Add Vagrant WinRM communication channel
|
17
17
|
require "vagrant-windows/communication/winrmcommunicator"
|
18
18
|
|
19
|
-
# Monkey patch the
|
19
|
+
# Monkey patch the vbox42 driver
|
20
20
|
require "vagrant-windows/monkey_patches/vbox_42_driver"
|
21
21
|
|
22
22
|
# Monkey Patch the VM object to support multiple channels, i.e. WinRM
|
@@ -28,6 +28,9 @@ require "vagrant-windows/monkey_patches/puppet"
|
|
28
28
|
# Monkey patch the Chef-Solo provisioner to support PowerShell/Windows
|
29
29
|
require "vagrant-windows/monkey_patches/chef_solo"
|
30
30
|
|
31
|
+
# Monkey patch the shell provisioner to support PowerShell/batch/exe/Windows/etc
|
32
|
+
require "vagrant-windows/monkey_patches/provisioner"
|
33
|
+
|
31
34
|
# Add our windows specific config object
|
32
35
|
require "vagrant-windows/config/windows"
|
33
36
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "vagrant-windows/helper"
|
2
|
+
|
3
|
+
describe VagrantWindows::Helper do
|
4
|
+
|
5
|
+
class DummyHelper
|
6
|
+
include VagrantWindows::Helper
|
7
|
+
end
|
8
|
+
|
9
|
+
before(:all) do
|
10
|
+
@dummy = DummyHelper.new
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "win_friendly_path" do
|
14
|
+
it "should replace slashes with backslashes" do
|
15
|
+
@dummy.win_friendly_path('c:/tmp/dir').should eq('c:\\tmp\\dir')
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should prepend c: drive if not drive specified" do
|
19
|
+
@dummy.win_friendly_path('/tmp/dir').should eq('c:\\tmp\\dir')
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should return nil if no path specified" do
|
23
|
+
@dummy.win_friendly_path(nil).should be_nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
metadata
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-windows
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Paul Morton
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-
|
12
|
+
date: 2013-06-07 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: winrm
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
@@ -20,6 +22,7 @@ dependencies:
|
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
@@ -27,34 +30,39 @@ dependencies:
|
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: highline
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- - '>='
|
35
|
+
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: '0'
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- - '>='
|
43
|
+
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: '0'
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: rake
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
|
-
- - '>='
|
51
|
+
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: '0'
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
|
-
- - '>='
|
59
|
+
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: rspec-core
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
67
|
- - ~>
|
60
68
|
- !ruby/object:Gem::Version
|
@@ -62,6 +70,7 @@ dependencies:
|
|
62
70
|
type: :development
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
75
|
- - ~>
|
67
76
|
- !ruby/object:Gem::Version
|
@@ -69,6 +78,7 @@ dependencies:
|
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
79
|
name: rspec-expectations
|
71
80
|
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
72
82
|
requirements:
|
73
83
|
- - ~>
|
74
84
|
- !ruby/object:Gem::Version
|
@@ -76,6 +86,7 @@ dependencies:
|
|
76
86
|
type: :development
|
77
87
|
prerelease: false
|
78
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
79
90
|
requirements:
|
80
91
|
- - ~>
|
81
92
|
- !ruby/object:Gem::Version
|
@@ -83,6 +94,7 @@ dependencies:
|
|
83
94
|
- !ruby/object:Gem::Dependency
|
84
95
|
name: rspec-mocks
|
85
96
|
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
86
98
|
requirements:
|
87
99
|
- - ~>
|
88
100
|
- !ruby/object:Gem::Version
|
@@ -90,6 +102,7 @@ dependencies:
|
|
90
102
|
type: :development
|
91
103
|
prerelease: false
|
92
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
93
106
|
requirements:
|
94
107
|
- - ~>
|
95
108
|
- !ruby/object:Gem::Version
|
@@ -112,8 +125,10 @@ files:
|
|
112
125
|
- lib/vagrant-windows/config/winrm.rb
|
113
126
|
- lib/vagrant-windows/errors.rb
|
114
127
|
- lib/vagrant-windows/guest/windows.rb
|
128
|
+
- lib/vagrant-windows/helper.rb
|
115
129
|
- lib/vagrant-windows/monkey_patches/chef_solo.rb
|
116
130
|
- lib/vagrant-windows/monkey_patches/machine.rb
|
131
|
+
- lib/vagrant-windows/monkey_patches/provisioner.rb
|
117
132
|
- lib/vagrant-windows/monkey_patches/puppet.rb
|
118
133
|
- lib/vagrant-windows/monkey_patches/vbox_42_driver.rb
|
119
134
|
- lib/vagrant-windows/plugin.rb
|
@@ -123,30 +138,39 @@ files:
|
|
123
138
|
- lib/vagrant-windows/version.rb
|
124
139
|
- locales/en.yml
|
125
140
|
- spec/vagrant-windows/config_spec.rb
|
141
|
+
- spec/vagrant-windows/helper_spec.rb
|
126
142
|
- vagrant-windows.gemspec
|
127
143
|
homepage: ''
|
128
144
|
licenses: []
|
129
|
-
metadata: {}
|
130
145
|
post_install_message:
|
131
146
|
rdoc_options: []
|
132
147
|
require_paths:
|
133
148
|
- lib
|
134
149
|
required_ruby_version: !ruby/object:Gem::Requirement
|
150
|
+
none: false
|
135
151
|
requirements:
|
136
|
-
- - '>='
|
152
|
+
- - ! '>='
|
137
153
|
- !ruby/object:Gem::Version
|
138
154
|
version: '0'
|
155
|
+
segments:
|
156
|
+
- 0
|
157
|
+
hash: 459186587088148181
|
139
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
|
+
none: false
|
140
160
|
requirements:
|
141
|
-
- - '>='
|
161
|
+
- - ! '>='
|
142
162
|
- !ruby/object:Gem::Version
|
143
163
|
version: '0'
|
164
|
+
segments:
|
165
|
+
- 0
|
166
|
+
hash: 459186587088148181
|
144
167
|
requirements: []
|
145
168
|
rubyforge_project:
|
146
|
-
rubygems_version:
|
169
|
+
rubygems_version: 1.8.25
|
147
170
|
signing_key:
|
148
|
-
specification_version:
|
171
|
+
specification_version: 3
|
149
172
|
summary: A small gem that adds windows guest support to vagrant, uses WinRM as the
|
150
173
|
Communication Channel
|
151
174
|
test_files:
|
152
175
|
- spec/vagrant-windows/config_spec.rb
|
176
|
+
- spec/vagrant-windows/helper_spec.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: e8275a55fe7f1a0a294fbe31a81a6e6e6a6014b2
|
4
|
-
data.tar.gz: dc9745a62fe13ee73cb65812e4698051f726508c
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: ad5f812d845fce099340ba355bef6b6e041576125483e706b989c6b092005f0aa45375f0f4a24981834710eebaadde495eda90c499a943fded37783fe75e6b18
|
7
|
-
data.tar.gz: 7f504f4eb7aac168441142cb90225fbf22f6535f330c33c384f9eac2bc29238faddd886715235c4a4f3ed88760ddad13ab900e3a42f27774f972e1bb18e8b2e4
|