vagrant-windows 1.5.1 → 1.6.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/.travis.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/README.md +8 -1
- data/lib/vagrant-windows/communication/winrmcommunicator.rb +3 -2
- data/lib/vagrant-windows/communication/winrmshell.rb +8 -0
- data/lib/vagrant-windows/monkey_patches/plugins/provisioners/chef/provisioner/chef_client.rb +74 -1
- data/lib/vagrant-windows/monkey_patches/plugins/provisioners/chef/provisioner/chef_solo.rb +20 -66
- data/lib/vagrant-windows/provisioners/chef_command_builder.rb +105 -0
- data/lib/vagrant-windows/version.rb +1 -1
- data/lib/vagrant-windows/windows_machine.rb +13 -0
- data/spec/vagrant-windows/chef_command_builder_spec.rb +101 -0
- data/spec/vagrant-windows/windows_machine_spec.rb +30 -0
- metadata +14 -31
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 6e89e485b8fae09a9d784792b184ebbc61d70185
|
|
4
|
+
data.tar.gz: a36e78c2c59df8921a7ad3db46ac7713d02a04d7
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 035e50bbe58c5e2512624982e1a2797f36530ce8855c67e45dbd5ab3aea8d15390aab866b870c660a870799061cdcec33f006f610928812ee4cb747685a5901d
|
|
7
|
+
data.tar.gz: a23744a7c72a969c0ea40a935b1a5deb8c85bafc0a4815f4729d232c7f74a7a12ea0283156b88499740b175d6085e702d69b80a66ad129e873e72c059a868c80
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -73,3 +73,7 @@
|
|
|
73
73
|
- Fixed issue 158 - Vagrant 1.4 broke the Puppet provisioner monkey patch. Removed configure method monkey patch.
|
|
74
74
|
- Fixed issue 162 - Set plugin name to 'vagrant-windows' to support has_plugin? method works.
|
|
75
75
|
- Reset winrmshell on error. When using the vSphere provider the hostname would not resolve.
|
|
76
|
+
|
|
77
|
+
1.6.0
|
|
78
|
+
- Added chef-client provisioner support and extracted shared code from chef-solo provisioner
|
|
79
|
+
- WinRM communicator download support
|
data/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://codeclimate.com/github/WinRb/vagrant-windows)
|
|
4
4
|
[](http://badge.fury.io/rb/vagrant-windows)
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
This [Vagrant](http://www.vagrantup.com/) plugin allows you to standup Windows guests using [WinRM](http://msdn.microsoft.com/en-us/library/aa384426\(v=vs.85\).aspx) instead of SSH. Additionally this plugin makes it easier to provision with Chef, Puppet, and the shell (PowerShell) on Windows guests.
|
|
7
7
|
|
|
8
8
|
## Getting Started
|
|
9
9
|
1. Install the vagrant-windows plugin.
|
|
@@ -48,6 +48,13 @@ These commands assume you're running from a regular command window and not Power
|
|
|
48
48
|
sc config WinRM start= auto
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
+
__NOTE:__ For the WinRM service to work in Windows 7, the network profile has to be changed from Public to Work. To ensure that networks added later (i.e. through the Vagrantfile) also are made non-public, add the following to your Vagrantfile:
|
|
52
|
+
|
|
53
|
+
```ruby
|
|
54
|
+
# Ensure that all networks are set to private
|
|
55
|
+
config.windows.set_work_network = true
|
|
56
|
+
```
|
|
57
|
+
|
|
51
58
|
#### Additional WinRM 1.1 Configuration
|
|
52
59
|
|
|
53
60
|
These additional configuration steps are specific to Windows Server 2008 (WinRM 1.1). For Windows Server 2008 R2, Windows 7 and later versions of Windows you can ignore this section.
|
|
@@ -75,8 +75,9 @@ module VagrantWindows
|
|
|
75
75
|
winrmshell.upload(from, to)
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
def download(from, to
|
|
79
|
-
@logger.
|
|
78
|
+
def download(from, to)
|
|
79
|
+
@logger.debug("Downloading: #{from} to #{to}")
|
|
80
|
+
winrmshell.download(from, to)
|
|
80
81
|
end
|
|
81
82
|
|
|
82
83
|
def winrmshell=(winrmshell)
|
|
@@ -77,6 +77,14 @@ module VagrantWindows
|
|
|
77
77
|
EOH
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
+
def download(from, to)
|
|
81
|
+
@logger.debug("Downloading: #{from} to #{to}")
|
|
82
|
+
output = powershell("[System.convert]::ToBase64String([System.IO.File]::ReadAllBytes(\"#{from}\"))")
|
|
83
|
+
contents = output[:data].map!{|line| line[:stdout]}.join.gsub("\\n\\r", '')
|
|
84
|
+
out = Base64.decode64(contents)
|
|
85
|
+
IO.binwrite(to, out)
|
|
86
|
+
end
|
|
87
|
+
|
|
80
88
|
protected
|
|
81
89
|
|
|
82
90
|
def execute_shell(command, shell=:powershell, &block)
|
data/lib/vagrant-windows/monkey_patches/plugins/provisioners/chef/provisioner/chef_client.rb
CHANGED
|
@@ -1 +1,74 @@
|
|
|
1
|
-
#
|
|
1
|
+
require "#{Vagrant::source_root}/plugins/provisioners/chef/provisioner/chef_client"
|
|
2
|
+
require_relative '../../../../../helper'
|
|
3
|
+
require_relative '../../../../../windows_machine'
|
|
4
|
+
require_relative '../../../../../provisioners/chef_command_builder'
|
|
5
|
+
|
|
6
|
+
module VagrantPlugins
|
|
7
|
+
module Chef
|
|
8
|
+
module Provisioner
|
|
9
|
+
class ChefClient < Base
|
|
10
|
+
|
|
11
|
+
include VagrantWindows::Helper
|
|
12
|
+
|
|
13
|
+
def initialize(machine, config)
|
|
14
|
+
super
|
|
15
|
+
@windows_machine = VagrantWindows::WindowsMachine.new(machine)
|
|
16
|
+
@logger = Log4r::Logger.new("vagrant::provisioners::chef_client")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
provision_on_linux = instance_method(:provision)
|
|
20
|
+
run_chef_client_on_linux = instance_method(:run_chef_client)
|
|
21
|
+
|
|
22
|
+
define_method(:run_chef_client) do
|
|
23
|
+
@windows_machine.is_windows? ? run_chef_client_on_windows() : run_chef_client_on_linux.bind(self).()
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
define_method(:provision) do
|
|
27
|
+
wait_if_rebooting(@windows_machine) if @windows_machine.is_windows?
|
|
28
|
+
provision_on_linux.bind(self).()
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def run_chef_client_on_windows
|
|
32
|
+
if @config.run_list && @config.run_list.empty?
|
|
33
|
+
@machine.ui.warn(I18n.t("vagrant.chef_run_list_empty"))
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
#################### START - monkey patched code ####################
|
|
37
|
+
command_builder = ::VagrantWindows::Provisioners::ChefCommandBuilder.new(
|
|
38
|
+
@windows_machine, @config, :client)
|
|
39
|
+
|
|
40
|
+
command_builder.prepare_for_chef_run()
|
|
41
|
+
command = command_builder.run_chef_command()
|
|
42
|
+
###################### END - monkey patched code ####################
|
|
43
|
+
|
|
44
|
+
@config.attempts.times do |attempt|
|
|
45
|
+
if attempt == 0
|
|
46
|
+
@machine.env.ui.info I18n.t("vagrant.provisioners.chef.running_client")
|
|
47
|
+
else
|
|
48
|
+
@machine.env.ui.info I18n.t("vagrant.provisioners.chef.running_client_again")
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
#################### START - monkey patched code ####################
|
|
52
|
+
@windows_machine.reinitialize_network_shares()
|
|
53
|
+
###################### END - monkey patched code ####################
|
|
54
|
+
|
|
55
|
+
exit_status = @machine.communicate.execute(command, :error_check => false) do |type, data|
|
|
56
|
+
# Output the data with the proper color based on the stream.
|
|
57
|
+
color = type == :stdout ? :green : :red
|
|
58
|
+
|
|
59
|
+
@machine.env.ui.info(
|
|
60
|
+
data, :color => color, :new_line => false, :prefix => false)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# There is no need to run Chef again if it converges
|
|
64
|
+
return if exit_status == 0
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# If we reached this point then Chef never converged! Error.
|
|
68
|
+
raise ChefError, :no_convergence
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end # ChefSolo class
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -1,46 +1,43 @@
|
|
|
1
|
-
require 'tempfile'
|
|
2
1
|
require "#{Vagrant::source_root}/plugins/provisioners/chef/provisioner/chef_solo"
|
|
3
2
|
require_relative '../../../../../helper'
|
|
4
3
|
require_relative '../../../../../windows_machine'
|
|
4
|
+
require_relative '../../../../../provisioners/chef_command_builder'
|
|
5
5
|
|
|
6
6
|
module VagrantPlugins
|
|
7
7
|
module Chef
|
|
8
8
|
module Provisioner
|
|
9
9
|
class ChefSolo < Base
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
include VagrantWindows::Helper
|
|
12
|
+
|
|
13
|
+
def initialize(machine, config)
|
|
14
|
+
super
|
|
15
|
+
@windows_machine = VagrantWindows::WindowsMachine.new(machine)
|
|
16
|
+
@logger = Log4r::Logger.new("vagrant::provisioners::chef_solo")
|
|
17
|
+
end
|
|
12
18
|
|
|
13
19
|
provision_on_linux = instance_method(:provision)
|
|
14
20
|
run_chef_solo_on_linux = instance_method(:run_chef_solo)
|
|
15
21
|
|
|
16
22
|
# This patch is needed until Vagrant supports chef on Windows guests
|
|
17
23
|
define_method(:run_chef_solo) do
|
|
18
|
-
is_windows? ? run_chef_solo_on_windows() : run_chef_solo_on_linux.bind(self).()
|
|
24
|
+
@windows_machine.is_windows? ? run_chef_solo_on_windows() : run_chef_solo_on_linux.bind(self).()
|
|
19
25
|
end
|
|
20
26
|
|
|
21
27
|
define_method(:provision) do
|
|
22
|
-
windows_machine
|
|
23
|
-
wait_if_rebooting(windows_machine) if is_windows?
|
|
28
|
+
wait_if_rebooting(@windows_machine) if @windows_machine.is_windows?
|
|
24
29
|
provision_on_linux.bind(self).()
|
|
25
30
|
end
|
|
26
31
|
|
|
27
32
|
def run_chef_solo_on_windows
|
|
28
|
-
# create cheftaskrun.ps1 that the scheduled task will invoke when run
|
|
29
|
-
render_file_and_upload("cheftaskrun.ps1", chef_script_options[:chef_task_run_ps1], :options => chef_script_options)
|
|
30
|
-
|
|
31
|
-
# create cheftask.xml that the scheduled task will be created with
|
|
32
|
-
render_file_and_upload("cheftask.xml", chef_script_options[:chef_task_xml], :options => chef_script_options)
|
|
33
|
-
|
|
34
|
-
# create cheftask.ps1 that will immediately invoke the scheduled task and wait for completion
|
|
35
|
-
render_file_and_upload("cheftask.ps1", chef_script_options[:chef_task_ps1], :options => chef_script_options)
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
#################### START - monkey patched code ####################
|
|
35
|
+
command_builder = ::VagrantWindows::Provisioners::ChefCommandBuilder.new(
|
|
36
|
+
@windows_machine, @config, :solo)
|
|
37
|
+
|
|
38
|
+
command_builder.prepare_for_chef_run()
|
|
39
|
+
command = command_builder.run_chef_command()
|
|
40
|
+
###################### END - monkey patched code ####################
|
|
44
41
|
|
|
45
42
|
@config.attempts.times do |attempt|
|
|
46
43
|
if attempt == 0
|
|
@@ -49,9 +46,9 @@ module VagrantPlugins
|
|
|
49
46
|
@machine.env.ui.info I18n.t("vagrant.provisioners.chef.running_solo_again")
|
|
50
47
|
end
|
|
51
48
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
#################### START - monkey patched code ####################
|
|
50
|
+
@windows_machine.reinitialize_network_shares()
|
|
51
|
+
###################### END - monkey patched code ####################
|
|
55
52
|
|
|
56
53
|
exit_status = @machine.communicate.execute(command, :error_check => false) do |type, data|
|
|
57
54
|
# Output the data with the proper color based on the stream.
|
|
@@ -69,49 +66,6 @@ module VagrantPlugins
|
|
|
69
66
|
raise ChefError, :no_convergence
|
|
70
67
|
end
|
|
71
68
|
|
|
72
|
-
def render_file_and_upload(script_name, dest_file, options)
|
|
73
|
-
script_contents = VagrantWindows.load_script_template(script_name, options)
|
|
74
|
-
|
|
75
|
-
# render cheftaskrun.ps1 to local temp file
|
|
76
|
-
script_local = Tempfile.new(script_name)
|
|
77
|
-
IO.write(script_local, script_contents)
|
|
78
|
-
|
|
79
|
-
# upload cheftaskrun.ps1 file
|
|
80
|
-
@machine.communicate.upload(script_local, dest_file)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def chef_script_options
|
|
84
|
-
if @chef_script_options.nil?
|
|
85
|
-
command_env = @config.binary_env ? "#{@config.binary_env} " : ""
|
|
86
|
-
command_args = @config.arguments ? " #{@config.arguments}" : ""
|
|
87
|
-
chef_solo_path = win_friendly_path(File.join(@config.provisioning_path, 'solo.rb'))
|
|
88
|
-
chef_dna_path = win_friendly_path(File.join(@config.provisioning_path, 'dna.json'))
|
|
89
|
-
|
|
90
|
-
chef_arguments = "-c #{chef_solo_path} "
|
|
91
|
-
chef_arguments << "-j #{chef_dna_path} "
|
|
92
|
-
chef_arguments << "#{command_args}"
|
|
93
|
-
|
|
94
|
-
@chef_script_options = {
|
|
95
|
-
:user => @machine.config.winrm.username,
|
|
96
|
-
:pass => @machine.config.winrm.password,
|
|
97
|
-
:chef_arguments => chef_arguments,
|
|
98
|
-
:chef_task_xml => win_friendly_path("#{@config.provisioning_path}/cheftask.xml"),
|
|
99
|
-
:chef_task_running => win_friendly_path("#{@config.provisioning_path}/cheftask.running"),
|
|
100
|
-
:chef_task_exitcode => win_friendly_path("#{@config.provisioning_path}/cheftask.exitcode"),
|
|
101
|
-
:chef_task_ps1 => win_friendly_path("#{@config.provisioning_path}/cheftask.ps1"),
|
|
102
|
-
:chef_task_run_ps1 => win_friendly_path("#{@config.provisioning_path}/cheftaskrun.ps1"),
|
|
103
|
-
:chef_stdout_log => win_friendly_path("#{@config.provisioning_path}/chef-solo.log"),
|
|
104
|
-
:chef_stderr_log => win_friendly_path("#{@config.provisioning_path}/chef-solo.err.log"),
|
|
105
|
-
:chef_binary_path => win_friendly_path("#{command_env}#{chef_binary_path("chef-solo")}")
|
|
106
|
-
}
|
|
107
|
-
end
|
|
108
|
-
@chef_script_options
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
def is_windows?
|
|
112
|
-
VagrantWindows::WindowsMachine.is_windows?(@machine)
|
|
113
|
-
end
|
|
114
|
-
|
|
115
69
|
end # ChefSolo class
|
|
116
70
|
end
|
|
117
71
|
end
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
require 'tempfile'
|
|
2
|
+
require_relative '../helper'
|
|
3
|
+
require_relative '../windows_machine'
|
|
4
|
+
|
|
5
|
+
module VagrantWindows
|
|
6
|
+
module Provisioners
|
|
7
|
+
|
|
8
|
+
# Builds scripts and ultimately the command to execute Chef solo or Chef client
|
|
9
|
+
# on Windows guests using a scheduled task.
|
|
10
|
+
class ChefCommandBuilder
|
|
11
|
+
|
|
12
|
+
include VagrantWindows::Helper
|
|
13
|
+
|
|
14
|
+
def initialize(windows_machine, chef_config, client_type)
|
|
15
|
+
@windows_machine = windows_machine
|
|
16
|
+
@config = chef_config
|
|
17
|
+
|
|
18
|
+
if client_type != :solo && client_type != :client
|
|
19
|
+
raise 'Invalid client_type, expected solo or client'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
@client_type = client_type
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def prepare_for_chef_run()
|
|
26
|
+
options = create_chef_options()
|
|
27
|
+
|
|
28
|
+
# create cheftaskrun.ps1 that the scheduled task will invoke when run
|
|
29
|
+
render_file_and_upload('cheftaskrun.ps1', options[:chef_task_run_ps1],
|
|
30
|
+
:options => options)
|
|
31
|
+
|
|
32
|
+
# create cheftask.xml that the scheduled task will be created with
|
|
33
|
+
render_file_and_upload('cheftask.xml', options[:chef_task_xml],
|
|
34
|
+
:options => options)
|
|
35
|
+
|
|
36
|
+
# create cheftask.ps1 that will immediately invoke the scheduled task and wait for completion
|
|
37
|
+
render_file_and_upload('cheftask.ps1', options[:chef_task_ps1],
|
|
38
|
+
:options => options)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def run_chef_command()
|
|
42
|
+
return <<-EOH
|
|
43
|
+
$old = Get-ExecutionPolicy;
|
|
44
|
+
Set-ExecutionPolicy Unrestricted -force;
|
|
45
|
+
#{chef_task_ps1_path};
|
|
46
|
+
Set-ExecutionPolicy $old -force
|
|
47
|
+
EOH
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def render_file_and_upload(script_name, dest_file, options)
|
|
53
|
+
# render the script file to a local temp file and then upload
|
|
54
|
+
script_local = Tempfile.new(script_name)
|
|
55
|
+
IO.write(script_local, VagrantWindows.load_script_template(script_name, options))
|
|
56
|
+
@windows_machine.winrmshell.upload(script_local, dest_file)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def create_chef_options
|
|
60
|
+
command_env = @config.binary_env ? "#{@config.binary_env} " : ''
|
|
61
|
+
return {
|
|
62
|
+
:user => @windows_machine.winrm_config.username,
|
|
63
|
+
:pass => @windows_machine.winrm_config.password,
|
|
64
|
+
:chef_arguments => create_chef_arguments(),
|
|
65
|
+
:chef_task_xml => provisioning_path('cheftask.xml'),
|
|
66
|
+
:chef_task_running => provisioning_path('cheftask.running'),
|
|
67
|
+
:chef_task_exitcode => provisioning_path('cheftask.exitcode'),
|
|
68
|
+
:chef_task_ps1 => chef_task_ps1_path(),
|
|
69
|
+
:chef_task_run_ps1 => provisioning_path('cheftaskrun.ps1'),
|
|
70
|
+
:chef_stdout_log => provisioning_path("chef-#{@client_type}.log"),
|
|
71
|
+
:chef_stderr_log => provisioning_path("chef-#{@client_type}.err.log"),
|
|
72
|
+
:chef_binary_path => win_friendly_path("#{command_env}#{chef_binary_path}")
|
|
73
|
+
}
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def create_chef_arguments()
|
|
77
|
+
command_args = @config.arguments ? @config.arguments : ''
|
|
78
|
+
chef_path = provisioning_path("#{@client_type}.rb")
|
|
79
|
+
chef_dna_path = provisioning_path('dna.json')
|
|
80
|
+
|
|
81
|
+
chef_arguments = "-c #{chef_path}"
|
|
82
|
+
chef_arguments << " -j #{chef_dna_path}"
|
|
83
|
+
chef_arguments << " #{command_args}"
|
|
84
|
+
chef_arguments.strip
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def chef_task_ps1_path()
|
|
88
|
+
provisioning_path('cheftask.ps1')
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Returns the path to the Chef binary, taking into account the
|
|
92
|
+
# `binary_path` configuration option.
|
|
93
|
+
def chef_binary_path()
|
|
94
|
+
binary = "chef-#{@client_type}"
|
|
95
|
+
return binary if !@config.binary_path
|
|
96
|
+
return win_friendly_path(File.join(@config.binary_path, binary))
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def provisioning_path(file_name)
|
|
100
|
+
win_friendly_path("#{@config.provisioning_path}/#{file_name}")
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
@@ -18,6 +18,13 @@ module VagrantWindows
|
|
|
18
18
|
@machine = machine
|
|
19
19
|
@logger = Log4r::Logger.new("vagrant_windows::windows_machine")
|
|
20
20
|
end
|
|
21
|
+
|
|
22
|
+
# Returns true if this Vagrant machine is a Windows guest, otherwise false.
|
|
23
|
+
#
|
|
24
|
+
# @return [Boolean]
|
|
25
|
+
def is_windows?()
|
|
26
|
+
WindowsMachine.is_windows?(@machine)
|
|
27
|
+
end
|
|
21
28
|
|
|
22
29
|
# Checks to see if the machine is using VMWare Fusion or Workstation.
|
|
23
30
|
#
|
|
@@ -55,6 +62,12 @@ module VagrantWindows
|
|
|
55
62
|
@machine.communicate.winrmshell
|
|
56
63
|
end
|
|
57
64
|
|
|
65
|
+
# Re-establishes our symbolic links if they were created between now and a reboot
|
|
66
|
+
# Fixes issue #119
|
|
67
|
+
def reinitialize_network_shares()
|
|
68
|
+
winrmshell.powershell('& net use a-non-existant-share')
|
|
69
|
+
end
|
|
70
|
+
|
|
58
71
|
# Reads the machine's MAC addresses keyed by interface index.
|
|
59
72
|
# {1=>"0800273FAC5A", 2=>"08002757E68A"}
|
|
60
73
|
#
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe VagrantWindows::Provisioners::ChefCommandBuilder, :unit => true do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@winrm_config = stub()
|
|
7
|
+
@winrm_config.stubs(:username).returns('vagrant')
|
|
8
|
+
@winrm_config.stubs(:password).returns('secret')
|
|
9
|
+
|
|
10
|
+
@windows_machine = stub()
|
|
11
|
+
@windows_machine.stubs(:winrm_config).returns(@winrm_config)
|
|
12
|
+
|
|
13
|
+
@chef_config = stub()
|
|
14
|
+
@chef_config.stubs(:provisioning_path).returns('/tmp/vagrant-chef-1')
|
|
15
|
+
@chef_config.stubs(:arguments).returns(nil)
|
|
16
|
+
@chef_config.stubs(:binary_env).returns(nil)
|
|
17
|
+
@chef_config.stubs(:binary_path).returns(nil)
|
|
18
|
+
|
|
19
|
+
@chef_cmd_builder = VagrantWindows::Provisioners::ChefCommandBuilder.new(
|
|
20
|
+
@windows_machine, @chef_config, :client)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe 'initialize' do
|
|
24
|
+
it 'should raise when chef type is not client or solo' do
|
|
25
|
+
expect { VagrantWindows::Provisioners::ChefCommandBuilder.new(@windows_machine, @chef_config, :zero) }.to raise_error
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe 'provisioning_path' do
|
|
30
|
+
it 'should be windows friendly' do
|
|
31
|
+
@chef_cmd_builder.provisioning_path('script.ps1').should eql 'c:\tmp\vagrant-chef-1\script.ps1'
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe 'create_chef_arguments' do
|
|
36
|
+
it 'should include paths to client.rb and dna.json' do
|
|
37
|
+
expected = '-c c:\tmp\vagrant-chef-1\client.rb -j c:\tmp\vagrant-chef-1\dna.json'
|
|
38
|
+
@chef_cmd_builder.create_chef_arguments().should eql expected
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'should include Chef arguments if specified' do
|
|
42
|
+
@chef_config.stubs(:arguments).returns('-l DEBUG')
|
|
43
|
+
expected = '-c c:\tmp\vagrant-chef-1\client.rb -j c:\tmp\vagrant-chef-1\dna.json -l DEBUG'
|
|
44
|
+
@chef_cmd_builder.create_chef_arguments().should eql expected
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe 'create_chef_options' do
|
|
49
|
+
it "should include winrm username and password" do
|
|
50
|
+
options = @chef_cmd_builder.create_chef_options()
|
|
51
|
+
options[:user].should eql 'vagrant'
|
|
52
|
+
options[:pass].should eql 'secret'
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'should include paths to scripts' do
|
|
56
|
+
options = @chef_cmd_builder.create_chef_options()
|
|
57
|
+
options[:chef_task_xml].should eql 'c:\tmp\vagrant-chef-1\cheftask.xml'
|
|
58
|
+
options[:chef_task_ps1].should eql 'c:\tmp\vagrant-chef-1\cheftask.ps1'
|
|
59
|
+
options[:chef_task_run_ps1].should eql 'c:\tmp\vagrant-chef-1\cheftaskrun.ps1'
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'should include paths to process flow files' do
|
|
63
|
+
options = @chef_cmd_builder.create_chef_options()
|
|
64
|
+
options[:chef_task_running].should eql 'c:\tmp\vagrant-chef-1\cheftask.running'
|
|
65
|
+
options[:chef_task_exitcode].should eql 'c:\tmp\vagrant-chef-1\cheftask.exitcode'
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'should include paths to logs' do
|
|
69
|
+
options = @chef_cmd_builder.create_chef_options()
|
|
70
|
+
options[:chef_stdout_log].should eql 'c:\tmp\vagrant-chef-1\chef-client.log'
|
|
71
|
+
options[:chef_stderr_log].should eql 'c:\tmp\vagrant-chef-1\chef-client.err.log'
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it 'should include path to chef binary' do
|
|
75
|
+
options = @chef_cmd_builder.create_chef_options()
|
|
76
|
+
options[:chef_binary_path].should eql 'chef-client'
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it 'should include full path to chef binary when binary_path is set' do
|
|
80
|
+
@chef_config.stubs(:binary_path).returns('c:/opscode/chef/bin')
|
|
81
|
+
options = @chef_cmd_builder.create_chef_options()
|
|
82
|
+
options[:chef_binary_path].should eql 'c:\opscode\chef\bin\chef-client'
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
describe 'prepare_for_chef_run' do
|
|
88
|
+
it 'should upload cheftask scripts' do
|
|
89
|
+
winrmshell = double()
|
|
90
|
+
@windows_machine.stubs(:winrmshell).returns(winrmshell)
|
|
91
|
+
|
|
92
|
+
winrmshell.should_receive(:upload).with(anything(), 'c:\tmp\vagrant-chef-1\cheftaskrun.ps1')
|
|
93
|
+
winrmshell.should_receive(:upload).with(anything(), 'c:\tmp\vagrant-chef-1\cheftask.xml')
|
|
94
|
+
winrmshell.should_receive(:upload).with(anything(), 'c:\tmp\vagrant-chef-1\cheftask.ps1')
|
|
95
|
+
|
|
96
|
+
@chef_cmd_builder.prepare_for_chef_run()
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
end
|
|
@@ -37,6 +37,20 @@ describe VagrantWindows::WindowsMachine , :unit => true do
|
|
|
37
37
|
expect(windows_machine.is_virtualbox?()).to be_false
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
|
+
|
|
41
|
+
describe "is_parallels?" do
|
|
42
|
+
it "should be true for parallels" do
|
|
43
|
+
machine = stub(:provider_name => :parallels)
|
|
44
|
+
windows_machine = VagrantWindows::WindowsMachine.new(machine)
|
|
45
|
+
expect(windows_machine.is_parallels?()).to be_true
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "should be false for vmware_workstation" do
|
|
49
|
+
machine = stub(:provider_name => :vmware_workstation)
|
|
50
|
+
windows_machine = VagrantWindows::WindowsMachine.new(machine)
|
|
51
|
+
expect(windows_machine.is_parallels?()).to be_false
|
|
52
|
+
end
|
|
53
|
+
end
|
|
40
54
|
|
|
41
55
|
describe "is_windows?" do
|
|
42
56
|
it "should return true when config vm guest is windows" do
|
|
@@ -45,6 +59,14 @@ describe VagrantWindows::WindowsMachine , :unit => true do
|
|
|
45
59
|
machine = stub(:config => config)
|
|
46
60
|
expect(VagrantWindows::WindowsMachine.is_windows?(machine)).to be_true
|
|
47
61
|
end
|
|
62
|
+
|
|
63
|
+
it "instance should return true when config vm guest is windows" do
|
|
64
|
+
vm = stub(:guest => :windows)
|
|
65
|
+
config = stub(:vm => vm)
|
|
66
|
+
machine = stub(:config => config)
|
|
67
|
+
windows_machine = VagrantWindows::WindowsMachine.new(machine)
|
|
68
|
+
expect(windows_machine.is_windows?()).to be_true
|
|
69
|
+
end
|
|
48
70
|
|
|
49
71
|
it "should return false when config vm guest is not windows" do
|
|
50
72
|
vm = stub(:guest => :ubuntu)
|
|
@@ -52,6 +74,14 @@ describe VagrantWindows::WindowsMachine , :unit => true do
|
|
|
52
74
|
machine = stub(:config => config)
|
|
53
75
|
expect(VagrantWindows::WindowsMachine.is_windows?(machine)).to be_false
|
|
54
76
|
end
|
|
77
|
+
|
|
78
|
+
it "instance should return false when config vm guest is not windows" do
|
|
79
|
+
vm = stub(:guest => :fedora)
|
|
80
|
+
config = stub(:vm => vm)
|
|
81
|
+
machine = stub(:config => config)
|
|
82
|
+
windows_machine = VagrantWindows::WindowsMachine.new(machine)
|
|
83
|
+
expect(windows_machine.is_windows?()).to be_false
|
|
84
|
+
end
|
|
55
85
|
end
|
|
56
86
|
|
|
57
87
|
describe "read_forwarded_ports" do
|
metadata
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vagrant-windows
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 1.6.0
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Paul Morton
|
|
@@ -10,12 +9,11 @@ authors:
|
|
|
10
9
|
autorequire:
|
|
11
10
|
bindir: bin
|
|
12
11
|
cert_chain: []
|
|
13
|
-
date: 2014-
|
|
12
|
+
date: 2014-03-20 00:00:00.000000000 Z
|
|
14
13
|
dependencies:
|
|
15
14
|
- !ruby/object:Gem::Dependency
|
|
16
15
|
name: winrm
|
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
|
18
|
-
none: false
|
|
19
17
|
requirements:
|
|
20
18
|
- - ~>
|
|
21
19
|
- !ruby/object:Gem::Version
|
|
@@ -23,7 +21,6 @@ dependencies:
|
|
|
23
21
|
type: :runtime
|
|
24
22
|
prerelease: false
|
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
-
none: false
|
|
27
24
|
requirements:
|
|
28
25
|
- - ~>
|
|
29
26
|
- !ruby/object:Gem::Version
|
|
@@ -31,23 +28,20 @@ dependencies:
|
|
|
31
28
|
- !ruby/object:Gem::Dependency
|
|
32
29
|
name: rake
|
|
33
30
|
requirement: !ruby/object:Gem::Requirement
|
|
34
|
-
none: false
|
|
35
31
|
requirements:
|
|
36
|
-
- -
|
|
32
|
+
- - '>='
|
|
37
33
|
- !ruby/object:Gem::Version
|
|
38
34
|
version: '0'
|
|
39
35
|
type: :development
|
|
40
36
|
prerelease: false
|
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
|
42
|
-
none: false
|
|
43
38
|
requirements:
|
|
44
|
-
- -
|
|
39
|
+
- - '>='
|
|
45
40
|
- !ruby/object:Gem::Version
|
|
46
41
|
version: '0'
|
|
47
42
|
- !ruby/object:Gem::Dependency
|
|
48
43
|
name: rspec-core
|
|
49
44
|
requirement: !ruby/object:Gem::Requirement
|
|
50
|
-
none: false
|
|
51
45
|
requirements:
|
|
52
46
|
- - ~>
|
|
53
47
|
- !ruby/object:Gem::Version
|
|
@@ -55,7 +49,6 @@ dependencies:
|
|
|
55
49
|
type: :development
|
|
56
50
|
prerelease: false
|
|
57
51
|
version_requirements: !ruby/object:Gem::Requirement
|
|
58
|
-
none: false
|
|
59
52
|
requirements:
|
|
60
53
|
- - ~>
|
|
61
54
|
- !ruby/object:Gem::Version
|
|
@@ -63,7 +56,6 @@ dependencies:
|
|
|
63
56
|
- !ruby/object:Gem::Dependency
|
|
64
57
|
name: rspec-expectations
|
|
65
58
|
requirement: !ruby/object:Gem::Requirement
|
|
66
|
-
none: false
|
|
67
59
|
requirements:
|
|
68
60
|
- - ~>
|
|
69
61
|
- !ruby/object:Gem::Version
|
|
@@ -71,7 +63,6 @@ dependencies:
|
|
|
71
63
|
type: :development
|
|
72
64
|
prerelease: false
|
|
73
65
|
version_requirements: !ruby/object:Gem::Requirement
|
|
74
|
-
none: false
|
|
75
66
|
requirements:
|
|
76
67
|
- - ~>
|
|
77
68
|
- !ruby/object:Gem::Version
|
|
@@ -79,7 +70,6 @@ dependencies:
|
|
|
79
70
|
- !ruby/object:Gem::Dependency
|
|
80
71
|
name: rspec-mocks
|
|
81
72
|
requirement: !ruby/object:Gem::Requirement
|
|
82
|
-
none: false
|
|
83
73
|
requirements:
|
|
84
74
|
- - ~>
|
|
85
75
|
- !ruby/object:Gem::Version
|
|
@@ -87,7 +77,6 @@ dependencies:
|
|
|
87
77
|
type: :development
|
|
88
78
|
prerelease: false
|
|
89
79
|
version_requirements: !ruby/object:Gem::Requirement
|
|
90
|
-
none: false
|
|
91
80
|
requirements:
|
|
92
81
|
- - ~>
|
|
93
82
|
- !ruby/object:Gem::Version
|
|
@@ -95,17 +84,15 @@ dependencies:
|
|
|
95
84
|
- !ruby/object:Gem::Dependency
|
|
96
85
|
name: simplecov
|
|
97
86
|
requirement: !ruby/object:Gem::Requirement
|
|
98
|
-
none: false
|
|
99
87
|
requirements:
|
|
100
|
-
- -
|
|
88
|
+
- - '>='
|
|
101
89
|
- !ruby/object:Gem::Version
|
|
102
90
|
version: '0'
|
|
103
91
|
type: :development
|
|
104
92
|
prerelease: false
|
|
105
93
|
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
-
none: false
|
|
107
94
|
requirements:
|
|
108
|
-
- -
|
|
95
|
+
- - '>='
|
|
109
96
|
- !ruby/object:Gem::Version
|
|
110
97
|
version: '0'
|
|
111
98
|
description: Windows Guest Support for Vagrant
|
|
@@ -142,6 +129,7 @@ files:
|
|
|
142
129
|
- lib/vagrant-windows/monkey_patches/plugins/provisioners/puppet/provisioner/puppet_server.rb
|
|
143
130
|
- lib/vagrant-windows/monkey_patches/plugins/provisioners/shell/provisioner.rb
|
|
144
131
|
- lib/vagrant-windows/plugin.rb
|
|
132
|
+
- lib/vagrant-windows/provisioners/chef_command_builder.rb
|
|
145
133
|
- lib/vagrant-windows/scripts/cheftask.ps1.erb
|
|
146
134
|
- lib/vagrant-windows/scripts/cheftask.xml.erb
|
|
147
135
|
- lib/vagrant-windows/scripts/cheftaskrun.ps1.erb
|
|
@@ -158,6 +146,7 @@ files:
|
|
|
158
146
|
- Rakefile
|
|
159
147
|
- README.md
|
|
160
148
|
- spec/spec_helper.rb
|
|
149
|
+
- spec/vagrant-windows/chef_command_builder_spec.rb
|
|
161
150
|
- spec/vagrant-windows/guestnetwork_spec.rb
|
|
162
151
|
- spec/vagrant-windows/helper_spec.rb
|
|
163
152
|
- spec/vagrant-windows/mount_shared_folder_spec.rb
|
|
@@ -173,37 +162,31 @@ files:
|
|
|
173
162
|
homepage: https://github.com/WinRb/vagrant-windows
|
|
174
163
|
licenses:
|
|
175
164
|
- APACHE2
|
|
165
|
+
metadata: {}
|
|
176
166
|
post_install_message:
|
|
177
167
|
rdoc_options: []
|
|
178
168
|
require_paths:
|
|
179
169
|
- lib
|
|
180
170
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
181
|
-
none: false
|
|
182
171
|
requirements:
|
|
183
|
-
- -
|
|
172
|
+
- - '>='
|
|
184
173
|
- !ruby/object:Gem::Version
|
|
185
174
|
version: '0'
|
|
186
|
-
segments:
|
|
187
|
-
- 0
|
|
188
|
-
hash: -4320786780650999420
|
|
189
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
|
-
none: false
|
|
191
176
|
requirements:
|
|
192
|
-
- -
|
|
177
|
+
- - '>='
|
|
193
178
|
- !ruby/object:Gem::Version
|
|
194
179
|
version: '0'
|
|
195
|
-
segments:
|
|
196
|
-
- 0
|
|
197
|
-
hash: -4320786780650999420
|
|
198
180
|
requirements: []
|
|
199
181
|
rubyforge_project:
|
|
200
|
-
rubygems_version:
|
|
182
|
+
rubygems_version: 2.0.14
|
|
201
183
|
signing_key:
|
|
202
|
-
specification_version:
|
|
184
|
+
specification_version: 4
|
|
203
185
|
summary: A small gem that adds windows guest support to vagrant, uses WinRM as the
|
|
204
186
|
Communication Channel
|
|
205
187
|
test_files:
|
|
206
188
|
- spec/spec_helper.rb
|
|
189
|
+
- spec/vagrant-windows/chef_command_builder_spec.rb
|
|
207
190
|
- spec/vagrant-windows/guestnetwork_spec.rb
|
|
208
191
|
- spec/vagrant-windows/helper_spec.rb
|
|
209
192
|
- spec/vagrant-windows/mount_shared_folder_spec.rb
|