4

I'm using vagrant to stand up some development environments. I have vagrant create a synced folder on the host machine. I have chef git-clone a project into the corresponding folder on the guest machine. This project then obviously appears in the synced folder on the host machine. All good...

However, if I need to destroy the vagrant instance, the synced folder and project still exists on the host machine. I find it best to delete this folder before I vagrant up again to avoid unexpectedly altering the freshly cloned project. Of course, I often forget to do this and it wastes a lot of time.

My question: Can and how do I configure vagrant to delete the synced folder on the host machine when I execute vagrant up?

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
nat
  • 43
  • 4

1 Answers1

1

Vagrantfile is basically a piece of Ruby code, so you can put a quite complicated logic there. This answer shows how command line arguments can be obtained in the file so you can execute some deletion actions only during vagrant up process.

But I would recommend you to install vagrant-triggers plugin and use it.

Community
  • 1
  • 1
Konstantin
  • 24,271
  • 5
  • 48
  • 65