Installation and Setup
Download and Install Vagrant
Download Vagrant from the official website and follow the installation wizard. Alternatively, if you have Chocolatey installed:
choco install vagrant
Install Vagrant vCenter Provider
First, install the prerequisite nokogiri gem, then install the vagrant-vsphere provider:
gem install nokogiri
vagrant plugin install vagrant-vsphere
Configuring vSphere Provider
Create a Vagrantfile in your project directory with the following configuration:
Vagrant.configure("2") do |config|
config.vm.box = 'vsphere'
config.vm.box_url = 'dummy.box'
config.ssh.private_key_path = '<Path to your SSH Private Key>'
config.vm.provider :vsphere do |vsphere|
vsphere.customization_spec_name = '<Name of Customization spec>'
vsphere.host = '<FQDN of vcenter server>'
vsphere.compute_resource_name = '<ESX Cluster Name>'
vsphere.resource_pool_name = '<Resource Pool Name>'
vsphere.template_name = '<Folder>/<Template Name>'
vsphere.name = '<VM Name>'
vsphere.user = '<vSphere username>'
vsphere.password = '<Password for vCenter>'
vsphere.linked_clone = true
vsphere.insecure = true
end
end
Note: Using linked_clone makes provisioning much faster, but requires taking a snapshot of the VM template first.
Essential Vagrant Commands
- vagrant up: Provisions one or more virtual machines based on your Vagrantfile configurations
- vagrant ssh: Connects to your provisioned machine via SSH using key authentication
- vagrant destroy: Shuts down and deletes your provisioned VMs
# If you have trouble connecting, specify the provider explicitly
vagrant up --provider=vcenter



