Skip to content

Vagrant and vSphere plugin for @scale deployment

Echo Cheng edited this page Mar 16, 2017 · 1 revision

Introduction

"Vagrant - the command line utility for managing the life-cycle of virtual machines." vagrant-vsphere - VMware vSphere provider for Vagrant, allowing Vagrant to control and provision machines using VMware vSphere. First, we can use vagrant to deployment InfraSIM @scale test environment on vCenter, VMs resources allocation will follow vSphere DRS (Distributed Resource Scheduler). We can execute vagrant up, halt, reload, provision, destroy and ssh...command on VMs in parallel.

Setup and Execution

Vagrant and vSphere plugin setup

Here we select a VM with Ubuntu 16.04 installed as Vagrant host server.

  • Vagrant installation:

$ sudo apt-get install ruby-full

$ sudo apt install ruby-bundler

$ git clone https://github.com/mitchellh/vagrant.git

$ cd vagrant

$ bundle install

$ wget https://releases.hashicorp.com/vagrant/1.9.2/vagrant_1.9.2_x86_64.deb

$ sudo apt install ~/vagrant_1.9.2_x86_64.deb

After the installation execute "vagrant -v" to make sure Vagrant version as your expectation.

  • Install vagrant-vsphere plugin:

$ vagrant plugin install vagrant-vsphere

The vagrant-vsphere box

Which is hosted via Atlas in "InfraSIM/infrasim-compute" organization, we can define it in Vagrantfile. https://atlas.hashicorp.com/InfraSIM/boxes/infrasim-compute

Prepare for the Vagrantfile

Please prepare this file base on your exact test vCenter environment, an example is uploaded to GitHub InfraSIM/tools/@scale repo for reference. https://github.com/InfraSIM/tools

Create a template/vm in vSphere/vCenter for vagrant proceed.

Make sure the "template inventory location" and "template name" is the same as in Vagrantfile Clone a template in vCenter

You can also create a register vm through ESXi vim-cmd.

$ vim-cmd solo/registervm /vmfs/volumes/datastore_name/VM_directory/VM_name.vm

Create Customization Specifications through vSphere Center

This "spec" will be used one you need to set static IP for "private network". One key point, the NIC numbers in "spec" should match the NIC numbers in vm template. Create Customization Specification

Run the vagrant command in Vagrant server to clone VMs in vCenter.

$ vagrant up --provider=vsphere

We can ssh to target VM

$ vagrant ssh vagrant-1

We can delete all deployed VMs

$ vagrant destroy

After all InfraSIM virtual nodes powered up, you can refer to Ansible playbook in InfraSIM/tools repo for further operation on InfraSIMs.

https://github.com/InfraSIM/tools/pull/40

Vagrant logs

If add "--debug" parameter we can save output to a file "vagrant.log".

$ vagrant up --debug &> vagrant.log

Reference

https://www.vagrantup.com/docs/

https://github.com/mitchellh/vagrant

https://github.com/nsidc/vagrant-vsphere

https://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.pg.doc_50%2FPG_Ch13_Resources.15.6.html

Create a Customization Specification for Linux in vSphere Client.

https://pubs.vmware.com/vsphere-51/index.jsp#com.vmware.vsphere.vm_admin.doc/GUID-70CD44B1-B27D-43E7-83D5-A76833B1CA8A.html

Clone this wiki locally