snippetMajor
How to avoid interactive dialogs when running "apt-get upgrade -y" in Ubuntu 16.04 when packaging with Packer?
Viewed 0 times
interactivehowpackerubuntuwithaptavoidrunninggetpackaging
Problem
I'm using Packer to create an AWS AMI based on an Ubuntu 16.04 image. In the beginning, I'm doing an upgrade:
Here is the relevant part of my provisioners section:
This breaks the automatization, however, as an interactive dialog pops up:
I also tried to set
Questions:
Background: This is the relevant part of my "builders" section, where I configured it to use the latest available AMI:
Note: Turns out that the
sudo apt-get update
sudo apt-get upgrade -yHere is the relevant part of my provisioners section:
"provisioners": [
{
"type": "shell",
"inline": [
"sudo apt-get update",
"sudo apt-get upgrade -y"
]
}
]This breaks the automatization, however, as an interactive dialog pops up:
amazon-ebs: Found kernel: /boot/vmlinuz-4.4.0-72-generic
amazon-ebs: A new version of /boot/grub/menu.lst is available, but the version installed
amazon-ebs: currently has been locally modified.
amazon-ebs:
amazon-ebs: 1. install the package maintainer's version
amazon-ebs: 2. keep the local version currently installed
amazon-ebs: 3. show the differences between the versions
amazon-ebs: 4. show a side-by-side difference between the versions
amazon-ebs: 5. show a 3-way difference between available versions
amazon-ebs: 6. do a 3-way merge between available versions (experimental)
amazon-ebs: 7. start a new shell to examine the situationI also tried to set
export DEBIAN_FRONTEND=noninteractive before (as recommended in this answer). Unfortunately, it makes no difference.Questions:
- Is there a way to get past the iteractive dialog (selecting option 1 would be fine)?
- Is it instead better to avoid upgrades and instead trust that the AMIs are up to date and contain the critical security patches?
Background: This is the relevant part of my "builders" section, where I configured it to use the latest available AMI:
"builders": [{
"type": "amazon-ebs",
"region": "eu-central-1",
...
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "*ubuntu-xenial-16.04-amd64-server-*",
"root-device-type": "ebs"
},
"owners": ["099720109477"],
"most_recent": true
},
...
}]Note: Turns out that the
noniteractive mode works if youSolution
This sequence of commands works for me:
So,
Source: https://github.com/moby/moby/issues/4032
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get upgrade -yqSo,
DEBIAN_FRONTEND=noninteractive is correct but you also need the -q flag.Source: https://github.com/moby/moby/issues/4032
Code Snippets
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get upgrade -yqContext
StackExchange DevOps Q#1139, answer score: 26
Revisions (0)
No revisions yet.