vagrant provision: Usage & Common CI Errors
Re-run the provisioners against an already-running Vagrant VM.
vagrant provision runs (or re-runs) the provisioners defined in the Vagrantfile against a machine that is already up - useful for iterating on shell/Ansible provisioning without recreating the VM.
What it does
vagrant provision executes the provisioners (shell, file, Ansible, Chef, Puppet) on a running machine, in the order defined. Unlike vagrant up, it does not boot or recreate the VM - it only applies provisioning, so it is the fast inner loop for configuration changes.
Common usage
# Re-run all provisioners on the running VM
vagrant provision
# Run only a named provisioner
vagrant provision --provision-with ansible
# Provision a specific machine
vagrant provision webCommon error in CI: machine not running / provisioner failed
provision errors with "VM is not running. Please bring it up with vagrant up first" or a nonzero exit from a shell/Ansible provisioner. Fix: ensure vagrant up succeeded before provision (or run vagrant up --provision), and treat provisioner exit codes as build failures. Use --provision-with to iterate on one provisioner at a time so a failing step is isolated, and make shell provisioners idempotent so re-runs are safe.
Key options
| Option | Purpose |
|---|---|
| --provision-with | Run only the named provisioners |
| [name] | Target a specific machine |