diff --git a/lib/schemas/base_metadata_schema.xsd b/lib/schemas/base_metadata_schema.xsd index 7eddfa286..a862c6f41 100644 --- a/lib/schemas/base_metadata_schema.xsd +++ b/lib/schemas/base_metadata_schema.xsd @@ -50,6 +50,7 @@ + diff --git a/lib/templates/Vagrantfile.erb b/lib/templates/Vagrantfile.erb index 1babe9dfd..60991cd04 100644 --- a/lib/templates/Vagrantfile.erb +++ b/lib/templates/Vagrantfile.erb @@ -18,6 +18,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| if selected_module.module_type == 'base' @base_type = selected_module.attributes['type'] @ovirt_template = selected_module.attributes['ovirt_template'] + @esxi_url = selected_module.attributes['esxi_url'] @cpu_word_size = selected_module.attributes['cpu_word_size'].first.downcase if (@options.has_key? :ovirtuser) && (@options.has_key? :ovirtpass) @ovirt_base_template = selected_module.attributes['ovirt_template'].first @@ -58,6 +59,30 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| ovirt.debug = true end # oVirt provider end + +<% elsif (@options.has_key? :esxiuser) && (@options.has_key? :esxipass) %> + # vmware_esxi provider begin + <%= system.name %>.vm.provider :vmware_esxi do |esxi| +<%= +" esxi.esxi_hostname = '#{@options[:esxiurl]}' + esxi.esxi_username = '#{@options[:esxiuser]}' + esxi.esxi_password = '#{@options[:esxipass]}' " + %> + +<%= if @options.has_key? :esxidatastore + " esxi.esxi_disk_store = '#{@options[:esxidatastore]}'" + end -%> +<%= if @options.has_key? :esxi_disktype +" esxi.guest_disk_type = '#{@options[:esxi_disktype]}'" + end -%> +<%= if @options.has_key? :memory_per_vm +" esxi.guest_memsize = '#{@options[:memory_per_vm]}'" + end -%> +<%= if @options.has_key? :cpu_cores +" esxi.guest_numvcpus = #{@options[:cpu_cores]}\n" + end -%> +end + # End ESXi provider <% else %> config.vm.provider :virtualbox do |vb| @@ -118,6 +143,10 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| <%= system.name %>.vm.hostname = '<%= "#{prefix}#{system.name}".tr('_', '-') %>' <%= system.name %>.vm.box = 'ovirt4' <%= system.name %>.vm.box_url = 'https://github.com/myoung34/vagrant-ovirt4/blob/master/example_box/dummy.box?raw=true' + <% elsif (@options.has_key? :esxiuser) && (@options.has_key? :esxipass) %> + <%= system.name %>.vm.hostname = '<%= "#{prefix}#{system.name}".tr('_', '-') %>' + <%= system.name %>.vm.box = "<%= selected_module.module_path_name %>" + <%= system.name %>.vm.box_url = "<%= selected_module.attributes['esxi_url'].first %>" <% else %> <%= system.name %>.vm.box = "<%= selected_module.module_path_name %>" <%= system.name %>.vm.box_url = "<%= selected_module.attributes['url'].first %>" diff --git a/modules/bases/debian_puppet_32/secgen_metadata.xml b/modules/bases/debian_puppet_32/secgen_metadata.xml index 171d99ba9..680dc3be6 100644 --- a/modules/bases/debian_puppet_32/secgen_metadata.xml +++ b/modules/bases/debian_puppet_32/secgen_metadata.xml @@ -16,6 +16,7 @@ unix Debian 7.8 (wheezy) 32-bit (i386) https://app.vagrantup.com/secgen/boxes/debian_wheezy_puppet/versions/1.0.0/providers/virtualbox.box + https://app.vagrantup.com/redwiz666/boxes/debian_wheezy_puppet/versions/1.0.0/providers/vmware_esxi.box debian_server https://atlas.hashicorp.com/puppetlabs diff --git a/modules/bases/debian_stretch/secgen_metadata.xml b/modules/bases/debian_stretch/secgen_metadata.xml index 8d90df6f0..b2e82c4f5 100644 --- a/modules/bases/debian_stretch/secgen_metadata.xml +++ b/modules/bases/debian_stretch/secgen_metadata.xml @@ -15,7 +15,8 @@ unix Debian 9.5.0 Stretch amd64 https://app.vagrantup.com/secgen/boxes/debian_stretch_server/versions/1.1/providers/virtualbox.box + https://app.vagrantup.com/redwiz666/boxes/debian_stretch_server/versions/1.0.0/providers/vmware.box debian_stretch_server_291118 various - \ No newline at end of file + diff --git a/modules/bases/debian_stretch_desktop_kde/secgen_metadata.xml b/modules/bases/debian_stretch_desktop_kde/secgen_metadata.xml index a4dbf3e21..236595e3a 100644 --- a/modules/bases/debian_stretch_desktop_kde/secgen_metadata.xml +++ b/modules/bases/debian_stretch_desktop_kde/secgen_metadata.xml @@ -14,6 +14,7 @@ unix Debian 9.5.0 Stretch amd64 https://app.vagrantup.com/secgen/boxes/debian_stretch_desktop_kde/versions/1.1/providers/virtualbox.box + https://app.vagrantup.com/redwiz666/boxes/debian_stretch_desktop_kde/versions/1.0.0/providers/vmware.box stretch_desktop_kde_301118 https://atlas.hashicorp.com/puppetlabs diff --git a/modules/bases/debian_wheezy_desktop_kde/secgen_metadata.xml b/modules/bases/debian_wheezy_desktop_kde/secgen_metadata.xml index a73992247..25700daf1 100644 --- a/modules/bases/debian_wheezy_desktop_kde/secgen_metadata.xml +++ b/modules/bases/debian_wheezy_desktop_kde/secgen_metadata.xml @@ -16,6 +16,7 @@ unix Debian 7.8 (wheezy) 32-bit (i386) https://app.vagrantup.com/secgen/boxes/debian_wheezy_kde_puppet/versions/1.0.0/providers/virtualbox.box + https://app.vagrantup.com/redwiz666/boxes/debian_wheezy_desktop_kde/versions/1.0.0/providers/vmware.box debian_desktop_kde https://atlas.hashicorp.com/puppetlabs diff --git a/modules/bases/kali_light/secgen_metadata.xml b/modules/bases/kali_light/secgen_metadata.xml index f7e1c7299..5b5b783eb 100644 --- a/modules/bases/kali_light/secgen_metadata.xml +++ b/modules/bases/kali_light/secgen_metadata.xml @@ -15,6 +15,7 @@ unix Kali Linux 2018.3 https://app.vagrantup.com/secgen/boxes/kali_light/versions/1.0/providers/virtualbox.box + https://app.vagrantup.com/redwiz666/boxes/kali_light/versions/1.0.0/providers/vmware.box https://app.vagrantup.com/secgen various diff --git a/modules/bases/kali_light_msf/secgen_metadata.xml b/modules/bases/kali_light_msf/secgen_metadata.xml index 38bebbd57..bd1c772ec 100644 --- a/modules/bases/kali_light_msf/secgen_metadata.xml +++ b/modules/bases/kali_light_msf/secgen_metadata.xml @@ -15,7 +15,9 @@ unix Kali Linux 2018.3 https://app.vagrantup.com/secgen/boxes/kali_light_msf/versions/1.0/providers/virtualbox.box + kali_linux_msf + https://app.vagrantup.com/secgen various diff --git a/modules/bases/ubuntu_xenial_64/secgen_metadata.xml b/modules/bases/ubuntu_xenial_64/secgen_metadata.xml index f013c4cfb..d28292bd1 100644 --- a/modules/bases/ubuntu_xenial_64/secgen_metadata.xml +++ b/modules/bases/ubuntu_xenial_64/secgen_metadata.xml @@ -15,6 +15,7 @@ unix Ubuntu Xenial 16.04 LTS https://app.vagrantup.com/puppetlabs/boxes/ubuntu-16.04-64-puppet/versions/1.0.0/providers/virtualbox.box + https://app.vagrantup.com/redwiz666/boxes/ubuntu-16.04-64-puppet/versions/1.0.0/providers/vmware_esxi.box debian_server https://atlas.hashicorp.com/puppetlabs diff --git a/secgen.rb b/secgen.rb index 817dfac89..b07ae262b 100644 --- a/secgen.rb +++ b/secgen.rb @@ -48,6 +48,14 @@ def usage --ovirt-network [ovirt_network_name] --ovirt-affinity-group [ovirt_affinity_group_name] + ESXI OPTIONS: + --esxiuser [esxi_username] + --esxipass [esxi_password] + --esxi-url [esxi_api_url] + --esxi-datastore [esxi_datastore] + --esxi-disktype [esxi_disktype] + --esxi-network [esxi_network_name] + COMMANDS: run, r: Builds project and then builds the VMs build-project, p: Builds project (vagrant and puppet config), but does not build VMs @@ -161,6 +169,7 @@ def build_vms(scenario, project_dir, options) Print.info "vagrant #{destroy} completed successfully." else OVirtFunctions::remove_uncreated_vms(destroy_output[:output], options, scenario) + # Add ESXI destroy uncreated VMs end else Print.err "Failed to destroy #{failed_vm}. Exiting." @@ -182,6 +191,15 @@ def build_vms(scenario, project_dir, options) end if successful_creation ovirt_post_build(options, scenario, project_dir) if OVirtFunctions.provider_ovirt?(options) + if options[:snapshot] + Print.info 'Creating a snapshot of VM(s)' + sleep(20) # give oVirt/Virtualbox a chance to save any VM config changes before creating the snapshot + if OVirtFunctions::provider_ovirt?(options) + OVirtFunctions::create_snapshot(options, scenario, get_vm_names(scenario)) + else + GemExec.exe('vagrant', project_dir, 'snapshot push') + end + end else Print.err "Failed to build VMs" exit 1 @@ -200,15 +218,6 @@ def ovirt_post_build(options, scenario, project_dir) Print.info 'Assigning affinity group of VM(s)' OVirtFunctions::assign_affinity_group(options, scenario, get_vm_names(scenario)) end - if options[:snapshot] - Print.info 'Creating a snapshot of VM(s)' - sleep(20) # give oVirt/Virtualbox a chance to save any VM config changes before creating the snapshot - if OVirtFunctions::provider_ovirt?(options) - OVirtFunctions::create_snapshot(options, scenario, get_vm_names(scenario)) - else - GemExec.exe('vagrant', project_dir, 'snapshot push') - end - end end # Make forensic image helper methods @@ -377,6 +386,11 @@ opts = GetoptLong.new( ['--ovirt-network', GetoptLong::REQUIRED_ARGUMENT], ['--ovirt-affinity-group', GetoptLong::REQUIRED_ARGUMENT], ['--snapshot', GetoptLong::NO_ARGUMENT], + ['--esxiuser', GetoptLong::REQUIRED_ARGUMENT], + ['--esxipass', GetoptLong::REQUIRED_ARGUMENT], + ['--esxi-url', GetoptLong::REQUIRED_ARGUMENT], + ['--esxi-datastore', GetoptLong::REQUIRED_ARGUMENT], + ['--esxi-network', GetoptLong::REQUIRED_ARGUMENT], ) scenario = SCENARIO_XML @@ -470,6 +484,28 @@ opts.each do |opt, arg| when '--snapshot' Print.info "Taking snapshots when VMs are created" options[:snapshot] = true + + when '--esxiuser' + Print.info "ESXi Username : #{arg}" + options[:esxiuser] = arg + when '--esxipass' + Print.info "ESXi Password : ********" + options[:esxipass] = arg + when '--esxi-url' + Print.info "ESXi host url : #{arg}" + options[:esxiurl] = arg + when '--esxi-datastore' + Print.info "ESXi datastore: #{arg}" + options[:esxidatastore] = arg + when '--esxi-network' + Print.info "ESXi Network Name : #{arg}" + options[:esxinetwork] = arg + when '--esxi-disktype' + Print.info "ESXi disk type : #{arg}" + options[:esxidisktype] = arg + when '--snapshot' + Print.info "Taking snapshots when VMs are created" + options[:snapshot] = true else Print.err "Argument not valid: #{arg}" @@ -515,6 +551,10 @@ case ARGV[0] make_forensic_image(project_dir, nil, image_type) end + when 'esxi-post-build' + esxi_post_build(options, scenario, project_dir) + exit 0 + when 'ovirt-post-build' ovirt_post_build(options, scenario, project_dir) exit 0