-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple provisioning scripts always runs the first script on Windows #7614
Comments
Hi @chingc Thank you for opening an issue. This seems rather odd. Can you please share the debug output? |
Thanks for getting back to me so quickly @sethvargo Here's the debug output. |
And can you please supply your complete Vagrantfile? |
Here you go: Vagrantfile |
I'm seeing this same thing. If I manage to delete the C:\tmp\vagrant-shell.ps1 before any of the succeeding scripts can run, it will run the correct script. It appears to have something to do with overwriting the existing vagrant-shell.ps1 file. |
Your loop is what is causing the issue, there is a warning in the documentation about the evaluation order. You will probably want to simply upload a directory of scripts and trigger a "scheduler" script to run them if you need a specific order. |
I'm not concerned about the order. The problem is it's running the same script repeatedly even though the stdout status messages are indicating otherwise. |
Ching, I'm seeing this same thing, but I noticed that it's only occurring On Wed, Aug 10, 2016 at 12:04 PM, Ching Chow notifications@github.com
|
@bl4ckcontact I was using the Windows 7 IE 11 Vagrant image from modern.ie. |
I'm hitting the same issue on Vagrant 1.8.5 on OSX El Capitan while provisioning a Windows 2008 R2 box using VirtualBox. I'm not using any loops, just simple shell calls running a script. My VagrantFile:
My output:
Some things I tried:
Based on what I've seen there is definitely an issue overwriting existing vagrant-shell.bat files. As a workaround, you can manually remove the vagrant-shell.bat file before running another script and it should run successfully. |
@jbarnett-r7 I think your issue is similar to #7615 as you are rebooting and Vagrant is going to detect that the first script is there and not re-upload. I'd say try the same tactic I advised earlier, upload a folder of files and then trigger those scripts from the shell provisioner, and if you required a reboot you'll need to drop a "script done" flag so that it doesn't re-run them on the next provision. A fix for Vagrant might be to upload all of the scripts at once to a known location and trigger them in a predictable/requested order instead of reusing the same script name for each upload and execution. |
@dragon788 They could be related. I do want to mention that I see the same behavior without the reboot. The reboot actually helps me move past some other failures I was seeing after running the first script. Basically that first script installs chocolatey. The next script uses chocolatey to install a package. The second script was failing because it was saying chocolatey wasn't installed. The reload was a workaround to force me to get a new shell which had the updated PATH variable containing chocolatey. Is it intended behavior that each config.vm.provision :shell call uses the shell that existed before? I feel like each should be run as a separate process to avoid collisions like this. Or maybe this is a change/regression? This tutorial from a year ago addresses the same issue and specifically mentions that you need to run the chocolatey installs in a separate provision line to prevent the behavior I'm seeing: http://digitaldrummerj.me//vagrant-installing-boxstarter/ Sorry for the information dump. These issues have been plaguing me for multiple weeks now and I feel like I'm just going from workaround to workaround. |
Can confirm this happens to me on first boot as well. I will attempt mounting a folder with the scripts and try executing them and report back. |
I think it is a Windows failing that updating the running environment is a nightmare, and the only way to really do it is to restart explorer.exe. What I found really helped was building my own base box from https://github.com/mwrock/packer-templates which includes Boxstarter/Chocolatey and makes it much easier to just bring a VM up and apply the tasty Chocolatey sauce. I do like your idea of an inline provisioner that you could define with a script block at the top of the Vagrantfile and then just reuse in between each call to ensure that it must run the script, though you'd want to make sure your scripts are idempotent so it doesn't keep flip flopping if you vagrant provision a few times. |
I'm seeing the same behavior on Windows 7 Ultimate. When using multiple batch scripts specified by path for provisioning, whichever the first one vagrant runs is run for all of the defined shell script provisioners. Seems like 1.bat
2.bat
Vagrantfile snippet
Output:
|
I just tested this on the recently released 1.8.6 and am still seeing the same behavior:
I am still testing against Windows 2008 R2. I had to add the hack (manually delete the C:\tmp\vagrant-shell.bat file after each provisioning script) back in to get things to work properly. |
Came across this issue myself with a Windows 2008R2 box. An easy fix was to simply supply an upload path for the scripts like so: config.vm.provision "script_a", type: "shell" do |s|
s.path = "scripts/script_a.bat"
s.upload_path = "C:\\tmp\\script_a.bat"
end
config.vm.provision "script_b", type: "shell" do |s|
s.path = "scripts/script_b.bat"
s.upload_path = "C:\\tmp\\script_b.bat"
end This issue plus other WinRM issues had us stuck on Vagrant 1.8.1, hopefully others with this issue can upgrade if they are able to use |
I have the same issue. The first powershell provisioner works, then every other provisioner runs the first script again. Relevant debug output:
The
|
Here's a generic workaround so you don't have to add an
|
I am hitting this as well, providing my info (originally reported as dupe at GH-7971): Vagrant versionVagrant 1.8.7 Host operating systemmacOS 10.12.1 (16B2555) Guest operating systemWindows 7 Pro x32 Czech FPP VagrantfileVagrant.configure(2) do |config|
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true
# Customize the amount of memory on the VM:
vb.memory = "2048"
# Add sound card (for synthesized speech)
vb.customize ["modifyvm", :id, '--audio', 'coreaudio', '--audiocontroller', 'hda']
# Clipboard sync (copying text is often needed)
vb.customize ["modifyvm", :id, '--clipboard', 'bidirectional']
end
config.vm.define "linux", autostart: false do |linux|
...
end
config.vm.define "win" do |win|
win.vm.box = ENV['VAGRANT_BOX_WIN'] || "someusername/win7x86-pro-cz"
win.vm.boot_timeout = 15*60 # user interaction is required on first boot
# set up provisioning prerequisities
win.vm.provision "shell", path: "vagrant/fixnetwork.ps1" # strangely, network gets randomly set to Public on first box boot
win.vm.provision "file", source: "vagrant/provutils.psm1", destination: "Documents/WindowsPowerShell/Modules/provutils/provutils.psm1"
win.vm.provision "shell", path: "vagrant/sharedfolder.cmd"
# now for the real work:
win.vm.provision "shell", path: "vagrant/desktop.ps1"
win.vm.provision "shell", path: "vagrant/bash.ps1"
win.vm.provision "shell", path: "vagrant/choco.ps1"
win.vm.provision "shell", path: "vagrant/java.ps1"
win.vm.provision :reload
end
end Debug outputhttps://gist.github.com/dusek/42617c076a582b2a4fed2c26e11a954f Expected behaviorThese scripts should run in sequence:
Actual behaviorWhat actually happened?
Steps to reproduce
Notes
References
|
I'm having the same issue with OS X Yosemite (host), Win 7 (guest), Vagrant (1.8.7), VirtualBox 5.1.8. One additional thing that I didn't see mentioned is that if you repackage or box the VM and it still has a script file that was uploaded to |
Hi there, It looks like this has been resolved within a previously shipped version of Vagrant so I am now closing this issue. If the original issue was not fully resolved, please reopen this issue or create a new one. Cheers! |
Same issue no clue it always runs the first $script on both nodes. $script = <<SCRIPT $script1 = <<SCRIPT Vagrant.configure("2") do |config|
end |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
I'm running vagrant 1.8.4 on OS X El Capitan, and I'm trying to run provisioning scripts on a IE11 Windows 7 VM downloaded from Modern.IE.
I've ran into a problem where it appears that if you attempt to run multiple provisioning scripts it will just repeatedly run the first script it finds. This doesn't happen on a Linux guest.
For example...
Provisioning Scripts
provision/greet_1.bat
provision/greet_2.bat
Vagrantfile
Output
Expected behavior
greet_2.bat
should have echoed WorldActual behavior
Output indicates
greet_2.bat
is running but clearlygreet_1.bat
is being re-run somehow.This problem doesn't happen on a Linux guest.
Workaround
Combine multiple scripts into one.
Gist
Debug Output
Vagrantfile
The text was updated successfully, but these errors were encountered: