# Set 'password' using shell var: PKR_VAR_password=$(pwgen -s 8 1) variable "password" {} source "qemu" "bullseye-live" { iso_url = "https://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/debian-live-11.5.0-amd64-standard.iso" iso_checksum = "sha256:8172b188061d098080bb315972becbe9bd387c856866746cee018102cd00fc9b" output_directory = "output" shutdown_command = "echo 'packer' | sudo -S shutdown -P now" disk_size = "5000M" memory = 2048 format = "qcow2" accelerator = "kvm" http_directory = "." ssh_username = "user" ssh_password = var.password ssh_timeout = "5m" vm_name = "debianzfs.qcow2" net_device = "virtio-net" disk_interface = "virtio" boot_wait = "5s" boot_command = [ "", "", "sudo -i", "read -s userpw", "${var.password}", "PASSWORD=$(echo $userpw | openssl passwd -1 -stdin)", "usermod -p \"$PASSWORD\" user", "apt-get update && apt-get install -y ssh && \\", "systemctl start ssh && exit" ] } build { name = "zfs" sources = ["source.qemu.bullseye-live"] provisioner "file" { source = "debianzfs.sh" destination = "/tmp/debianzfs.sh" } provisioner "shell" { scripts = ["scripts/setup.sh"] } provisioner "shell" { inline = ["sudo /tmp/debianzfs.sh -ip changeme -P letmeinzfs! /dev/vda debianzfs"] } }