Vagrant : supprimer toutes ses box

Aujourd’hui, juste une petite astuce pour supprimer en 1 commande l’intégralité de ses box Vagrant (attention, il n’y a pas de confirmation) :

vagrant box list | cut -f 1 -d ' ' | xargs -L 1 vagrant box remove -f

Exemple :

L’état de mes box Vagrant avant le lancement :

$ vagrant box list
ThyDao/odoo-box                                   (virtualbox, 1.1.3)
build/packer_virtualbox-iso_virtualbox.box        (virtualbox, 0)
generic/ubuntu1904                                (virtualbox, 1.9.40)
mshannaq/odoo12_ubuntu18.04_accounting_pdfreports (virtualbox, 0.0.1)
ubuntu/bionic64                                   (virtualbox, 20191107.0.0)
ubuntu/disco64                                    (virtualbox, 20191115.0.0)

On lance la commande :

$ vagrant box list | cut -f 1 -d ' ' | xargs -L 1 vagrant box remove -f
Removing box 'ThyDao/odoo-box' (v1.1.3) with provider 'virtualbox'...
Removing box 'build/packer_virtualbox-iso_virtualbox.box' (v0) with provider 'virtualbox'...
Removing box 'generic/ubuntu1904' (v1.9.40) with provider 'virtualbox'...
Removing box 'mshannaq/odoo12_ubuntu18.04_accounting_pdfreports' (v0.0.1) with provider 'virtualbox'...
Removing box 'ubuntu/bionic64' (v20191107.0.0) with provider 'virtualbox'...
Removing box 'ubuntu/disco64' (v20191115.0.0) with provider 'virtualbox'...

Le résultat :

$ vagrant box list
There are no installed boxes! Use `vagrant box add` to add some.

Et c’est votre espace disque qui vous dira merci !