5

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
muru
  • 197,895
  • 55
  • 485
  • 740
Horsty
  • 153
  • 2
  • 7
  • "I am getting the problem very often" what problem, exactly? FWIW I would expect the DEBIAN_FRONTEND=noninteractive assignment to go after sudo, not before – steeldriver Sep 11 '18 at 12:29
  • 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. The dialog is prompting on the server. – Horsty Sep 11 '18 at 12:37
  • @steeldriver I am testing your remark now and put the DEBIAN_FRONTEND=noninteractive after the sudo and it seems that it does the trick. I thank you very much for this comment. It seems that this is the little thing that hindered my script from working. – Horsty Sep 11 '18 at 12:43
  • Shall I post the solution as an answer or do you want to do it? Then I can mark it as accepted. Damn, you just saved me precious hours! I am very glad. Thank you! – Horsty Sep 11 '18 at 12:45
  • This is more general than Ubuntu and a more comprehensive answer is on https://serverfault.com/questions/227190/how-do-i-ask-apt-get-to-skip-any-interactive-post-install-configuration-steps – Stéphane Gourichon Jun 26 '19 at 12:45

1 Answers1

5

You need to set DEBIAN_FRONTEND=noninteractive inside the sudo environment - not before it:

Ex.

$ sudo DEBIAN_FRONTEND=noninteractive sh -c 'echo $DEBIAN_FRONTEND'
noninteractive

whereas

$ DEBIAN_FRONTEND=noninteractive sudo sh -c 'echo $DEBIAN_FRONTEND'
(empty)
steeldriver
  • 136,215
  • 21
  • 243
  • 336