AMI-3b054701
リージョンのap-southeast-2
に基づいてAMIを作成しようとしています。 Packer構成には、1つのシンプルなプロビジョニング機能があります。
#!/bin/bash -e
info() {
echo -e "[INFO] $1\n"
}
exec_cmd() {
echo -e "\n[INFO] $1\n"
eval $1
}
exec_cmd "apt-get update"
exec_cmd "apt-get -y upgrade"
exec_cmd "apt-get -y install build-essential git Zip unzip wget default-jre"
これは問題なく動作する場合もありますが、次のエラーで失敗する場合もあります。
AMI: [INFO] apt-get -y install build-essential git Zip unzip wget default-jre
AMI:
AMI: Reading package lists... Done
AMI: Building dependency tree
AMI: Reading state information... Done
AMI: Package build-essential is not available, but is referred to by another package.
AMI: This may mean that the package is missing, has been obsoleted, or
AMI: is only available from another source
AMI:
AMI: Package default-jre is not available, but is referred to by another package.
AMI: This may mean that the package is missing, has been obsoleted, or
AMI: is only available from another source
AMI:
AMI: Package Zip is not available, but is referred to by another package.
AMI: This may mean that the package is missing, has been obsoleted, or
AMI: is only available from another source
AMI:
AMI: E: Package 'build-essential' has no installation candidate
AMI: E: Package 'Zip' has no installation candidate
AMI: E: Package 'default-jre' has no installation candidate
これを避ける方法を見つけるために丸一日を無駄にしました。推奨される Stack Exchangeのソリューション がありますが、それはソリューションというよりもハックです。このエラーが断続的に発生するのを防ぐ方法はありますか?
これがPackerの完全な出力です。
==> AMI: Prevalidating AMI Name...
==> AMI: Inspecting the source AMI...
==> AMI: Creating temporary keypair: packer 55d33324-e319-bd49-24c5-c06a18b4fe09
==> AMI: Launching a source AWS instance...
AMI: Instance ID: i-8b78cd55
==> AMI: Waiting for instance (i-8b78cd55) to become ready...
==> AMI: Waiting for SSH to become available...
==> AMI: Connected to SSH!
==> AMI: Provisioning with Shell script: scripts/provision.sh
AMI:
AMI: [INFO] apt-get update
AMI:
AMI: Ign http://security.ubuntu.com trusty-security InRelease
AMI: Ign http://archive.ubuntu.com trusty InRelease
AMI: Get:1 http://security.ubuntu.com trusty-security Release.gpg [933 B]
AMI: Ign http://archive.ubuntu.com trusty-updates InRelease
AMI: Get:2 http://security.ubuntu.com trusty-security Release [63.5 kB]
AMI: Hit http://archive.ubuntu.com trusty Release.gpg
AMI: Get:3 http://archive.ubuntu.com trusty-updates Release.gpg [933 B]
AMI: Hit http://archive.ubuntu.com trusty Release
AMI: Get:4 http://archive.ubuntu.com trusty-updates Release [63.5 kB]
AMI: Get:5 http://security.ubuntu.com trusty-security/main AMD64 Packages [333 kB]
AMI: Get:6 http://security.ubuntu.com trusty-security/restricted AMD64 Packages [8875 B]
AMI: Hit http://archive.ubuntu.com trusty/main AMD64 Packages
AMI: Get:7 http://security.ubuntu.com trusty-security/universe AMD64 Packages [114 kB]
AMI: Hit http://archive.ubuntu.com trusty/restricted AMD64 Packages
AMI: Hit http://archive.ubuntu.com trusty/universe AMD64 Packages
AMI: Get:8 http://security.ubuntu.com trusty-security/multiverse AMD64 Packages [3686 B]
AMI: Hit http://archive.ubuntu.com trusty/multiverse AMD64 Packages
AMI: Get:9 http://security.ubuntu.com trusty-security/main Translation-en [181 kB]
AMI: Hit http://archive.ubuntu.com trusty/main Translation-en
AMI: Hit http://security.ubuntu.com trusty-security/multiverse Translation-en
AMI: Hit http://archive.ubuntu.com trusty/multiverse Translation-en
AMI: Hit http://security.ubuntu.com trusty-security/restricted Translation-en
AMI: Hit http://archive.ubuntu.com trusty/restricted Translation-en
AMI: Get:10 http://security.ubuntu.com trusty-security/universe Translation-en [66.6 kB]
AMI: Hit http://archive.ubuntu.com trusty/universe Translation-en
AMI: Get:11 http://archive.ubuntu.com trusty-updates/main AMD64 Packages [605 kB]
AMI: Get:12 http://archive.ubuntu.com trusty-updates/restricted AMD64 Packages [15.3 kB]
AMI: Get:13 http://archive.ubuntu.com trusty-updates/universe AMD64 Packages [308 kB]
AMI: Get:14 http://archive.ubuntu.com trusty-updates/multiverse AMD64 Packages [11.9 kB]
AMI: Get:15 http://archive.ubuntu.com trusty-updates/main Translation-en [292 kB]
AMI: Hit http://archive.ubuntu.com trusty-updates/multiverse Translation-en
AMI: Hit http://archive.ubuntu.com trusty-updates/restricted Translation-en
AMI: Get:16 http://archive.ubuntu.com trusty-updates/universe Translation-en [163 kB]
AMI: Fetched 2232 kB in 16s (134 kB/s)
AMI: Reading package lists... Done
AMI:
AMI: [INFO] apt-get -y upgrade
AMI:
AMI: Reading package lists... Done
AMI: Building dependency tree
AMI: Reading state information... Done
AMI: Calculating upgrade... Done
AMI: The following packages have been kept back:
AMI: linux-headers-generic linux-headers-virtual linux-image-virtual
AMI: linux-virtual
AMI: 0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
AMI:
AMI: [INFO] apt-get -y install build-essential git Zip unzip wget default-jre
AMI:
AMI: Reading package lists... Done
AMI: Building dependency tree
AMI: Reading state information... Done
AMI: Package build-essential is not available, but is referred to by another package.
AMI: This may mean that the package is missing, has been obsoleted, or
AMI: is only available from another source
AMI:
AMI: Package default-jre is not available, but is referred to by another package.
AMI: This may mean that the package is missing, has been obsoleted, or
AMI: is only available from another source
AMI:
AMI: Package Zip is not available, but is referred to by another package.
AMI: This may mean that the package is missing, has been obsoleted, or
AMI: is only available from another source
AMI:
AMI: E: Package 'build-essential' has no installation candidate
AMI: E: Package 'Zip' has no installation candidate
AMI: E: Package 'default-jre' has no installation candidate
==> AMI: Terminating the source AWS instance...
==> AMI: No AMIs to cleanup
ほとんどの場合、cloud-initで競合状態に陥りました。 このパッカーの問題 いくつかの洞察を与え、私はOPによって与えられた以下の提案を成功させました:
echo "waiting 180 seconds for cloud-init to update /etc/apt/sources.list"
timeout 180 /bin/bash -c \
'until stat /var/lib/cloud/instance/boot-finished 2>/dev/null; do echo waiting ...; sleep 1; done'
これはまだ問題のようです。ストックのUbuntuイメージのコピーを作成し、その上にapt-getラッパーを配置することで解決しました。既存のインストールが完了するのを待ってから(失敗する代わりに)続行します。
apt-get
に新しい/usr/local/sbin/apt-get
スクリプト(以下を参照)を配置しますSudo chmod 755 /usr/local/sbin/apt-get
/usr/local/sbin/
が/etc/environment
のPATH変数の前にあることを確認しますこれから適合したスクリプト
#!/bin/bash
#
# Wait for the package manager locks to be released before trying to call apt-get
#
i=0
tput sc
while fuser /var/lib/dpkg/lock >/dev/null 2>&1 || fuser /var/lib/apt/lists/lock >/dev/null 2>&1; do
case $(($i % 4)) in
0 ) j="-" ;;
1 ) j="\\" ;;
2 ) j="|" ;;
3 ) j="/" ;;
esac
tput rc
echo -en "\r[$j] Waiting for other software managers to finish..."
sleep 0.5
((i=i+1))
done
/usr/bin/apt-get "$@"
サーバーチームにこれを確認するように依頼しましたが、回答を作成している間、StackExchangeのソリューションは、出力に見られない「ハッシュサムミスマッチ」問題に関係していると言えます。
何らかの理由で、アーカイブメタデータはインストールを要求しているパッケージ(メインにあります)に一致していないように見えますが、aptは他のパッケージがそれらに依存していることを知っているので、そうではないことを伝えますどちらかおかしいと思います。 ;-)