/** * Packer template for building MSVSphere 10 ovf image. */ source "vmware-iso" "msvsphere-10-ovf-x86_64" { iso_url = var.iso_url_10_x86_64 iso_checksum = var.iso_checksum_10_x86_64 http_directory = var.http_directory shutdown_command = var.vagrant_shutdown_command ssh_username = var.vagrant_ssh_username ssh_password = var.vagrant_ssh_password ssh_timeout = var.ssh_timeout boot_command = var.vagrant_boot_cmd_10_x86_64_bios boot_wait = var.boot_wait disk_size = var.vagrant_disk_size guest_os_type = "centos-64" version = 21 vm_name = "MSVSphere-${var.os_version_10}-${formatdate("YYYYMMDD", timestamp())}.ovf.x86_64" cpus = var.cpus memory = var.memory network_adapter_type = "vmxnet3" headless = var.headless vmx_remove_ethernet_interfaces = true vmx_data = { "cpuid.coresPerSocket" : "1" } vmx_data_post = { "memsize" : var.post_memory "numvcpus" : var.post_cpus } } build { sources = [ "sources.vmware-iso.msvsphere-10-ovf-x86_64" ] provisioner "ansible" { playbook_file = "ansible/ovf.yml" galaxy_file = "ansible/requirements.yml" roles_path = "ansible/roles" collections_path = "ansible/collections" ansible_env_vars = [ "ANSIBLE_PIPELINING=True", "ANSIBLE_REMOTE_TEMP=/tmp", "ANSIBLE_SSH_ARGS='-o ControlMaster=no -o ControlPersist=180s -o ServerAliveInterval=120s -o TCPKeepAlive=yes -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa'" ] extra_arguments = [ "--extra-vars", "packer_provider=${source.type}" ] } post-processor "shell-local"{ inline = ["rm -rf vmware-iso.msvsphere-10-ovf-x86_64_ovf", "mkdir vmware-iso.msvsphere-10-ovf-x86_64_ovf", "/usr/lib/vmware-ovftool/ovftool --machineOutput --X:logFile=./ovftool.log --X:logLevel=verbose --exportFlags=extraconfig --allowExtraConfig --X:vCloudEnableGuestCustomization ./output-msvsphere-10-ovf-x86_64/MSVSphere-${var.os_version_10}-${formatdate("YYYYMMDD", timestamp())}.ovf.x86_64.vmx ./vmware-iso.msvsphere-10-ovf-x86_64_ovf" ] } }