Vagrantfile example: Single Machine, fully documented - josenk/vagrant-vmware-esxi GitHub Wiki

#
#  Single Machine, fully documented Vagrant file.
#
Vagrant.configure('2') do |config|

  #  Box, Select any box created for VMware that is compatible with
  #    the ovftool.  To get maximum compatibility You should download
  #    and install the latest version of ovftool for your OS.
  #    https://www.vmware.com/support/developer/ovf/
  #
  #    If your box is stuck at 'Powered On', then most likely
  #    the system doesn't have the vmware tools installed.
  #
  # Here are some of the MANY examples....
  config.vm.box = 'hashicorp/precise64'
  #config.vm.box = 'generic/centos7'
  #config.vm.box = 'generic/centos6'
  #config.vm.box = 'generic/fedora26'
  #config.vm.box = 'generic/freebsd11'
  #config.vm.box = 'generic/ubuntu1710'
  #config.vm.box = 'generic/debian9'
  #config.vm.box = 'steveant/CentOS-7.0-1406-Minimal-x64'
  #config.vm.box = 'geerlingguy/centos7'
  #config.vm.box = 'geerlingguy/ubuntu1604'
  #config.vm.box = 'laravel/homestead'
  #config.vm.box = 'puphpet/debian75-x64'


  #  Use rsync and NFS synced folders. (or disable them)
  #    https://www.vagrantup.com/docs/synced-folders/
  #config.vm.synced_folder('.', '/vagrant', type: 'rsync')
  config.vm.synced_folder('.', '/vagrant', type: 'nfs', disabled: true)

  #  Vagrant can set a static IP for the additional network interfaces.  Use
  #  public_network or private_network to manually set a static IP and
  #  netmask.  ESXi doesn't use the concept of public or private networks so
  #  both are valid here.   'bridge' will be ignored.  Netmask is optional if
  #  you are using standard Class A/B/C networks. The primary network
  #  interface is considered the management interface and cannot be changed,
  #  so you can specify 3 entries here!
  #    *** Invalid settings could cause 'vagrant up' to fail ***
  #config.vm.network 'private_network', ip: '192.168.10.170', netmask: '255.255.255.0'
  #config.vm.network 'private_network', ip: '192.168.11.170'
  #config.vm.network 'public_network', ip: '192.168.12.170'

  #
  #  Provider (esxi) settings
  #
  config.vm.provider :vmware_esxi do |esxi|

    #  REQUIRED!  ESXi hostname/IP
    #    You MUST specify a esxi_hostname or IP, uless you
    #    were lucky enough to name your esxi host 'esxi'.  :-)
    esxi.esxi_hostname = 'esxi'

    #  ESXi username
    #    Default is 'root'.
    esxi.esxi_username = 'root'

    #
    #  IMPORTANT!  ESXi password.
    #  *** NOTES about esxi_password & ssh keys!! ***
    #
    #    1) 'prompt:'
    #       This will prompt you for the esxi password each time you
    #       run a vagrant command.  This is the default.
    #
    #    2) 'file:'  or  'file:my_secret_file'
    #       This will read a plain text file containing the esxi
    #       password.   The default filename is ~/.esxi_password, or
    #       you can specify any filename after the colon ':'.
    #
    #    3) 'env:'  or 'env:my_secret_env_var'
    #        This will read the esxi password via an environment
    #        variable.  The default is $esxi_password, but you can
    #        specify any environment variable after the colon ':'.
    #
    #            $ export esxi_password='my_secret_password'
    #
    #    4)  'key:'  or  key:~/.ssh/some_ssh_private_key'
    #        Use ssh keys.  The default is to use the system private keys,
    #        or you specify a custom private key after the colon ':'.
    #
    #        To test connectivity. From your command line, you should be able to
    #        run following command without an error and get an esxi prompt.
    #
    #            $ ssh root@ESXi_IP_ADDRESS
    #
    #        The ssh connections to esxi will try the ssh private
    #        keys.  However the ovftool does NOT!  To make
    #        vagrant fully password-less, you will need to use other
    #        options. (set the password, use 'env:' or 'file:')
    #
    #    5)  esxi.esxi_password = 'my_esxi_password'
    #        Enter your esxi passowrd in clear text here...  This is the
    #        least secure method because you may share this Vagrant file without
    #        realizing the password is in clear text.
    #
    #  IMPORTANT!  Set the ESXi password or authentication method..
    esxi.esxi_password = 'prompt:'

    #  SSH port.
    #    Default port 22.
    #esxi.esxi_hostport = 22

    #  HIGHLY RECOMMENDED!  Virtual Network
    #    You should specify a Virtual Network!  If it's not specified, the
    #    default is to use the first found.  You can specify up to 4 virtual
    #    networks using an array format.  Note that Vagrant only looks at the
    #    first interface for a valid IP address.  BTW: This does not configure
    #    IP addresses.  This specifies which 'ESXi virtual network' is used for
    #    each network interface in your VM.  For most OS's DHCP is the default,
    #    so, you will need a DHCP server for each virtual network.  To set a
    #    static IP for interface 2, 3 or 4. see above 'config.vm.network'.
    #esxi.esxi_virtual_network = ['VM Network','VM Network 2','VM Network 3','VM Network 4']

    #  OPTIONAL.  Specify a Disk Store
    #    If it's not specified, the Default is to use the least used Disk Store.
    #esxi.esxi_disk_store = 'DS_001'

    #  OPTIONAL.  Resource Pool
    #    If unspecified, the default is to create VMs in the 'root'.  You can
    #    specify a resource pool here to partition memory and cpu usage away
    #    from other systems on your esxi host.  The resource pool must
    #    already exist and have the proper permissions set.
    #
    #     Vagrant will NOT create a Resource pool it for you.
    #esxi.esxi_resource_pool = '/Vagrant'

    #  Optional. Specify a VM to clone instead of uploading a box.
    #    Vagrant can use any stopped VM as the source 'box'.   The VM must be
    #    registered, stopped and must have the vagrant insecure ssh key installed.
    #    If the VM is stored in a resource pool, it must be specified.  If this
    #    option is specified, config.vm.box should be set to a dummy box.
    #    See wiki: https://github.com/josenk/vagrant-vmware-esxi/wiki/How-to-clone_from_vm.
    #esxi.clone_from_vm = 'resource_pool/source_vm'

    #  OPTIONAL.  Guest VM name to use.
    #    The Default will be automatically generated.  It will be based on
    #    the guest_name_prefix (see below), your hostname & username and path.
    #    Otherwise you can set a fixed guest VM name here.
    #esxi.guest_name = 'Custom-Guest-VM_Name'

    #  OPTIONAL.  When automatically naming VMs, use this prifix.
    #esxi.guest_name_prefix = 'V-'

    #  OPTIONAL.  Set the guest username login.  The default is 'vagrant'.
    #esxi.guest_username = 'vagrant'

    #  OPTIONAL.  Memory size override
    #    The default is to use the memory size specified in the
    #    vmx file, however you can specify a new value here.
    #esxi.guest_memsize = '2048'

    #  OPTIONAL.  Virtual CPUs override
    #    The default is to use the number of virtual cpus specified
    #     in the vmx file, however you can specify a new value here.
    #esxi.guest_numvcpus = '2'

    #  OPTIONAL. Specify a disk type.
    #    If unspecified, it will be set to 'thin'.  Otherwise, you can set to
    #    'thin', 'thick', or 'eagerzeroedthick'
    #esxi.guest_disk_type = 'thick'

    #  OPTIONAL.  Create additional storage for guests.
    #    You can specify an array of upto 14 virtual disk sizes (in GB) that you
    #    would like the provider to create once the guest has been created.  The
    #    virtual disks will be created and added to the guest, however you must
    #    provision it.  The disks can be used for lvm, partitioned, raw disk
    #    for data bases, etc...
    #esxi.guest_storage = [10,20]

    #  OPTIONAL & RISKY.  Specify up to 4 MAC addresses
    #    The default is ovftool to automatically generate a MAC address.
    #    You can specify an array of MAC addresses using upper or lower case,
    #    separated by colons ':'.  I highly recommend using vmware's OUI
    #    of '00:50:56' or '00:0c:29'.  I consider this option a risk
    #    because you may reuse a Vagrantfile without realizing you are
    #    duplicating the MAC address.
    #    *** Invalid settings could cause 'vagrant up' to fail ***
    #esxi.guest_mac_address = ['00:50:56:aa:bb:cc', '00:50:56:01:01:01','00:50:56:02:02:02','00:50:56:BE:AF:01' ]

    #   OPTIONAL & RISKY.  Specify a guest_nic_type
    #     The default is to have the virtual nic hw type automatically
    #     determined by the ovftool.  However, you can override it by specifying
    #     it here.  This is a global setting.  (all 4 virtual networks will be set)
    #     The validated list of guest_nic_types are 'e1000', 'e1000e', 'vmxnet',
    #     'vmxnet2', 'vmxnet3', 'Vlance', and 'Flexible'.  I consider this
    #     risky because I don't validate if the specified guest_nic_type is
    #     compatible with your OS version.
    #    *** Invalid setting could cause 'vagrant up' to fail ***
    #esxi.guest_nic_type = 'e1000'

    #  OPTIONAL. specify snapshot options.
    #esxi.guest_snapshot_includememory = 'true'
    #esxi.guest_snapshot_quiesced = 'true'

    #  RISKY. guest_guestos
    #    if unspecified, the default will be generated by the OVFTool.  Most
    #    of the time, you don't need to change this unless ovftool doesn't get
    #    the correct information from the box.  See my page on supported guest_guestos
    #    types for ESXI.
    #    https://github.com/josenk/vagrant-vmware-esxi/ESXi_guest_guestos_types.md
    #esxi.guest_guestos = 'centos-64'

    #  OPTIONAL. guest_virtualhw_version
    #    If unspecified, the default will be generated by the OVFTool.  Most
    #    of the time, you don't need to change this unless you are using advanced
    #    custom vmx settings that require it.
    #    ESXi 6.5 supports these versions. 4,7,8,9,10,11,12 & 13.
    #esxi.guest_virtualhw_version = '9'

    #  RISKY. guest_custom_vmx_settings
    #    You can specify an array of custom vmx settings to add (or to override
    #    existing settings).   ****  I don't do any validation, so if you
    #    make any errors, it will not be caught ***   This is the place you would
    #    add any special settings you need in your vmx.  (Like adding a USB, DVD
    #    CPU settings, etc...).
    #    ex vhv.enable = 'TRUE' will be appended, floppy0.presend = 'TRUE' will be modified
    #esxi.guest_custom_vmx_settings = ['vhv.enable','TRUE'], ['floppy0.present','TRUE'](/josenk/vagrant-vmware-esxi/wiki/'vhv.enable','TRUE'],-['floppy0.present','TRUE')

    #  OPTIONAL. local_lax
    #    If unspecified, the ovftool option --lax is disabled.   If you are
    #    importing ovf boxes that generate errors, you may want to enable local_lax
    #    to convert the errors to warning. (then the import could succeed)
    #esxi.local_lax = 'true'

    #  OPTIONAL.  Guest IP Caching
    #    If unspecified, guest IP caching will be enabled.  This will result in
    #    faster vagrant command executution.   However, vagrant could get incorrect
    #    information if an IP changes on the guest.   Set this 'False' to disable
    #    IP caching.
    #esxi.local_use_ip_cache = 'False'

    #  DANGEROUS!  Allow Overwrite
    #    If unspecified, the default is to produce an error if overwriting
    #    vm's and packages.
    #    Set this to 'True' will overwrite existing VMs (with the same name)
    #    when you run vagrant up.   ie,  if the guest_name already exists,
    #    it will be destroyed, then over written...  This is helpful
    #    if you have a VM that became an orphan (vagrant lost association).
    #    This will also overwrite your box when using vagrant package.
    #esxi.local_allow_overwrite = 'True'

    #  Plugin debug output.
    #    Send bug reports with debug output...
    #esxi.debug = 'true'

  end
end