Packer error – sudo: no tty present and no askpass program specified

I'm been learning how to use Packer this week on my home lab where I have an ESXi 7 host.

I'm simply trying to deploy a Ubuntu 18.04 VM however at the end of the build I get this error in the packer console:

sudo: no tty present and no askpass program specified

This is what I have done.

Build.json

Preseed.cfg

variables.json

Command I run:

sudo packer build -var-file=variables.json build.json

In ESXi I see the VM build and complete and reboot and it gets an IP and I get a SSH prompt briefly before Packer deletes the VM after I see the above message.

This is the full error:

==> Ubuntu-18.04: Connecting to VNC over websocket...
==> Ubuntu-18.04: Waiting 10s for boot...
==> Ubuntu-18.04: Typing the boot command over VNC...
==> Ubuntu-18.04: Waiting for SSH to become available...
==> Ubuntu-18.04: Connected to SSH!
==> Ubuntu-18.04: Provisioning with shell script: /tmp/packer-shell382031289
==> Ubuntu-18.04: sudo: no tty present and no askpass program specified
==> Ubuntu-18.04: Provisioning step had errors: Running the cleanup provisioner, if present...
==> Ubuntu-18.04: Stopping virtual machine...
==> Ubuntu-18.04: Destroying virtual machine...
Build 'Ubuntu-18.04' errored after 8 minutes 21 seconds: Script exited with non-zero exit status: 1.Allowed exit codes are: [0]

==> Wait completed after 8 minutes 21 seconds

==> Some builds didn't complete successfully and had errors:
--> Ubuntu-18.04: Script exited with non-zero exit status: 1.Allowed exit codes are: [0]

==> Builds finished but no artifacts were created.

What am I doing wrong?



Read more here: https://stackoverflow.com/questions/66186534/packer-error-sudo-no-tty-present-and-no-askpass-program-specified

Content Attribution

This content was originally published by Andy White at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: