Please note that the Vagrant issue tracker is reserved for bug reports and
enhancements. For general usage questions, please use the Vagrant mailing list:
https://groups.google.com/forum/#!forum/vagrant-up. Thank you!
2.1.1
Windows 10
Amazon Linux
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.ssh.insert_key = false
# ssite
config.vm.define "site" do |site|
site.vm.box = "winky/amazonlinux-2"
site.vm.hostname ="site"
site.vm.network "private_network", ip: "192.168.51.11"
site.vm.synced_folder "src/", "/srv/www/site", type: "virtualbox", create: true, group: "ec2-user", owner: "ec2-user"
site.vm.provider "virtualbox" do |vb|
vb.name = "site"
vb.customize ["modifyvm", :id, "--memory", "512"]
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
end
site.vm.provision "shell" do |s|
s.path = "scripts/provision.sh"
end
end
config.trigger.after :provision do |trigger|
trigger.run_remote = {inline: "cd /vagrant && sudo npm run debug"}
end
end
https://gist.github.com/Renari/07358cd52394b5e2f6cd80d26d66d030
What should have happened?
cd /vagrant && sudo npm run debug should have run at the end of the provision, thus starting the application.
What actually happened?
The application did not start, requiring me to ssh into the machine and start it myself.
vagrant upHi @Renari - this looks like a bug to me. I've labeled it as such and dropped it into our next milestone to be fixed. Thanks for reporting the issue!
Oh wait @Renari - apologies. I believe this is a misunderstanding for what the trigger command key is about. This works, however it's expected to run _after_ the provision command, not the provision step in vagrant up. If you run vagrant provision, you'll see that your defined trigger runs after. If you simply want that command to run after your machine has been brought up, then the trigger should be config.trigger.after :up. Thanks!
We are planning on supporting triggers that can be injected in the Vagrant lifecycle, but for the moment the command keys expected are around specified commands.
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.
Most helpful comment
Oh wait @Renari - apologies. I believe this is a misunderstanding for what the trigger command key is about. This works, however it's expected to run _after_ the
provisioncommand, not the provision step invagrant up. If you runvagrant provision, you'll see that your defined trigger runs after. If you simply want that command to run after your machine has been brought up, then the trigger should beconfig.trigger.after :up. Thanks!We are planning on supporting triggers that can be injected in the Vagrant lifecycle, but for the moment the command keys expected are around specified commands.