Hi all,
I am trying to build RAW type image of Windows server 2019, so I decided to try using QEMU builder.
The packer version is 1.8.3.
The problem I am facing is that WinRM fails to connect and I am thinking its related to qemu user network stack. The IP range is 10.0.2.0/24 and I have no way to connect to it from QEMU host. I have tried numerous options with qemuargs but ultimately failed to solve it.
Was also trying to find a way to utilize virbr0 or actual bridged interface but that does not seem to work with WIndows, Linux only.
Here is my main packer config file.
source "qemu" "testimage" {
accelerator = "kvm"
boot_wait = "10s"
communicator = "winrm"
# configuration_version = "8.0"
cpus = "${var.cpus}"
memory = "${var.memory}"
disk_size = "${var.disk_size}"
disk_interface = "ide"
net_device = "virtio-net"
# net_bridge = "bridge0"
qemu_binary = "/usr/bin/qemu-system-x86_64"
qemuargs = [["-m", "${var.memory}"],
["-smp", "${var.cpus}"],
# [ "-device", "virtio-net,netdev=user.0"],
# [ "-netdev", "user,hostfwd=tcp::2222-:5985,id=forward"],
# [ "-netdev", "user,id=user.0,", "hostfwd=tcp::2222-:5985", "net=192.168.122.1/24" ],
# [ "-device", "virtio-net,netdev=user.0"],
["-vga", "qxl"]]
floppy_files = ["${var.autounattend}",
"./scripts/unattend.xml",
"./scripts/domainjoin.ps1",
"./scripts/sysprep.bat",
"./scripts/enable-winrm.ps1",
"./drivers/vioserial/2k19/amd64/*.cat",
"./drivers/vioserial/2k19/amd64/*.inf",
"./drivers/vioserial/2k19/amd64/*.sys",
"./drivers/viostor/2k19/amd64/*.cat",
"./drivers/viostor/2k19/amd64/*.inf",
"./drivers/viostor/2k19/amd64/*.sys",
"./drivers/NetKVM/2k19/amd64/*.cat",
"./drivers/NetKVM/2k19/amd64/*.inf",
"./drivers/NetKVM/2k19/amd64/*.sys",
"./drivers/qxldod/2k19/amd64/*.cat",
"./drivers/qxldod/2k19/amd64/*.inf",
"./drivers/qxldod/2k19/amd64/*.sys",
"./software/MetashapeFloating.lic",
"./software/newrelic-infra.yml",
"./software/flex-gpu.yml" ]
cd_files = [ "${var.software_directory}" ]
iso_checksum = "${var.iso_checksum}"
iso_url = "${var.iso_url}"
shutdown_command = "a:/sysprep.bat"
shutdown_timeout = "10m"
headless = var.headless
format = "raw"
vm_name = "testimage"
winrm_password = "${var.password}"
winrm_timeout = "${var.winrm_timeout}"
winrm_username = "${var.username}"
winrm_use_ssl = false
winrm_insecure = true
output_directory = "artifacts/qemu/${var.os_name}${var.os_version}"
}
build {
sources = ["source.qemu.testimage"]
provisioner "windows-shell" {
execute_command = "{{ .Vars }} cmd /c \"{{ .Path }}\""
scripts = ["./scripts/dotnetfm-install.bat"]
environment_vars = ["dotnetfm_package=${var.dotnetfm_package}"]
valid_exit_codes = [ 0, 3010 ]
}
provisioner "windows-shell" {
scripts = [ "./scripts/hosts-restore.bat", "./scripts/compact.bat"]
}
}
I would really appreciate if someone was able to solve this as I am out of ideas.
The network on my Linux host, where I am running QEMU and trying to build images is:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp5s0f3u2u2c2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
link/ether 7a:30:6f:58:07:96 brd ff:ff:ff:ff:ff:ff
inet 169.254.3.1/24 brd 169.254.3.255 scope link noprefixroute dynamic enp5s0f3u2u2c2
valid_lft 772909sec preferred_lft 772909sec
inet6 fe80::32c6:79c3:a940:8b16/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master bridge0 state UP group default qlen 1000
link/ether 3c:ec:ef:71:87:fe brd ff:ff:ff:ff:ff:ff
9: bridge0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 3c:ec:ef:71:87:fe brd ff:ff:ff:ff:ff:ff
inet 10.3.43.202/24 brd 10.3.43.255 scope global noprefixroute dynamic bridge0
valid_lft 3316sec preferred_lft 3316sec
inet6 fe80::3eec:efff:fe71:87fe/64 scope link noprefixroute
valid_lft forever preferred_lft forever
15: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:a4:fe:43 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
16: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:a4:fe:43 brd ff:ff:ff:ff:ff:ff
I was able to successfully build several different types of Linux distro but trying to build this windows server 2019 version with Winrm communicator is just not moving forward.
If you have any suggestions or need more information, please let me know.