// For LTS series which need support for the cloud-tools archive,
// we need to enable apt-get update regardless of the environ
// setting, otherwise bootstrap or provisioning will fail.
if series == "precise" && !addUpdateScripts {
addUpdateScripts = true
}
// Bring packages up-to-date.
c.SetAptUpdate(addUpdateScripts)
c.SetAptUpgrade(addUpgradeScripts)
c.SetAptGetWrapper("eatmydata")
// If we're not doing an update, adding these packages is
// meaningless.
if addUpdateScripts {
requiredPackages := []string{
"curl",
"cpu-checker",
// TODO(axw) 2014-07-02 #1277359
// Don't install bridge-utils in cloud-init;
// leave it to the networker worker.
"bridge-utils",
"rsyslog-gnutls",
"cloud-utils",
"cloud-image-utils",
}
// The required packages need to come from the correct repo.
// For precise, that might require an explicit --target-release parameter.
for _, pkg := range requiredPackages {
// We cannot just pass requiredPackages below, because
// this will generate install commands which older
// versions of cloud-init (e.g. 0.6.3 in precise) will
// interpret incorrectly (see bug http://pad.lv/1424777).
cmds := apt.GetPreparePackages([]string{pkg}, series)
if len(cmds) != 1 {
// One package given, one command (with possibly
// multiple args) expected.
panic(fmt.Sprintf("expected one install command per package, got %v", cmds))
}
for _, p := range cmds[0] {
// We need to add them one package at a time. Also for
// precise where --target-release
// precise-updates/cloud-tools is needed for some packages
// we need to pass these as "packages", otherwise the
// aforementioned older cloud-init will also fail to
// interpret the command correctly.
c.AddPackage(p)
}
}
}