大网数据广告活动
服务器运维问答

inconsistent `apt-get update` behaviour on official Ubuntu AWS AMI

· 52CE 我爱测

I get various and inconsistent errors with apt on the official Ubuntu images ( ami-83e769fb ). I'm using Packer to build my AMI and it fails about 40% of the time. Rerunning the script succeeds. My script runs: sudo apt-get clean…

问题原文

原帖链接 · Mystic · CC BY-SA 3.0

I get various and inconsistent errors with apt on the official Ubuntu images (ami-83e769fb). I'm using Packer to build my AMI and it fails about 40% of the time. Rerunning the script succeeds.

My script runs:

sudo apt-get clean all
sudo apt-get update

before install any packages.

Some times I get this error:

amazon-ebs: W: GPG error: http://archive.ubuntu.com/ubuntu artful InRelease: Splitting up /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_artful_InRelease into data and signature failed
amazon-ebs: E: The repository 'http://archive.ubuntu.com/ubuntu artful InRelease' is not signed.

Some times apt-get update hits http://us-west-2.ec2.archive.ubuntu.com/ubuntu ... other times it doesn't.

Other times packages are missing (like apache2 or python3).

I don't understand why this behaviour is inconsistent.

How can I get apt-get update on the official Ubuntu AMI to work consistently?

社区高分解答

原帖链接 · dnozay · CC BY-SA 4.0

If you are using cloud-init you can wait for it to complete.

while [ ! -f /var/lib/cloud/instance/boot-finished ]; do
   echo 'Waiting for cloud-init...'
   sleep 1
done

e.g. packer json:

{
  "type": "shell",
  "inline": [
    "while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done"
  ]
}

Reference:

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-03-22)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。