Vagrant execute script or command after every guest restart (vagrant up)

you can use run: 'always'

config.vm.provision :shell, path: "vagrant/bootstrap.sh", run: 'always'

This will make sure your command are executed every time your VM is starting (vagrant up or vagrant reload)

If you need only certain commands to be always run, you can split your script

config.vm.provision :shell, path: "vagrant/bootstrap1.sh"
config.vm.provision :shell, path: "vagrant/bootstrap2.sh", run: 'always'
config.vm.provision :shell, path: "vagrant/bootstrap3.sh"

script will be run in order, bootstrap1 then 2 then 3 when the machine is first provisioned

any further time you run vagrant up (or reload) only bootstrap2 will be run

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)