Vagrant cheat sheet

Vagrant cheat sheet

A quick overview of the most useful vagrant commands.

Hint: “ve” means vagrant environment – the virtual machine(s) you run.

CommandRemark
vagrant upstart ve
vagrant haltstop ve
vagrant reloadreload Vagrantfile, restart ve
vagrant destroydestroy ve
vagrant statusshow status of ve(s)
vagrant box listshow local baseboxes
vagrant box add http://local.example.com/vagrant/box.json --box-version 2019.05.04explicitly install a box from the given location and version
vagrant box updateupdate all baseboxes currently installed
vagrant box update --box prefix/boxnameupdate just the given basebox
vagrant box pruneremove outdated baseboxes
vagrant box prune --name prefix/boxnameremove just the given outdated baseboxes
vagrant box remove prefix/boxnameremove all cached instances of the given basebox
vagrant box remove prefix/boxname --box-version 2019.05.04remove just the given basebox and version
vagrant up --provision veprovision the ve with all provisioners (again)
vagrant up --provision-with ansible veprovision the ve with ansible (again)
vagrant reload --provision vereload Vagrantfile, restart the ve and provision it again
vagrant provision veprovision the running ve without restart
vagrant provision --provision-with-ansible veprovision the running ve with ansible and without restart

How to return to a previous version of a vagrant basebox

  1. remove any vagrant environment based on the basebox you want to remove:
    vagrant destroy
  2. remove the basebox:
    vagrant box remove prefix/basebox --box-version xyz
  3. if you already pruned the previous basebox you have to download it again:
    vagrant box add http://local.example.com/vagrant/basebox.json --box-version xyz
  4. check if it is there:
    vagrant box list
  5. create a new vagrant environment:
    vagrant up

Leave a Reply

Your email address will not be published.