diff --git a/.gitignore b/.gitignore index 7b0b144..9ee2540 100755 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ inventory.yml.bak *.box manifest.xml HyperV/.vagrant/* -logger_variables.sh \ No newline at end of file +logger_variables.sh +ESXi/Packer/variables.json diff --git a/ESXi/Packer/ubuntu1804_esxi.json b/ESXi/Packer/ubuntu1804_esxi.json index 77d8a3d..d7e7ef8 100644 --- a/ESXi/Packer/ubuntu1804_esxi.json +++ b/ESXi/Packer/ubuntu1804_esxi.json @@ -26,36 +26,45 @@ "" ], "boot_wait": "10s", - "keep_registered": true, - "remote_datastore": "{{user `esxi_datastore`}}", - "remote_host": "{{user `esxi_host`}}", - "remote_username": "{{user `esxi_username`}}", - "remote_password": "{{user `esxi_password`}}", - "remote_type": "esx5", - "vnc_disable_password": true, - "vnc_port_min": 5900, - "vnc_port_max": 5980, + "cpus": "{{ user `cpus` }}", "disk_size": "{{user `disk_size`}}", "guest_os_type": "ubuntu-64", "http_directory": "{{user `http_directory`}}", "iso_checksum": "{{user `iso_checksum`}}", "iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}", + "keep_registered": true, "shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now", "ssh_password": "vagrant", "ssh_port": 22, "ssh_username": "vagrant", "ssh_timeout": "10000s", - "pause_before_connecting": "10m", + "memory": "{{ user `memory` }}", + "pause_before_connecting": "1m", + "remote_datastore": "{{user `esxi_datastore`}}", + "remote_host": "{{user `esxi_host`}}", + "remote_username": "{{user `esxi_username`}}", + "remote_password": "{{user `esxi_password`}}", + "remote_type": "esx5", + "skip_export": true, "tools_upload_flavor": "linux", "type": "vmware-iso", "vm_name": "Ubuntu1804", - "memory": "{{ user `memory` }}", - "cpus": "{{ user `cpus` }}", "vmx_data": { "ethernet0.networkName": "{{user `esxi_network_with_dhcp_and_internet` }}", "cpuid.coresPerSocket": "1", - "ethernet0.pciSlotNumber": "32" - } + "ethernet0.pciSlotNumber": "32", + "tools.syncTime": "0", + "time.synchronize.continue": "0", + "time.synchronize.restore": "0", + "time.synchronize.resume.disk": "0", + "time.synchronize.shrink": "0", + "time.synchronize.tools.startup": "0", + "time.synchronize.tools.enable": "0", + "time.synchronize.resume.host": "0" + }, + "vnc_disable_password": true, + "vnc_port_min": 5900, + "vnc_port_max": 5980 } ], "provisioners": [ diff --git a/ESXi/Packer/windows_10_esxi.json b/ESXi/Packer/windows_10_esxi.json index 5b6964e..791d848 100644 --- a/ESXi/Packer/windows_10_esxi.json +++ b/ESXi/Packer/windows_10_esxi.json @@ -1,31 +1,10 @@ { "builders": [ { - "vnc_disable_password": true, - "keep_registered": true, - "remote_datastore": "{{user `esxi_datastore`}}", - "remote_host": "{{user `esxi_host`}}", - "remote_username": "{{user `esxi_username`}}", - "remote_password": "{{user `esxi_password`}}", - "remote_type": "esx5", - "type": "vmware-iso", - "vm_name":"Windows10", - "communicator": "winrm", - "iso_url": "{{user `iso_url`}}", - "iso_checksum": "{{user `iso_checksum`}}", - "headless": false, "boot_wait": "6m", "boot_command": "", - "winrm_username": "vagrant", - "winrm_password": "vagrant", - "winrm_timeout": "4h", - "shutdown_timeout": "2h", - "shutdown_command": "a:/sysprep.bat", - "guest_os_type": "windows9-64", - "disk_size": "{{user `disk_size`}}", - "vnc_port_min": 5900, - "vnc_port_max": 5980, - "version": 11, + "communicator": "winrm", + "disk_size": 61440, "floppy_files": [ "{{user `autounattend`}}", "../../Packer/floppy/WindowsPowershell.lnk", @@ -40,12 +19,42 @@ "../../Packer/scripts/unattend.xml", "../../Packer/scripts/sysprep.bat" ], + "guest_os_type": "windows9-64", + "keep_registered": true, + "headless": false, + "iso_url": "{{user `iso_url`}}", + "iso_checksum": "{{user `iso_checksum`}}", + "shutdown_timeout": "2h", + "shutdown_command": "a:/sysprep.bat", + "skip_export": true, + "remote_datastore": "{{user `esxi_datastore`}}", + "remote_host": "{{user `esxi_host`}}", + "remote_username": "{{user `esxi_username`}}", + "remote_password": "{{user `esxi_password`}}", + "remote_type": "esx5", + "type": "vmware-iso", + "version": 11, + "vm_name": "Windows10", + "vnc_disable_password": true, + "vnc_port_min": 5900, + "vnc_port_max": 5980, "vmx_data": { "ethernet0.networkName": "{{user `esxi_network_with_dhcp_and_internet`}}", "memsize": "2048", "numvcpus": "2", - "scsi0.virtualDev": "lsisas1068" - } + "scsi0.virtualDev": "lsisas1068", + "tools.syncTime": "0", + "time.synchronize.continue": "0", + "time.synchronize.restore": "0", + "time.synchronize.resume.disk": "0", + "time.synchronize.shrink": "0", + "time.synchronize.tools.startup": "0", + "time.synchronize.tools.enable": "0", + "time.synchronize.resume.host": "0" + }, + "winrm_username": "vagrant", + "winrm_password": "vagrant", + "winrm_timeout": "4h" } ], "provisioners": [ @@ -93,8 +102,7 @@ "esxi_password": "", "iso_checksum": "sha256:ab4862ba7d1644c27f27516d24cb21e6b39234eb3301e5f1fb365a78b22f79b3", "iso_url": "https://software-download.microsoft.com/download/pr/18362.30.190401-1528.19h1_release_svc_refresh_CLIENTENTERPRISEEVAL_OEMRET_x64FRE_en-us.iso", - "autounattend": "../../Packer/answer_files/10/Autounattend.xml", - "disk_size": "61440" + "autounattend": "../../Packer/answer_files/10/Autounattend.xml" } } diff --git a/ESXi/Packer/windows_2016_esxi.json b/ESXi/Packer/windows_2016_esxi.json index 9242bfa..6509d5a 100644 --- a/ESXi/Packer/windows_2016_esxi.json +++ b/ESXi/Packer/windows_2016_esxi.json @@ -1,28 +1,9 @@ { "builders": [ { - "vnc_disable_password": true, - "keep_registered": true, - "remote_datastore": "{{user `esxi_datastore`}}", - "remote_host": "{{user `esxi_host`}}", - "remote_username": "{{user `esxi_username`}}", - "remote_password": "{{user `esxi_password`}}", - "remote_type": "esx5", - "vm_name":"WindowsServer2016", - "type": "vmware-iso", - "communicator": "winrm", - "iso_url": "{{user `iso_url`}}", - "iso_checksum": "{{user `iso_checksum`}}", - "headless": false, "boot_wait": "2m", - "winrm_username": "vagrant", - "winrm_password": "vagrant", - "winrm_timeout": "4h", - "shutdown_timeout": "2h", - "shutdown_command": "a:/sysprep.bat", - "guest_os_type": "windows8srv-64", + "communicator": "winrm", "disk_size": 61440, - "version": 11, "floppy_files": [ "{{user `autounattend`}}", "../../Packer/floppy/WindowsPowershell.lnk", @@ -35,12 +16,40 @@ "../../Packer/scripts/microsoft-updates.bat", "../../Packer/scripts/win-updates.ps1" ], + "guest_os_type": "windows8srv-64", + "headless": false, + "iso_url": "{{user `iso_url`}}", + "iso_checksum": "{{user `iso_checksum`}}", + "keep_registered": true, + "shutdown_timeout": "2h", + "shutdown_command": "a:/sysprep.bat", + "skip_export": true, + "remote_datastore": "{{user `esxi_datastore`}}", + "remote_host": "{{user `esxi_host`}}", + "remote_username": "{{user `esxi_username`}}", + "remote_password": "{{user `esxi_password`}}", + "remote_type": "esx5", + "type": "vmware-iso", + "version": 11, + "vm_name": "WindowsServer2016", + "vnc_disable_password": true, "vmx_data": { "ethernet0.networkName": "{{user `esxi_network_with_dhcp_and_internet`}}", "memsize": "2048", "numvcpus": "2", - "scsi0.virtualDev": "lsisas1068" - } + "scsi0.virtualDev": "lsisas1068", + "tools.syncTime": "0", + "time.synchronize.continue": "0", + "time.synchronize.restore": "0", + "time.synchronize.resume.disk": "0", + "time.synchronize.shrink": "0", + "time.synchronize.tools.startup": "0", + "time.synchronize.tools.enable": "0", + "time.synchronize.resume.host": "0" + }, + "winrm_username": "vagrant", + "winrm_password": "vagrant", + "winrm_timeout": "4h" } ], "provisioners": [ diff --git a/ESXi/ansible/inventory.yml b/ESXi/ansible/inventory.yml index a00fe41..46f3205 100644 --- a/ESXi/ansible/inventory.yml +++ b/ESXi/ansible/inventory.yml @@ -7,7 +7,7 @@ logger: ansible_password: vagrant ansible_port: 22 ansible_connection: ssh - ansible_ssh_common_args: '-o StrictHostKeyChecking=no' + ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null' dc: hosts: diff --git a/ESXi/main.tf b/ESXi/main.tf index b329810..215a93e 100644 --- a/ESXi/main.tf +++ b/ESXi/main.tf @@ -18,16 +18,6 @@ resource "esxi_guest" "logger" { guest_name = "logger" disk_store = var.esxi_datastore guestos = "ubuntu-64" - custom_vmx_settings = [ - ['tools.syncTime', '0'], - ['time.synchronize.continue', '0'], - ['time.synchronize.restore', '0'], - ['time.synchronize.resume.disk', '0'], - ['time.synchronize.shrink', '0'], - ['time.synchronize.tools.startup', '0'], - ['time.synchronize.tools.enable', '0'], - ['time.synchronize.resume.host', '0'] - ] boot_disk_type = "thin" @@ -39,9 +29,8 @@ resource "esxi_guest" "logger" { provisioner "remote-exec" { inline = [ - "sudo ifconfig eth1 up || echo 'eth1 up'", - "sudo ifconfig eth2 up || echo 'eth2 up'", - "sudo route add default gw 192.168.76.1 || echo 'route exists'" + "sudo ifconfig eth0 up && echo 'eth0 up' || echo 'unable to bring eth0 interface up", + "sudo ifconfig eth1 up && echo 'eth1 up' || echo 'unable to bring eth1 interface up" ] connection { @@ -80,16 +69,6 @@ resource "esxi_guest" "dc" { guest_name = "dc" disk_store = var.esxi_datastore guestos = "windows9srv-64" - custom_vmx_settings = [ - ['tools.syncTime', '0'], - ['time.synchronize.continue', '0'], - ['time.synchronize.restore', '0'], - ['time.synchronize.resume.disk', '0'], - ['time.synchronize.shrink', '0'], - ['time.synchronize.tools.startup', '0'], - ['time.synchronize.tools.enable', '0'], - ['time.synchronize.resume.host', '0'] - ] boot_disk_type = "thin" @@ -118,16 +97,6 @@ resource "esxi_guest" "wef" { guest_name = "wef" disk_store = var.esxi_datastore guestos = "windows9srv-64" - custom_vmx_settings = [ - ['tools.syncTime', '0'], - ['time.synchronize.continue', '0'], - ['time.synchronize.restore', '0'], - ['time.synchronize.resume.disk', '0'], - ['time.synchronize.shrink', '0'], - ['time.synchronize.tools.startup', '0'], - ['time.synchronize.tools.enable', '0'], - ['time.synchronize.resume.host', '0'] - ] boot_disk_type = "thin" @@ -156,16 +125,6 @@ resource "esxi_guest" "win10" { guest_name = "win10" disk_store = var.esxi_datastore guestos = "windows9-64" - custom_vmx_settings = [ - ['tools.syncTime', '0'], - ['time.synchronize.continue', '0'], - ['time.synchronize.restore', '0'], - ['time.synchronize.resume.disk', '0'], - ['time.synchronize.shrink', '0'], - ['time.synchronize.tools.startup', '0'], - ['time.synchronize.tools.enable', '0'], - ['time.synchronize.resume.host', '0'] - ] boot_disk_type = "thin" diff --git a/ESXi/variables.tf b/ESXi/variables.tf index b907d0b..052bc07 100644 --- a/ESXi/variables.tf +++ b/ESXi/variables.tf @@ -1,7 +1,8 @@ # # See https://www.terraform.io/intro/getting-started/variables.html for more details. # -# Change these defaults to fit your needs! +# Don't change the variables in this file! +# Instead, create a terrform.tfvars file to override them. variable "esxi_hostname" { default = ""