I'm using Packer to create an AWS AMI based on an Ubuntu 16.04 image. In the beginning, I'm doing an upgrade:
sudo apt-get update
sudo apt-get upgrade -y
Here 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 situation
I 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 you run apt-get update with both the -y
and the -q
flag.