vagrant-unbundled 2.2.6.0 → 2.2.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/.hashibot.hcl +14 -0
  3. data/CHANGELOG.md +93 -2
  4. data/README.md +1 -3
  5. data/bin/vagrant +23 -0
  6. data/contrib/bash/completion.sh +13 -1
  7. data/lib/vagrant.rb +25 -0
  8. data/lib/vagrant/action.rb +5 -0
  9. data/lib/vagrant/action/builder.rb +145 -24
  10. data/lib/vagrant/action/builtin/box_add.rb +11 -4
  11. data/lib/vagrant/action/builtin/box_check_outdated.rb +12 -15
  12. data/lib/vagrant/action/builtin/cleanup_disks.rb +56 -0
  13. data/lib/vagrant/action/builtin/delayed.rb +26 -0
  14. data/lib/vagrant/action/builtin/disk.rb +52 -0
  15. data/lib/vagrant/action/builtin/handle_box.rb +2 -0
  16. data/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb +28 -9
  17. data/lib/vagrant/action/builtin/mixin_provisioners.rb +19 -1
  18. data/lib/vagrant/action/builtin/ssh_run.rb +21 -3
  19. data/lib/vagrant/action/builtin/trigger.rb +36 -0
  20. data/lib/vagrant/action/hook.rb +20 -2
  21. data/lib/vagrant/action/runner.rb +11 -26
  22. data/lib/vagrant/action/warden.rb +4 -18
  23. data/lib/vagrant/box_metadata.rb +17 -3
  24. data/lib/vagrant/bundler.rb +260 -53
  25. data/lib/vagrant/cli.rb +4 -2
  26. data/lib/vagrant/errors.rb +24 -0
  27. data/lib/vagrant/machine.rb +9 -6
  28. data/lib/vagrant/plugin/manager.rb +25 -14
  29. data/lib/vagrant/plugin/v2/command.rb +1 -1
  30. data/lib/vagrant/plugin/v2/manager.rb +53 -0
  31. data/lib/vagrant/plugin/v2/plugin.rb +1 -0
  32. data/lib/vagrant/plugin/v2/trigger.rb +64 -26
  33. data/lib/vagrant/shared_helpers.rb +28 -0
  34. data/lib/vagrant/ui.rb +50 -4
  35. data/lib/vagrant/util.rb +1 -0
  36. data/lib/vagrant/util/curl_helper.rb +8 -5
  37. data/lib/vagrant/util/downloader.rb +5 -1
  38. data/lib/vagrant/util/file_checksum.rb +6 -2
  39. data/lib/vagrant/util/guest_inspection.rb +9 -1
  40. data/lib/vagrant/util/io.rb +7 -27
  41. data/lib/vagrant/util/is_port_open.rb +1 -2
  42. data/lib/vagrant/util/map_command_options.rb +33 -0
  43. data/lib/vagrant/util/numeric.rb +69 -0
  44. data/lib/vagrant/util/platform.rb +8 -1
  45. data/plugins/commands/box/command/outdated.rb +14 -2
  46. data/plugins/commands/cloud/locales/en.yml +1 -1
  47. data/plugins/commands/cloud/publish.rb +1 -1
  48. data/plugins/commands/snapshot/command/save.rb +13 -8
  49. data/plugins/commands/ssh_config/command.rb +1 -1
  50. data/plugins/communicators/ssh/communicator.rb +18 -23
  51. data/plugins/communicators/winrm/config.rb +1 -1
  52. data/plugins/communicators/winrm/shell.rb +1 -1
  53. data/plugins/communicators/winssh/communicator.rb +126 -38
  54. data/plugins/communicators/winssh/config.rb +3 -7
  55. data/plugins/guests/alpine/cap/rsync.rb +1 -1
  56. data/plugins/guests/alpine/plugin.rb +16 -0
  57. data/plugins/guests/centos/cap/flavor.rb +24 -0
  58. data/plugins/guests/centos/guest.rb +9 -0
  59. data/plugins/guests/centos/plugin.rb +20 -0
  60. data/plugins/guests/darwin/cap/mount_vmware_shared_folder.rb +99 -13
  61. data/plugins/guests/darwin/plugin.rb +5 -0
  62. data/plugins/guests/debian/cap/configure_networks.rb +14 -6
  63. data/plugins/guests/linux/cap/halt.rb +9 -1
  64. data/plugins/guests/linux/cap/mount_smb_shared_folder.rb +16 -0
  65. data/plugins/guests/linux/cap/reboot.rb +48 -0
  66. data/plugins/guests/linux/plugin.rb +10 -0
  67. data/plugins/guests/redhat/cap/flavor.rb +3 -1
  68. data/plugins/guests/redhat/cap/nfs_client.rb +2 -2
  69. data/plugins/guests/redhat/cap/smb.rb +20 -0
  70. data/plugins/guests/redhat/plugin.rb +5 -0
  71. data/plugins/guests/suse/cap/change_host_name.rb +2 -2
  72. data/plugins/guests/windows/cap/public_key.rb +3 -3
  73. data/plugins/guests/windows/cap/reboot.rb +2 -1
  74. data/plugins/hosts/darwin/cap/nfs.rb +11 -0
  75. data/plugins/hosts/darwin/plugin.rb +5 -0
  76. data/plugins/hosts/linux/cap/nfs.rb +21 -2
  77. data/plugins/kernel_v2/config/disk.rb +199 -0
  78. data/plugins/kernel_v2/config/ssh_connect.rb +24 -0
  79. data/plugins/kernel_v2/config/vm.rb +109 -4
  80. data/plugins/kernel_v2/config/vm_provisioner.rb +4 -1
  81. data/plugins/kernel_v2/config/vm_trigger.rb +2 -5
  82. data/plugins/providers/docker/driver.rb +38 -10
  83. data/plugins/providers/docker/errors.rb +4 -0
  84. data/plugins/providers/docker/executor/local.rb +7 -1
  85. data/plugins/providers/hyperv/action/export.rb +4 -2
  86. data/plugins/providers/hyperv/driver.rb +10 -9
  87. data/plugins/providers/hyperv/scripts/set_vm_integration_services.ps1 +3 -3
  88. data/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 +6 -6
  89. data/plugins/providers/virtualbox/action.rb +2 -0
  90. data/plugins/providers/virtualbox/action/clean_machine_folder.rb +10 -1
  91. data/plugins/providers/virtualbox/action/export.rb +4 -2
  92. data/plugins/providers/virtualbox/action/import.rb +8 -4
  93. data/plugins/providers/virtualbox/action/prepare_clone_snapshot.rb +4 -2
  94. data/plugins/providers/virtualbox/action/snapshot_delete.rb +4 -2
  95. data/plugins/providers/virtualbox/action/snapshot_restore.rb +4 -2
  96. data/plugins/providers/virtualbox/cap/cleanup_disks.rb +54 -0
  97. data/plugins/providers/virtualbox/cap/configure_disks.rb +287 -0
  98. data/plugins/providers/virtualbox/cap/validate_disk_ext.rb +27 -0
  99. data/plugins/providers/virtualbox/driver/base.rb +15 -0
  100. data/plugins/providers/virtualbox/driver/meta.rb +14 -2
  101. data/plugins/providers/virtualbox/driver/version_5_0.rb +142 -2
  102. data/plugins/providers/virtualbox/driver/version_6_1.rb +39 -0
  103. data/plugins/providers/virtualbox/plugin.rb +21 -0
  104. data/plugins/provisioners/ansible/cap/guest/alpine/ansible_install.rb +44 -0
  105. data/plugins/provisioners/ansible/cap/guest/arch/ansible_install.rb +20 -3
  106. data/plugins/provisioners/ansible/cap/guest/debian/ansible_install.rb +4 -5
  107. data/plugins/provisioners/ansible/cap/guest/fedora/ansible_install.rb +2 -2
  108. data/plugins/provisioners/ansible/cap/guest/freebsd/ansible_install.rb +2 -2
  109. data/plugins/provisioners/ansible/cap/guest/pip/pip.rb +8 -4
  110. data/plugins/provisioners/ansible/cap/guest/redhat/ansible_install.rb +2 -2
  111. data/plugins/provisioners/ansible/cap/guest/suse/ansible_install.rb +2 -1
  112. data/plugins/provisioners/ansible/cap/guest/ubuntu/ansible_install.rb +3 -3
  113. data/plugins/provisioners/ansible/plugin.rb +5 -0
  114. data/plugins/provisioners/ansible/provisioner/base.rb +1 -1
  115. data/plugins/provisioners/container/client.rb +203 -0
  116. data/plugins/provisioners/container/config.rb +83 -0
  117. data/plugins/provisioners/container/installer.rb +13 -0
  118. data/plugins/provisioners/container/plugin.rb +23 -0
  119. data/plugins/provisioners/container/provisioner.rb +28 -0
  120. data/plugins/provisioners/docker/cap/{redhat → centos}/docker_install.rb +10 -7
  121. data/plugins/provisioners/docker/cap/centos/docker_start_service.rb +24 -0
  122. data/plugins/provisioners/docker/client.rb +4 -175
  123. data/plugins/provisioners/docker/config.rb +2 -72
  124. data/plugins/provisioners/docker/installer.rb +3 -5
  125. data/plugins/provisioners/docker/plugin.rb +6 -6
  126. data/plugins/provisioners/docker/provisioner.rb +4 -10
  127. data/plugins/provisioners/podman/cap/centos/podman_install.rb +35 -0
  128. data/plugins/provisioners/podman/cap/linux/podman_installed.rb +13 -0
  129. data/plugins/provisioners/podman/cap/redhat/podman_install.rb +26 -0
  130. data/plugins/provisioners/podman/client.rb +12 -0
  131. data/plugins/provisioners/podman/config.rb +28 -0
  132. data/plugins/provisioners/podman/installer.rb +33 -0
  133. data/plugins/provisioners/podman/plugin.rb +38 -0
  134. data/plugins/provisioners/podman/provisioner.rb +52 -0
  135. data/plugins/provisioners/salt/provisioner.rb +4 -0
  136. data/plugins/provisioners/shell/config.rb +1 -6
  137. data/plugins/provisioners/shell/provisioner.rb +54 -25
  138. data/plugins/synced_folders/smb/synced_folder.rb +1 -1
  139. data/templates/commands/init/Vagrantfile.erb +1 -1
  140. data/templates/locales/en.yml +123 -4
  141. data/templates/locales/providers_docker.yml +2 -0
  142. data/templates/nfs/exports_darwin.erb +7 -0
  143. data/vagrant.gemspec +8 -9
  144. data/version.txt +1 -1
  145. metadata +3731 -3663
  146. data/lib/vagrant/action/builtin/after_trigger.rb +0 -31
  147. data/lib/vagrant/action/builtin/before_trigger.rb +0 -28
  148. data/plugins/provisioners/docker/cap/redhat/docker_start_service.rb +0 -16
@@ -1,3 +1,5 @@
1
+ require_relative "../container/provisioner"
2
+
1
3
  require_relative "client"
2
4
  require_relative "installer"
3
5
 
@@ -7,17 +9,16 @@ module VagrantPlugins
7
9
  error_namespace("vagrant.provisioners.docker")
8
10
  end
9
11
 
10
- class Provisioner < Vagrant.plugin("2", :provisioner)
12
+ class Provisioner < VagrantPlugins::ContainerProvisioner::Provisioner
11
13
  def initialize(machine, config, installer = nil, client = nil)
12
14
  super(machine, config)
13
15
 
14
16
  @installer = installer || Installer.new(@machine)
15
17
  @client = client || Client.new(@machine)
18
+ @logger = Log4r::Logger.new("vagrant::provisioners::docker")
16
19
  end
17
20
 
18
21
  def provision
19
- @logger = Log4r::Logger.new("vagrant::provisioners::docker")
20
-
21
22
  @logger.info("Checking for Docker installation...")
22
23
  if @installer.ensure_installed
23
24
  if !config.post_install_provisioner.nil?
@@ -50,13 +51,6 @@ module VagrantPlugins
50
51
  end
51
52
  end
52
53
 
53
- def run_provisioner(env)
54
- klass = Vagrant.plugin("2").manager.provisioners[env[:provisioner].type]
55
- result = klass.new(env[:machine], env[:provisioner].config)
56
- result.config.finalize!
57
-
58
- result.provision
59
- end
60
54
  end
61
55
  end
62
56
  end
@@ -0,0 +1,35 @@
1
+ module VagrantPlugins
2
+ module PodmanProvisioner
3
+ module Cap
4
+ module Centos
5
+ module PodmanInstall
6
+ def self.podman_install(machine, kubic)
7
+ if kubic
8
+ # Official install instructions for podman
9
+ # https://podman.io/getting-started/installation.html
10
+ case machine.guest.capability("flavor")
11
+ when :centos_7
12
+ machine.communicate.tap do |comm|
13
+ comm.sudo("curl -L -o /etc/yum.repos.d/devel:kubic:libcontainers:stable.repo https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_7/devel:kubic:libcontainers:stable.repo")
14
+ comm.sudo("yum -q -y install podman")
15
+ end
16
+ when :centos_8
17
+ machine.communicate.tap do |comm|
18
+ comm.sudo("dnf -y module disable container-tools &> /dev/null || echo 'container-tools module does not exist'")
19
+ comm.sudo("dnf -y install 'dnf-command(copr)'")
20
+ comm.sudo("dnf -y copr enable rhcontainerbot/container-selinux")
21
+ comm.sudo("curl -L -o /etc/yum.repos.d/devel:kubic:libcontainers:stable.repo https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_8/devel:kubic:libcontainers:stable.repo")
22
+ comm.sudo("dnf -y install podman")
23
+ end
24
+ end
25
+ else
26
+ machine.communicate.tap do |comm|
27
+ comm.sudo("yum -q -y install podman")
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,13 @@
1
+ module VagrantPlugins
2
+ module PodmanProvisioner
3
+ module Cap
4
+ module Linux
5
+ module PodmanInstalled
6
+ def self.podman_installed(machine)
7
+ machine.communicate.test("command -v podman")
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,26 @@
1
+ module VagrantPlugins
2
+ module PodmanProvisioner
3
+ module Cap
4
+ module Redhat
5
+ module PodmanInstall
6
+ def self.podman_install(machine, kubic)
7
+ # Official install instructions for podman
8
+ # https://podman.io/getting-started/installation.html
9
+ case machine.guest.capability("flavor")
10
+ when :rhel_7
11
+ machine.communicate.tap do |comm|
12
+ comm.sudo("subscription-manager repos --enable=rhel-7-server-extras-rpms")
13
+ comm.sudo("yum -q -y install podman")
14
+ end
15
+ when :rhel_8
16
+ machine.communicate.tap do |comm|
17
+ comm.sudo("yum module enable -y container-tools")
18
+ comm.sudo("yum module install -y container-tools")
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,12 @@
1
+ require_relative "../container/client"
2
+
3
+ module VagrantPlugins
4
+ module PodmanProvisioner
5
+ class Client < VagrantPlugins::ContainerProvisioner::Client
6
+ def initialize(machine)
7
+ super(machine, "podman")
8
+ @container_command = "podman"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,28 @@
1
+ require_relative "../container/config"
2
+
3
+ module VagrantPlugins
4
+ module PodmanProvisioner
5
+ class Config < VagrantPlugins::ContainerProvisioner::Config
6
+ attr_accessor :kubic
7
+
8
+ def initialize
9
+ super()
10
+ @kubic = UNSET_VALUE
11
+ end
12
+
13
+ def finalize!
14
+ super()
15
+ @kubic = false if @kubic == UNSET_VALUE
16
+ end
17
+
18
+ def post_install_provision(name, **options, &block)
19
+ # Abort
20
+ raise PodmanError, :wrong_provisioner if options[:type] == "podman"
21
+
22
+ proxy = VagrantPlugins::Kernel_V2::VMConfig.new
23
+ proxy.provision(name, **options, &block)
24
+ @post_install_provisioner = proxy.provisioners.first
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,33 @@
1
+ require_relative "../container/installer"
2
+
3
+ module VagrantPlugins
4
+ module PodmanProvisioner
5
+ class Installer < VagrantPlugins::ContainerProvisioner::Installer
6
+ # This handles verifying the Podman installation, installing it if it was
7
+ # requested, and so on. This method will raise exceptions if things are
8
+ # wrong.
9
+ # @params [Boolean] - if true install should use kubic project (this will)
10
+ # add a yum repo.
11
+ # if false install comes from default yum
12
+ # @return [Boolean] - false if podman cannot be detected on machine, else
13
+ # true if podman installs correctly or is installed
14
+ def ensure_installed(kubic)
15
+ if !@machine.guest.capability?(:podman_installed)
16
+ @machine.ui.warn("Podman can not be installed")
17
+ return false
18
+ end
19
+
20
+ if !@machine.guest.capability(:podman_installed)
21
+ @machine.ui.detail("Podman installing")
22
+ @machine.guest.capability(:podman_install, kubic)
23
+ end
24
+
25
+ if !@machine.guest.capability(:podman_installed)
26
+ raise PodmanError, :install_failed
27
+ end
28
+
29
+ true
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,38 @@
1
+ require "vagrant"
2
+
3
+ module VagrantPlugins
4
+ module PodmanProvisioner
5
+ class Plugin < Vagrant.plugin("2")
6
+ name "podman"
7
+ description <<-DESC
8
+ Provides support for provisioning your virtual machines with
9
+ OCI images and containers using Podman.
10
+ DESC
11
+
12
+ config(:podman, :provisioner) do
13
+ require_relative "config"
14
+ Config
15
+ end
16
+
17
+ guest_capability("redhat", "podman_install") do
18
+ require_relative "cap/redhat/podman_install"
19
+ Cap::Redhat::PodmanInstall
20
+ end
21
+
22
+ guest_capability("centos", "podman_install") do
23
+ require_relative "cap/centos/podman_install"
24
+ Cap::Centos::PodmanInstall
25
+ end
26
+
27
+ guest_capability("linux", "podman_installed") do
28
+ require_relative "cap/linux/podman_installed"
29
+ Cap::Linux::PodmanInstalled
30
+ end
31
+
32
+ provisioner(:podman) do
33
+ require_relative "provisioner"
34
+ Provisioner
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,52 @@
1
+ require_relative "../container/provisioner"
2
+
3
+ require_relative "installer"
4
+ require_relative "client"
5
+
6
+ module VagrantPlugins
7
+ module PodmanProvisioner
8
+ class PodmanError < Vagrant::Errors::VagrantError
9
+ error_namespace("vagrant.provisioners.podman")
10
+ end
11
+
12
+ class Provisioner < VagrantPlugins::ContainerProvisioner::Provisioner
13
+ def initialize(machine, config, installer = nil, client = nil)
14
+ super(machine, config, installer, client)
15
+
16
+ @installer = installer || Installer.new(@machine)
17
+ @client = client || Client.new(@machine)
18
+ @logger = Log4r::Logger.new("vagrant::provisioners::podman")
19
+ end
20
+
21
+ def provision
22
+ @logger.info("Checking for Podman installation...")
23
+
24
+ if @installer.ensure_installed(config.kubic)
25
+ if !config.post_install_provisioner.nil?
26
+ @logger.info("Running post setup provision script...")
27
+ env = {
28
+ callable: method(:run_provisioner),
29
+ provisioner: config.post_install_provisioner,
30
+ machine: machine}
31
+ machine.env.hook(:run_provisioner, env)
32
+ end
33
+ end
34
+
35
+ if config.images.any?
36
+ @machine.ui.info(I18n.t("vagrant.docker_pulling_images"))
37
+ @client.pull_images(*config.images)
38
+ end
39
+
40
+ if config.build_images.any?
41
+ @machine.ui.info(I18n.t("vagrant.docker_building_images"))
42
+ @client.build_images(config.build_images)
43
+ end
44
+
45
+ if config.containers.any?
46
+ @machine.ui.info(I18n.t("vagrant.docker_starting_containers"))
47
+ @client.run(config.containers)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -158,6 +158,10 @@ module VagrantPlugins
158
158
  options = "%s -N" % options
159
159
  end
160
160
 
161
+ if @config.python_version && @machine.config.vm.communicator != :winrm
162
+ options = "%s -x python%s" % [options, @config.python_version]
163
+ end
164
+
161
165
  if @config.install_type && @machine.config.vm.communicator != :winrm
162
166
  options = "%s %s" % [options, @config.install_type]
163
167
  end
@@ -55,7 +55,7 @@ module VagrantPlugins
55
55
  @sha384 = nil if @sha384 == UNSET_VALUE
56
56
  @sha512 = nil if @sha512 == UNSET_VALUE
57
57
  @env = {} if @env == UNSET_VALUE
58
- @upload_path = "/tmp/vagrant-shell" if @upload_path == UNSET_VALUE
58
+ @upload_path = nil if @upload_path == UNSET_VALUE
59
59
  @privileged = true if @privileged == UNSET_VALUE
60
60
  @binary = false if @binary == UNSET_VALUE
61
61
  @keep_color = false if @keep_color == UNSET_VALUE
@@ -109,11 +109,6 @@ module VagrantPlugins
109
109
  errors << I18n.t("vagrant.provisioners.shell.env_must_be_a_hash")
110
110
  end
111
111
 
112
- # There needs to be a path to upload the script to
113
- if !upload_path
114
- errors << I18n.t("vagrant.provisioners.shell.upload_path_not_set")
115
- end
116
-
117
112
  if !args_valid?
118
113
  errors << I18n.t("vagrant.provisioners.shell.args_bad_type")
119
114
  end
@@ -9,6 +9,8 @@ module VagrantPlugins
9
9
  class Provisioner < Vagrant.plugin("2", :provisioner)
10
10
  include Vagrant::Util::Retryable
11
11
 
12
+ DEFAULT_WINDOWS_SHELL_EXT = ".ps1".freeze
13
+
12
14
  def provision
13
15
  args = ""
14
16
  if config.args.is_a?(String)
@@ -38,6 +40,27 @@ module VagrantPlugins
38
40
  end
39
41
  end
40
42
 
43
+ def upload_path
44
+ if !defined?(@_upload_path)
45
+ case @machine.config.vm.guest
46
+ when :windows
47
+ @_upload_path = Vagrant::Util::Platform.unix_windows_path(config.upload_path.to_s)
48
+ else
49
+ @_upload_path = config.upload_path.to_s
50
+ end
51
+
52
+ if @_upload_path.empty?
53
+ case @machine.config.vm.guest
54
+ when :windows
55
+ @_upload_path = "C:/tmp/vagrant-shell"
56
+ else
57
+ @_upload_path = "/tmp/vagrant-shell"
58
+ end
59
+ end
60
+ end
61
+ @_upload_path
62
+ end
63
+
41
64
  protected
42
65
 
43
66
  # This handles outputting the communication data back to the UI
@@ -63,10 +86,10 @@ module VagrantPlugins
63
86
  env = config.env.map { |k,v| "#{k}=#{quote_and_escape(v.to_s)}" }
64
87
  env = env.join(" ")
65
88
 
66
- command = "chmod +x '#{config.upload_path}'"
89
+ command = "chmod +x '#{upload_path}'"
67
90
  command << " &&"
68
91
  command << " #{env}" if !env.empty?
69
- command << " #{config.upload_path}#{args}"
92
+ command << " #{upload_path}#{args}"
70
93
 
71
94
  with_script_file do |path|
72
95
  # Upload the script to the machine
@@ -79,10 +102,10 @@ module VagrantPlugins
79
102
  end
80
103
 
81
104
  user = info[:username]
82
- comm.sudo("chown -R #{user} #{config.upload_path}",
105
+ comm.sudo("chown -R #{user} #{upload_path}",
83
106
  error_check: false)
84
107
 
85
- comm.upload(path.to_s, config.upload_path)
108
+ comm.upload(path.to_s, upload_path)
86
109
 
87
110
  if config.name
88
111
  @machine.ui.detail(I18n.t("vagrant.provisioners.shell.running",
@@ -113,22 +136,28 @@ module VagrantPlugins
113
136
  with_script_file do |path|
114
137
  # Upload the script to the machine
115
138
  @machine.communicate.tap do |comm|
116
- env = config.env.map{|k,v| comm.generate_environment_export(k, v)}.join
117
- upload_path = config.upload_path.to_s
118
- if File.extname(upload_path).empty?
119
- remote_ext = @machine.config.winssh.shell == "powershell" ? "ps1" : "bat"
120
- upload_path << ".#{remote_ext}"
139
+ env = config.env.map{|k,v| comm.generate_environment_export(k, v)}.join(';')
140
+
141
+ remote_ext = File.extname(upload_path.to_s)
142
+ if remote_ext.empty?
143
+ remote_ext = File.extname(path.to_s)
144
+ if remote_ext.empty?
145
+ remote_ext = @machine.config.winssh.shell == "cmd" ? ".bat" : ".ps1"
146
+ end
121
147
  end
122
- if remote_ext == "ps1"
148
+
149
+ remote_path = add_extension(upload_path, remote_ext)
150
+
151
+ if remote_ext == ".bat"
152
+ command = "#{env}\n cmd.exe /c \"#{remote_path}\" #{args}"
153
+ else
123
154
  # Copy powershell_args from configuration
124
155
  shell_args = config.powershell_args
125
156
  # For PowerShell scripts bypass the execution policy unless already specified
126
157
  shell_args += " -ExecutionPolicy Bypass" if config.powershell_args !~ /[-\/]ExecutionPolicy/i
127
158
  # CLIXML output is kinda useless, especially on non-windows hosts
128
159
  shell_args += " -OutputFormat Text" if config.powershell_args !~ /[-\/]OutputFormat/i
129
- command = "#{env}\npowershell #{shell_args} #{upload_path}#{args}"
130
- else
131
- command = "#{env}\n#{upload_path}#{args}"
160
+ command = "#{env}\npowershell #{shell_args} -file \"#{remote_path}\"#{args}"
132
161
  end
133
162
 
134
163
  # Reset upload path permissions for the current ssh user
@@ -137,8 +166,8 @@ module VagrantPlugins
137
166
  info = @machine.ssh_info
138
167
  raise Vagrant::Errors::SSHNotReady if info.nil?
139
168
  end
140
-
141
- comm.upload(path.to_s, upload_path)
169
+
170
+ comm.upload(path.to_s, remote_path)
142
171
 
143
172
  if config.name
144
173
  @machine.ui.detail(I18n.t("vagrant.provisioners.shell.running",
@@ -154,7 +183,7 @@ module VagrantPlugins
154
183
  # Execute it with sudo
155
184
  comm.execute(
156
185
  command,
157
- sudo: config.privileged,
186
+ shell: :powershell,
158
187
  error_key: :ssh_bad_exit_status_muted
159
188
  ) do |type, data|
160
189
  handle_comm(type, data)
@@ -174,20 +203,17 @@ module VagrantPlugins
174
203
  @machine.communicate.tap do |comm|
175
204
  # Make sure that the upload path has an extension, since
176
205
  # having an extension is critical for Windows execution
177
- upload_path = config.upload_path.to_s
178
- if File.extname(upload_path) == ""
179
- upload_path += File.extname(path.to_s)
180
- end
206
+ winrm_upload_path = add_extension(upload_path, DEFAULT_WINDOWS_SHELL_EXT)
181
207
 
182
208
  # Upload it
183
- comm.upload(path.to_s, upload_path)
209
+ comm.upload(path.to_s, winrm_upload_path)
184
210
 
185
211
  # Build the environment
186
212
  env = config.env.map { |k,v| "$env:#{k} = #{quote_and_escape(v.to_s)}" }
187
213
  env = env.join("; ")
188
214
 
189
215
  # Calculate the path that we'll be executing
190
- exec_path = upload_path
216
+ exec_path = winrm_upload_path
191
217
  exec_path.gsub!('/', '\\')
192
218
  exec_path = "c:#{exec_path}" if exec_path.start_with?("\\")
193
219
 
@@ -236,6 +262,11 @@ module VagrantPlugins
236
262
  "#{quote}#{text.gsub(/#{quote}/) { |m| "#{m}\\#{m}#{m}" }}#{quote}"
237
263
  end
238
264
 
265
+ def add_extension(path, ext)
266
+ return path if !File.extname(path.to_s).empty?
267
+ path + ext
268
+ end
269
+
239
270
  # This method yields the path to a script to upload and execute
240
271
  # on the remote server. This method will properly clean up the
241
272
  # script file if needed.
@@ -269,14 +300,12 @@ module VagrantPlugins
269
300
  ext = File.extname(config.path)
270
301
  script = Pathname.new(config.path).expand_path(root_path).read
271
302
  else
272
- # The script is just the inline code...
273
- ext = ".ps1"
274
303
  script = config.inline
275
304
  end
276
305
 
277
306
  # Replace Windows line endings with Unix ones unless binary file
278
307
  # or we're running on Windows.
279
- if !config.binary && @machine.config.vm.communicator != :winrm
308
+ if !config.binary && @machine.config.vm.guest != :windows
280
309
  begin
281
310
  script = script.gsub(/\r\n?$/, "\n")
282
311
  rescue ArgumentError