Open survivant opened 3 years ago
but If I create a empty file vagrant up the validation will passed but the file will be empty on the vm :(
Hey there, thanks for opening up an issue. This is expected Vagrant behavior. config.trigger.before :provision do |trigger|
will get triggered when a vagrant provision
command is run.
You might want to use typed triggers instead to run those triggers on every provisioning action. Or, config.trigger.before :up do |trigger|
but my problem is also.. why the destination file must exists ?
The destination file does not need to exist, only the source file. If you have a scenario where the destination file must exist, could you share a debug log and the associated Vagrantfile. I could not reproduce that situation with the Vagrantfile in the original issue report.
yep.. it will works with before: up
finally .. the issue is still there for me. The source must be present. There is a way to tell Vagrant to not validate a provision command ?
# generate files for provisionning at startup
config.trigger.before :up do |trigger|
trigger.info = "init script before provisionning"
trigger.run = {inline: "provision/preparing-provision.ps1"}
end
# copy SMB files to all VMs and mount folder
config.vm.provision "file", source: "provision/generated/host-localip", destination: "/home/vagrant/host-localip"
here my usecase. When I do : vagrant up
there is a script that will run locally (preparing-provision.ps1). That script will remove the folder provision/generated and recreate the file : provision/generated/host-localip
so when I first start the folder generated will not exists. Vagrant will give me the error :
PS F:\junk\tutoriel\03-createvm-fixed-ip-provisionning> vagrant up
There are errors in the configuration of this machine. Please fix
the following errors and try again:
File provisioner:
* File upload source file F:/junk/tutoriel/03-createvm-fixed-ip-provisionning/provision/generated/host-localip must exist
PS F:\junk\tutoriel\03-createvm-fixed-ip-provisionning>
There is a way to tell Vagrant to not validate a provision command ?
No. Vagrant will always try to validate provisioners. I don't think this is likely to change.
One option is to manually create the file provision/generated/host-localip
initially. Or, since the Vagrantfile is Ruby you can add a little snippet like
File.write("#{Dir.pwd}/provision/generated/host-localip", "")
Vagrant.configure("2") do |config|
...
end
I have this scenario. I will create VM and provision them.
but I'll generate a file in the BEFORE -PROVISION STEP. the file doesn't exist yet, but it will before the provisionning.
I have a validation error when I do