我正在使用Packer创建基于Ubuntu 16.04映像的AWS AMI。首先,我正在进行升级:
sudo apt-get update
sudo apt-get upgrade -y
这是我的预配器部分的相关部分:
"provisioners": [
{
"type": "shell",
"inline": [
"sudo apt-get update",
"sudo apt-get upgrade -y"
]
}
]
但是,这将打破自动化,因为会弹出一个交互式对话框:
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
我还尝试过设置export DEBIAN_FRONTEND=noninteractive
(如此答案中所建议)。不幸的是,这没有什么区别。
问题:
- 有没有办法通过迭代对话框(选择选项1会很好)?
- 是不是最好避免升级,而是相信AMI是最新的并包含关键的安全补丁?
背景:这是“构建器”部分的相关部分,在该部分中,我将其配置为使用最新的可用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
},
...
}]
注意:事实证明,noniteractive
如果同时使用-y
和-q
标志运行apt-get update ,则该模式有效。
apt-get update ; DEBIAN_FRONTEND=noninteractive apt-get upgrade -yq
。我认为 不需要apt-get update
任何提示,因此它可能不需要DEBIAN_FRONTEND
,因此您实际上并不需要,并且export
DEBIAN_FRONTEND
在整个环境中都可以继续使用它。无论对您有多重要。