vagrant
vagrant copied to clipboard
vagrant file provisioner must not check for file existence when using vagrant destroy
Vagrant version
2.2.7
Vagrantfile
This creates a file in the before up trigger, so the file will only be available after the trigger runs.
Vagrant.configure(2) do |config|
config.vm.box = 'esxi-6.7-amd64'
config.vm.hostname = 'esxi.test'
...
# create the management certificate that will be used to access the esxi
# management web interface (hostd).
config.trigger.before :up do |trigger|
trigger.run = {
inline: "bash provision-certificate.sh #{config.vm.hostname}"
}
end
config.vm.provision :file, source: "shared/tls/example-esxi-ca/#{config.vm.hostname}", destination: '/tmp/tls'
end
Expected behavior
the file provisioner should only check for file existence when it actually runs or when vagrant is provisioning (e.g. in a vagrant up execution).
actually, neither the other provisioners (e.g. shell) should.
Actual behavior
a vagrant destroy should not fail because a file referenced in a file provisioner does not exist.
Steps to reproduce
- vagrant destroy
Any updates on this?