• Stars
    star
    609
  • Rank 73,614 (Top 2 %)
  • Language
    Ruby
  • License
    Other
  • Created over 11 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

VMware vSphere provider for Vagrant

Build Status Gem Version

Vagrant vSphere Provider

This is a Vagrant 1.6.4+ plugin that adds a vSphere provider to Vagrant, allowing Vagrant to control and provision machines using VMware. New machines are created from virtual machines or templates which must be configured prior to using this provider.

This provider is built on top of the RbVmomi Ruby interface to the vSphere API.

Level of Support

This repository is not actively supported by NSIDC but we welcome issue submissions and pull requests in order to foster community contribution.

See the LICENSE for details on permissions and warranties. Please contact [email protected] for more information.

Requirements

  • Vagrant 1.6.4+
  • VMware with vSphere API
  • Ruby 1.9+
  • libxml2, libxml2-dev, libxslt, libxslt-dev

Current Version

version: 1.13.5

vagrant-vsphere (version: 1.13.5) is available from RubyGems.org

Installation

Install using standard Vagrant plugin method:

vagrant plugin install vagrant-vsphere

This will install the plugin from RubyGems.org.

Alternatively, you can clone this repository and build the source with gem build vSphere.gemspec. After the gem is built, run the plugin install command from the build directory.

Potential Installation Problems

The requirements for Nokogiri must be installed before the plugin can be installed. See the Nokogiri tutorial for detailed instructions.

The plugin forces use of Nokogiri ~> 1.5 to prevent conflicts with older versions of system libraries, specifically zlib.

Usage

After installing the plugin, you must create a vSphere box. The example_box directory contains a metadata.json file that can be used to create a dummy box with the command:

tar cvzf dummy.box ./metadata.json

This can be installed using the standard Vagrant methods or specified in the Vagrantfile.

After creating the dummy box, make a Vagrantfile that looks like the following:

Vagrant.configure("2") do |config|
  config.vm.box = 'dummy'
  config.vm.box_url = './example_box/dummy.box'

  config.vm.provider :vsphere do |vsphere|
    vsphere.host = 'HOST NAME OF YOUR VSPHERE INSTANCE'
    vsphere.compute_resource_name = 'YOUR COMPUTE RESOURCE'
    vsphere.resource_pool_name = 'YOUR RESOURCE POOL'
    vsphere.template_name = '/PATH/TO/YOUR VM TEMPLATE'
    vsphere.name = 'NEW VM NAME'
    vsphere.user = 'YOUR VMWARE USER'
    vsphere.password = 'YOUR VMWARE PASSWORD'
  end
end

And then run vagrant up --provider=vsphere.

Custom Box

The bulk of this configuration can be included as part of a custom box. See the Vagrant documentation and the Vagrant AWS provider for more information and an example.

Supported Commands

Currently the only implemented actions are up, halt, reload, destroy, and ssh.

up supports provisioning of the new VM with the standard Vagrant provisioners.

Configuration

This provider has the following settings, all are required unless noted:

  • host - IP or name for the vSphere API
  • insecure - Optional verify SSL certificate from the host
  • user - user name for connecting to vSphere
  • password - password for connecting to vSphere. If no value is given, or the value is set to :ask, the user will be prompted to enter the password on each invocation.
  • data_center_name - Optional datacenter containing the computed resource, the template and where the new VM will be created, if not specified the first datacenter found will be used
  • compute_resource_name - Required if cloning from template the name of the host or cluster containing the resource pool for the new VM
  • resource_pool_name - the resource pool for the new VM. If not supplied, and cloning from a template, uses the root resource pool
  • clone_from_vm - Optional use a virtual machine instead of a template as the source for the cloning operation
  • template_name - the VM or VM template to clone (including the full folder path)
  • vm_base_path - Optional path to folder where new VM should be created, if not specified template's parent folder will be used
  • name - Optional name of the new VM. If missing, the name will be auto-generated
  • customization_spec_name - Optional customization spec for the new VM
  • data_store_name - Optional the datastore where the VM will be located
  • linked_clone - Optional link the cloned VM to the parent to share virtual disks
  • proxy_host - Optional proxy host name for connecting to vSphere via proxy
  • proxy_port - Optional proxy port number for connecting to vSphere via proxy
  • vlan - Optional vlan to connect the first NIC to
  • memory_mb - Optional Configure the amount of memory (in MB) for the new VM
  • cpu_count - Optional Configure the number of CPUs for the new VM
  • mac - Optional Used to set the mac address of the new VM
  • cpu_reservation - Optional Configure the CPU time (in MHz) to reserve for this VM
  • mem_reservation - Optional Configure the memory (in MB) to reserve for this VM
  • addressType - Optional Configure the address type of the vSphere Virtual Ethernet Card
  • custom_attribute - Optional Add a custom attribute to the VM upon creation. This method takes a key/value pair, e.g. vsphere.custom_attribute('timestamp', Time.now.to_s), and may be called multiple times to set different attributes.
  • extra_config - Optional A hash of extra configuration values to add to the VM during creation. These are of the form {'guestinfo.some.variable' => 'somevalue'}, where the key must start with guestinfo.. VMs with VWware Tools installed can retrieve the value of these variables using the vmtoolsd command: vmtoolsd --cmd 'info-get guestinfo.some.variable'.
  • notes - Optional Add arbitrary notes to the VM
  • real_nic_ip - Optional true/false - Enable logic that forces the acquisition of the ssh IP address for a target VM to be retrieved from the list of vm adapters on the host and filtered for a single legitimate adapter with a defined interface. An error will be raised if this filter is enabled and multiple valid adapters exist on a host.
  • ip_address_timeout - Optional Maximum number of seconds to wait while an IP address is obtained
  • wait_for_sysprep - Optional Boolean. Enable waiting for Windows machines to reboot during the sysprep process (#199). Defaults to false.

Cloning from a VM rather than a template

To clone from an existing VM rather than a template, set clone_from_vm to true. If this value is set, compute_resource_name and resource_pool_name are not required.

Template_Name

  • The template name includes the actual template name and the directory path containing the template.
  • For example: if the template is a directory called vagrant-templates and the template is called ubuntu-lucid-template the template_name setting would be:
vsphere.template_name = "vagrant-templates/ubuntu-lucid-template"

Vagrant Vsphere Screenshot

VM_Base_Path

  • The new vagrant VM will be created in the same directory as the template it originated from.
  • To create the VM in a directory other than the one where the template was located, include the vm_base_path setting.
  • For example: if the machines will be stored in a directory called vagrant-machines the vm_base_path would be:
vsphere.vm_base_path = "vagrant-machines"

Vagrant Vsphere Screenshot

Setting a static IP address

To set a static IP, add a private network to your vagrant file:

config.vm.network 'private_network', ip: '192.168.50.4'

The IP address will only be set if a customization spec name is given. The customization spec must have network adapter settings configured with a static IP address(just an unused address NOT the address you want the VM to be). The config.vm.network line will overwrite the ip in the customization spec with the one you set. For each private network specified, there needs to be a corresponding network adapter in the customization spec. An error will be thrown if there are more networks than adapters.

Auto name generation

The name for the new VM will be automagically generated from the Vagrant machine name, the current timestamp and a random number to allow for simultaneous executions.

This is useful if running Vagrant from multiple directories or if multiple machines are defined in the Vagrantfile.

Setting addressType for network adapter

This sets the addressType of the network adapter, for example 'Manual' to be able to set a manual mac address. This value may depend on the version of vSphere you use. It may be necessary to set this in combination with the mac field, in order to set a manual mac address. For valid values for this field see VirtualEthernetCard api documentation of vSphere.

vsphere.addressType = 'Manual'

Setting the MAC address

To set a static MAC address, add a vsphere.mac to your Vagrantfile. In some cases you must also set vsphere.addressType (see above) to make this work:

vsphere.mac = '00:50:56:XX:YY:ZZ'

Take care to avoid using invalid or duplicate VMware MAC addresses, as this can easily break networking.

Troubleshooting

vCenter

ESXi is not supported. Make sure to connect to a vCenter server and not directly to an ESXi host. ESXi vs vCenter

Permissions

If you have permission issues:

  1. give the connecting user read only access to everything, and full permission to a specific data center. Narrow the permissions down after a VM is created.
  2. Be sure the path to the VM is correct. see the "Template_Name" screenshots above for more information.

Example Usage

FILE: Vagrantfile

VAGRANT_INSTANCE_NAME   = "vagrant-vsphere"

Vagrant.configure("2") do |config|
  config.vm.box     = 'vsphere'
  config.vm.box_url = 'https://vagrantcloud.com/ssx/boxes/vsphere-dummy/versions/0.0.1/providers/vsphere.box'

  config.vm.hostname = VAGRANT_INSTANCE_NAME
  config.vm.define VAGRANT_INSTANCE_NAME do |d|
  end

  config.vm.provider :vsphere do |vsphere|
    vsphere.host                  = 'vsphere.local'
    vsphere.name                  = VAGRANT_INSTANCE_NAME
    vsphere.compute_resource_name = 'vagrant01.vsphere.local'
    vsphere.resource_pool_name    = 'vagrant'
    vsphere.template_name         = 'vagrant-templates/ubuntu14041'
    vsphere.vm_base_path          = "vagrant-machines"

    vsphere.user     = 'vagrant-user@vsphere'
    vsphere.password = '***************'
    vsphere.insecure = true

    vsphere.custom_attribute('timestamp', Time.now.to_s)
  end
end

Vagrant Up

vagrant up --provider=vsphere

Vagrant SSH

vagrant ssh

Vagrant Destroy

vagrant destroy

Version History

See CHANGELOG.md.

Contributing

See DEVELOPMENT.md.

License

The Vagrant vSphere Provider is licensed under the MIT license. See LICENSE.

Code of Conduct

See Code of Conduct.

Credit

This software was developed by the National Snow and Ice Data Center with funding from multiple sources.

More Repositories

1

earthaccess

Python Library for NASA Earthdata APIs
Python
413
star
2

NSIDC-Data-Tutorials

Jupyter notebook-based tutorials to learn how to access and work with select NSIDC DAAC data.
Jupyter Notebook
77
star
3

NSIDC-Data-Access-Notebook

A Jupyter notebook exploring data coverage, size, and customization service availability along with direct data download utilizing the NSIDC DAAC's access and service API.
Jupyter Notebook
56
star
4

smap_python_notebooks

Python
38
star
5

qgreenland

Source code for generating the QGreenland package hosted at https://qgreenland.org/
Python
36
star
6

OpenSearchlight

An OpenSearch client in JavaScript
JavaScript
21
star
7

polarstereo-lonlat-convert-py

Python functions for converting polar stereographic coordinates.
Python
19
star
8

ol3-projection-switcher

OpenLayers 3 Projection Switcher Control
JavaScript
15
star
9

cloud-optimized-icesat2

Jupyter Notebook
9
star
10

Antarctica_Today

The "Antarctica Today" code and datasets
Python
7
star
11

nsidc_open_science

Towards developing an Open Science Strategy for the National Snow and Ice Data Center
Jupyter Notebook
6
star
12

tech-radar

Helps NSIDC understand the spectrum of technology that is relevant to our work
5
star
13

snow-today-webapp

Visualize near-real-time snow data
TypeScript
5
star
14

polar_stereo

NSIDC Polar Stereographic Projection
5
star
15

AGU-2019-NSIDC-Data-Tutorial

Jupyter Notebook
5
star
16

easegrids-easeconv

EASE-Grid map transformation utilities for IDL.
IDL
4
star
17

ms2gt

MODIS Swath-to-Grid Toolbox
IDL
4
star
18

qgreenland-plugin

Python
4
star
19

snow-today-webapp-server

Serve data the snow-today-webapp depends on
Python
4
star
20

NSIDC-Data-Cookbook

A collection of how-to guides, tutorials and references for searching, accessing and working with NSIDC data.
Jupyter Notebook
4
star
21

polarstereo-reformat

Scripts for working with NSIDC data in polar stereographic projections.
Python
3
star
22

seaice_ecdr

Sea Ice Concentration 12.5km Enhanced CDR
Python
3
star
23

nsidc0756-scripts

Scripts related to NSIDC-0756
Python
3
star
24

pm_icecon

Sea Ice Concentrations from Passive Microwave Data
Python
3
star
25

mapxmaps

A collection of Map Projection Parameter (.mpp) and Grid Parameter Definition (.gpd) files for use with NSIDC's mapx software
Makefile
3
star
26

git-training

Git training for NSIDC
Shell
3
star
27

icebridge-tools

NSIDC Tools for reading and viewing NASA IceBridge data
MATLAB
3
star
28

JIRA-GitHub-ETL

Python scripts to transform JIRA xml export to GitHub Issues
Python
3
star
29

HMA_GLAM_BioLith-RT_5

Matlab code for Glacier Lake Assisted Melting of Glaciers
MATLAB
3
star
30

presentation-reusable-workflows

A presentation about re-usable workflows in GitHub Actions
2
star
31

mapx

The NSIDC mapx library and associated binary tools for gridding/reprojection.
C
2
star
32

gi_cat_driver

Ruby
2
star
33

beer_lambert_rt

Beer-Lambert Radiative Transfer Model used for Stroeve et al 2021
Python
2
star
34

aross-map

Arctic Rain on Snow Study LEO Network Observation Map
TypeScript
2
star
35

slackbotr

An application for hosting/serving Python slackbots
Python
2
star
36

search-interface

An Opensearch based single page search interface
JavaScript
2
star
37

earthaccess-gallery

earthaccess gallery with examples
Jupyter Notebook
2
star
38

qgreenland-customizer

Prototype/spike on QGreenland Customizer Plugin
Python
2
star
39

revealjs_presentation_template

Presentation templates for NSIDC using Revealjs
SCSS
2
star
40

search-solr-tools

This is a gem that contains: Ruby translators to transform various metadata feeds into solr documents and a command-line utility to access/utilize the gem's translators to harvest metadata into a working solr instance.
Ruby
2
star
41

earthaccess-proposal-2024-nasa-roses

A proposal for sustainment funding for _earthaccess_ under NASA ROSES 2024 F.07
TeX
1
star
42

icesat2-notebooks

notebooks to test IS2 datasets
Jupyter Notebook
1
star
43

nsidc0447-scripts

Scripts related to NSIDC-0447
Python
1
star
44

cumulus-migration-dependencies

collect versions for various dependencies and components in the Cumulus Migration stack
Python
1
star
45

dataset-search-services

OpenSearch interface to a Solr backend.
Ruby
1
star
46

data_strategies_for_future_us

1
star
47

Shapefile_to_grid

This python code was written specifically to convert the shapefiles from the NSIDC dataset G10007 to a grid that matches the data in the NSIDC data G10010 dataset
Python
1
star
48

presentation-pangeo-forge

A brief intro to Pangeo Forge
1
star
49

2022-bookclub-exercises

Euler Project problems and other exercises through which we are learning Scheme together
Racket
1
star
50

.github

1
star
51

open-science-reading-club

A website and community space for the NSIDC open science reading club
SCSS
1
star
52

ros-animator-widget

A widget for controlling animations of Rain on Snow events
TypeScript
1
star
53

polarstereo-latlon-convert-fortran

FORTRAN program that transforms between I,J and latitude,longitude coordinates of an SSM/I grid cell.
Fortran
1
star