{ "variables": { "iso_url": "https://software-static.download.prss.microsoft.com/pr/download/17763.737.190906-2324.rs5_release_svc_refresh_SERVER_EVAL_x64FRE_en-us_1.iso", "iso_path": "{{pwd}}/iso/17763.737.190906-2324.rs5_release_svc_refresh_SERVER_EVAL_x64FRE_en-us_1.iso", "iso_sha256": "sha256:549bca46c055157291be6c22a3aaaed8330e78ef4382c99ee82c896426a1cee1", "timestamp": "{{isotime `2006-01-02`}}", "headless": "false", "boot_wait": "2s", "name": "winserver2019", "cpu": "2", "cores": "2", "ram": "4096", "disk_size": "102400", "communicator_username": "packer", "communicator_password": "packer" }, "builders": [ { "type": "qemu", "format": "qcow2", "accelerator": "kvm", "net_device": "e1000", "disk_interface": "virtio", "headless": "{{user `headless`}}", "name": "qemu", "vm_name": "qemu-{{user `name`}}_{{user `timestamp`}}", "disk_size": "{{user `disk_size`}}", "disk_cache": "none", "disk_discard": "unmap", "disk_compression": true, "communicator": "winrm", "winrm_username": "{{user `communicator_username`}}", "winrm_password": "{{user `communicator_password`}}", "winrm_timeout": "99h", "shutdown_command": "C:\\sysprep-shutdown.bat", "boot_wait": "2s", "boot_command": ["", "", "", "", "", "", "", ""], "iso_urls": [ "{{user `iso_path`}}", "{{user `iso_url`}}" ], "cd_files": [ "files/drivers", "files/answer_files/windows/2019/autounattend.xml", "files/answer_files/windows/sysprep/sysprep.xml", "files/scripts/windows/enable-winrm-http.ps1" ], "iso_checksum": "{{user `iso_sha256`}}", "iso_target_path": "{{user `iso_path`}}", "output_directory": "qemu_output_{{user `name`}}", "qemuargs": [ ["-m", "{{user `ram`}}M"], ["-cpu", "host"], ["-smp", "cpus={{user `cpu`}}"] ] } ], "provisioners": [ { "type": "powershell", "elevated_user": "{{user `communicator_username`}}", "elevated_password": "{{user `communicator_password`}}", "pause_before": "30s", "script": "files/scripts/windows/init.ps1" }, { "type": "file", "source": "files/scripts/windows/sysprep-shutdown.bat", "destination": "C:\\sysprep-shutdown.bat" }, { "type": "powershell", "elevated_user": "Administrator", "elevated_password": "{{user `communicator_password`}}", "pause_before": "30s", "valid_exit_codes": ["3010", "1168"], "inline": [ "DISM /Online /Set-edition:ServerStandard /ProductKey:N69G4-B89J2-4G8F4-WWYCC-J464C /AcceptEula /NoRestart /Quiet" ] }, { "type": "windows-restart", "restart_timeout": "30m", "restart_command": "shutdown /r /f /t 0 /c \"packer restart\"", "restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\"" }, { "type": "powershell", "only": ["qemu"], "elevated_user": "{{user `communicator_username`}}", "elevated_password": "{{user `communicator_password`}}", "pause_before": "30s", "script": "files/scripts/windows/setup-qemu-guest-agent.ps1" }, { "type": "windows-restart", "restart_timeout": "30m", "restart_command": "shutdown /r /f /t 0 /c \"packer restart\"", "restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\"" }, { "type": "powershell", "elevated_user": "{{user `communicator_username`}}", "elevated_password": "{{user `communicator_password`}}", "pause_before": "30s", "script": "files/scripts/windows/cleanup.ps1" }, { "type": "windows-restart", "restart_timeout": "30m", "restart_command": "shutdown /r /f /t 0 /c \"packer restart\"", "restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\"" } ], "post-processors": [ { "type": "shell-local", "only_on": ["linux"], "environment_vars": [ "NAME={{user `name`}}", "TIMESTAMP={{user `timestamp`}}" ], "script": "files/scripts/create-checksums.sh" } ] }