hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.26k stars 4.43k forks source link

vagrant file provisioner must not check for file existence when using vagrant destroy #11569

Open rgl opened 4 years ago

rgl commented 4 years ago

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

  1. vagrant destroy
tomadimitrie commented 1 month ago

Any updates on this?