I found this question and basically had the same problem with my script.
But! I am not running it with packer but with a simple script:
DEBIAN_FRONTEND=noninteractive sudo apt-get update DEBIAN_FRONTEND=noninteractive sudo dpkg --configure -aq DEBIAN_FRONTEND=noninteractive sudo apt-get upgrade -yq --force-yes DEBIAN_FRONTEND=noninteractive sudo apt-get dist-upgrade -yq --force-yes
...and other things.
The script did work on 1404, but with 1604 Xenial and 1804 Bionic I am getting the problem, that the dialog prompt wants to open in the script and doesn't continue on his own. This is because I can't respond with keyboard inputs on the workstation.
This solution seems to be too risky for GRUB in my opinion, but I need to automate because I can't update hundreds of servers manually.
I think this is a problem for all "new" 1604 and 1804 machines.
Does anybody know a solution for this?
Update: I trie this accepted answer solution and it gave me the following error:
E: Invalid operation Dpkg::Options::=--force-confdef