How hashicorp/vagrant works
Vagrant is a CLI and framework for building and managing portable development environments. The documented path is to initialize a project, configure an environment, then bring it up; Vagrant can obtain a box and run it on a local virtualized platform, in cloud infrastructure, or in a container. Its runtime is organized around environment configuration and action execution, with providers, guest/host integrations, communicators, provisioners, and synced folders supplying platform-specific behavior. The README establishes the product workflow and capabilities; internal links not visible in the excerpts are left unverified.
Main entry points: machine.rb Machine Lifecycle · chef_client.rb Chef Provisioner · bundler.rb Plugin Dependencies · environment.rb Environment
Components 26
CLI and Environment
- Vagrant CLI
lib/vagrant/cli.rb - Environment
lib/vagrant/environment.rb - Environment Config
lib/vagrant/config.rb - Vagrantfile Loading
lib/vagrant/vagrantfile.rb
Runtime Core
- Action Middleware
lib/vagrant/action/primary_runner.rb - Machine Lifecycle
lib/vagrant/machine.rb - Box Management
lib/vagrant/box_collection.rb - Box Metadata
lib/vagrant/box_metadata.rb - Shared Helpers
lib/vagrant/shared_helpers.rb - Safe Environment
lib/vagrant/util/safe_env.rb - Version Utilities
lib/vagrant/version.rb
Machine Platforms
- VirtualBox Provider
plugins/providers/virtualbox/action.rb - Storage Controllers
plugins/providers/virtualbox/model/storage_controller_array.rb - Disk Format Rules
plugins/providers/virtualbox/cap/validate_disk_ext.rb
Guest Operations
- SSH Communicator
plugins/communicators/ssh/communicator.rb - Guest OS Support
plugins/guests/linux/guest.rb - Chef Provisioner
plugins/provisioners/chef/provisioner/chef_client.rb - Synced Folders
plugins/synced_folders/nfs/synced_folder.rb - Chef Provisioner Base
plugins/provisioners/chef/provisioner/base.rb - Chef Client Config
plugins/provisioners/chef/config/chef_client.rb
Extensions and State
- Plugin Manager
lib/vagrant/plugin/manager.rb - Plugin Dependencies
lib/vagrant/bundler.rb - Plugin State
lib/vagrant/plugin/state_file.rb - FTP Push
plugins/pushes/ftp/push.rb - FTP Adapter
plugins/pushes/ftp/adapter.rb
Other components
- Environment Developer
Connections 23
- Environment Developer → Vagrant CLI: runs commands
- Vagrant CLI → Environment: manages environments
- Environment → Vagrantfile Loading: loads configuration
- Vagrantfile Loading → Environment Config: provides settings
- Environment → Action Middleware: runs actions
- Action Middleware → Machine Lifecycle: manages lifecycle
- Machine Lifecycle → Box Management: uses boxes
- Box Management → Box Metadata: reads metadata
- Machine Lifecycle → VirtualBox Provider: runs on platform
- Storage Controllers → Disk Format Rules: validates format
plugins/providers/virtualbox/model/storage_controller_array.rb - Machine Lifecycle → SSH Communicator: communicates with guest
- Machine Lifecycle → Guest OS Support: uses guest support
- Machine Lifecycle → Chef Provisioner: runs provisioning
- Machine Lifecycle → Synced Folders: configures folders
- Plugin Manager → Plugin State: reads and updates
lib/vagrant/plugin/manager.rb - Plugin Manager → Plugin Dependencies: resolves plugins
lib/vagrant/plugin/manager.rb - Plugin Dependencies → Shared Helpers: uses helpers
lib/vagrant/bundler.rb - Plugin Dependencies → Safe Environment: uses environment
lib/vagrant/bundler.rb - Plugin Dependencies → Version Utilities: checks version
lib/vagrant/bundler.rb - Chef Provisioner → Chef Provisioner Base: inherits behavior
plugins/provisioners/chef/provisioner/chef_client.rb - Chef Provisioner → SSH Communicator: runs guest commands
plugins/provisioners/chef/provisioner/chef_client.rb - Chef Provisioner → Chef Client Config: uses configuration
- FTP Push → FTP Adapter: uploads files
plugins/pushes/ftp/push.rb