ESXi fail to build, Vagrantfile error
Using the ESXi command line options or the .conf file option with --read-options cause the same issue. It appears to not build the Vagrantfile correctly. Correcting the Vagrantfile formatting does not resolve the issue, as it's looking for VirtualBox as the provider if I call build-vms --project and point to my project directory.
CLI and .conf also do not recognize the --esxi-disktype option.
Ubuntu 20.04 Ruby 2.7.0 Vagrant 2.2.6
While typing this whole thing out, came across a few things that got me near a success. I hope this helps someone trying this in 2022:
Install the ESXi provider plugin:
vagrant plugin install vagrant-vmware-esxi
Download VMware ovftool (VMware provides it but you must download it and install it). I installed 4.3.0 build 13981069.
Success? A VM successfully built on my ESXi instance, but none of this is mentioned in the setup docs. You will likely have to correct the Vagrantfile after building your project file then use the build-vms function for it to work. There was also an early issue with the nokogiri gem that I had to rebuild using system libraries. Two basic commands that helped there:
sudo gem uninstall nokogiri
sudo gem install nokogiri --platform=ruby -- --use-system-libraries
Errors and such from before I installed the plugin and ovftool:
Error from stdout after running ruby secgen.rb --read-options esxi.conf run
There is a syntax error in the following Vagrantfile. The syntax error
message is reproduced below for convenience:
/home/sasquatch/Desktop/Tools/SecGen/projects/SecGen20221020_200625/Vagrantfile:20: syntax error, unexpected local variable or method, expecting `end'
...i_disk_store = 'DS1' esxi.guest_memsize = '1024 MB'
... ^~~~
/home/sasquatch/Desktop/Tools/SecGen/projects/SecGen20221020_200625/Vagrantfile:196: syntax error, unexpected `end', expecting end-of-input
Non-zero exit status...
Error provisioning VMs, destroying VMs and exiting SecGen.
Loading vagrant (destroy -f) in /home/sasquatch/Desktop/Tools/SecGen/projects/SecGen20221020_200625
Vagrant failed to initialize at a very early stage:
There is a syntax error in the following Vagrantfile. The syntax error
message is reproduced below for convenience:
/home/sasquatch/Desktop/Tools/SecGen/projects/SecGen20221020_200625/Vagrantfile:20: syntax error, unexpected local variable or method, expecting `end'
...i_disk_store = 'DS1' esxi.guest_memsize = '1024 MB'
... ^~~~
/home/sasquatch/Desktop/Tools/SecGen/projects/SecGen20221020_200625/Vagrantfile:196: syntax error, unexpected `end', expecting end-of-input
Non-zero exit status...
SecGen generated Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# This file was generated by SecGen
# 2022-10-20 20:06:30 -0400
# Based on scenarios/default_scenario.xml
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "escalation" do |escalation|
# vmware_esxi provider begin
escalation.vm.provider :vmware_esxi do |esxi|
esxi.esxi_hostname = 'https://esxi1.example.com'
esxi.esxi_username = 'root'
esxi.esxi_password = 'password'
esxi.esxi_disk_store = 'DS1' esxi.guest_memsize = '1024 MB'
end
# End ESXi provider
Corrected Vagrantfile
# vi: set ft=ruby :
# This file was generated by SecGen
# 2022-10-19 22:21:50 -0400
# Based on scenarios/default_scenario.xml
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "escalation" do |escalation|
# vmware_esxi provider begin
escalation.vm.provider :vmware_esxi do |esxi|
esxi.esxi_hostname = 'esxi1.example.com'
esxi.esxi_username = 'root'
esxi.esxi_password = 'password'
esxi.esxi_disk_store = 'DS1'
esxi.guest_memsize = '1024 MB'
end
# End ESXi provider
Error after corrected Vagrantfile using uby secgen.rb build-vms --project ./projects/SecGen20221019_222143
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SecGen - Creates virtualised security scenarios
Licensed GPLv3 2014-22
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please take a minute to tell us how you are using SecGen:
https://tinyurl.com/SecGenFeedback
Relative path to project detected
Using /home/sasquatch/Desktop/Tools/SecGen/./projects/SecGen20221019_222143
Building project: /home/sasquatch/Desktop/Tools/SecGen/./projects/SecGen20221019_222143
Loading vagrant (up) in /home/sasquatch/Desktop/Tools/SecGen/./projects/SecGen20221019_222143
Bringing machine 'escalation' up with 'virtualbox' provider...
==> escalation: Box 'modules_bases_debian_stretch_server' could not be found. Attempting to find and install...
escalation: Box Provider: virtualbox
escalation: Box Version: >= 0
==> escalation: Box file was not detected as metadata. Adding it directly...
==> escalation: Adding box 'modules_bases_debian_stretch_server' (v0) for provider: virtualbox
escalation: Downloading: https://app.vagrantup.com/redwiz666/boxes/debian_stretch_server/versions/1.0.0/providers/vmware.box
escalation: Download redirected to host: vagrantcloud-files-production.s3-accelerate.amazonaws.com
The box you attempted to add doesn't match the provider you specified.
Provider expected: virtualbox
Provider of box: vmware_desktop
Non-zero exit status...
Error provisioning VMs, destroying VMs and exiting SecGen.
Loading vagrant (destroy -f) in /home/sasquatch/Desktop/Tools/SecGen/./projects/SecGen20221019_222143
Corrected a few issues by upgrading to Vagrant 2.2.9 related to SSH timeouts, but still running into issues.
Specifically, it consistently does not format the Vagrantfile correctly in the ESXi section.
Vagrant failed to initialize at a very early stage:
There is a syntax error in the following Vagrantfile. The syntax error
message is reproduced below for convenience:
/home/sasquatch/Desktop/Tools/SecGen/projects/SecGen20221020_221406/Vagrantfile:20: syntax error, unexpected tIDENTIFIER, expecting end
...i_disk_store = 'DS1' esxi.guest_memsize = '1024 MB'
... ^~~~
/home/sasquatch/Desktop/Tools/SecGen/projects/SecGen20221020_221406/Vagrantfile:102: syntax error, unexpected end, expecting end-of-input
Non-zero exit status...
Error provisioning VMs, destroying VMs and exiting SecGen.
Thanks for letting us know. We don't internally use ESXi, it was contributed by @redwiz666, so maybe they can provide some input. Pull requests very welcome.
@SasquatchSecurity can you run the following and let me know you output
vagrant plugin list
vagrant --version
also provide the content from your esxi.conf Make sure to mask any passwords
as for the disk-type Good find. Seems i forgot to implement that one. I will get a pull request sent over with that after we figure out whats going on with your vagrant files.
If you want to use it for after line 466 at the following before the )
['--esxi-disktype', GetoptLong::REQUIRED_ARGUMENT],
I found the issues and have created a pull request #229 .