Example #1
0
// addPackageCommandsCommon is a helper function which applies the given
// packaging-related options to the given CloudConfig.
func addPackageCommandsCommon(
	cfg CloudConfig,
	packageProxySettings proxy.Settings,
	packageMirror string,
	addUpdateScripts bool,
	addUpgradeScripts bool,
	series string,
) {
	// Set the package mirror.
	cfg.SetPackageMirror(packageMirror)

	// For LTS series which need support for the cloud-tools archive,
	// we need to enable package-list update regardless of the environ
	// setting, otherwise bootstrap or provisioning will fail.
	if config.SeriesRequiresCloudArchiveTools(series) && !addUpdateScripts {
		addUpdateScripts = true
	}

	// Bring packages up-to-date.
	cfg.SetSystemUpdate(addUpdateScripts)
	cfg.SetSystemUpgrade(addUpgradeScripts)

	// Always run this step - this is where we install packages that juju
	// requires.
	cfg.addRequiredPackages()

	// TODO(bogdanteleaga): Deal with proxy settings on CentOS
	cfg.updateProxySettings(packageProxySettings)
}
Example #2
0
// addRequiredPackages is defined on the AdvancedPackagingConfig interface.
func (cfg *centOSCloudConfig) addRequiredPackages() {
	packages := []string{
		"curl",
		"bridge-utils",
		"cloud-utils",
		"nmap-ncat",
		"tmux",
	}
	if featureflag.Enabled(feature.DeveloperMode) {
		packages = append(packages, "socat")
	}

	// The required packages need to come from the correct repo.
	// For CentOS 7, this requires an rpm cloud archive be up.
	// In the event of the addition of such a repository, its addition should
	// happen in the utils/packaging/config package whilst leaving the below
	// code untouched.
	for _, pack := range packages {
		if config.SeriesRequiresCloudArchiveTools(cfg.series) && cfg.pacconfer.IsCloudArchivePackage(pack) {
			cfg.AddPackage(strings.Join(cfg.pacconfer.ApplyCloudArchiveTarget(pack), " "))
		} else {
			cfg.AddPackage(pack)
		}
	}
}
Example #3
0
func (s *FunctionsSuite) TestSeriesRequiresCloudArchiveTools(c *gc.C) {
	testedSeries := []string{
		"precise",
		"centos7",
		"rogentos",
		"debian",
		"mint",
		"makulu",
		"rhel lol",
	}

	for i, series := range testedSeries {
		c.Logf("Test %d: series %s:", i+1, series)

		res := config.SeriesRequiresCloudArchiveTools(series)
		_, req := config.SeriesRequiringCloudTools[series]

		c.Assert(res, gc.Equals, req)
	}
}
Example #4
0
// ensureDependencies creates a set of install packages using
// apt.GetPreparePackages and runs each set of packages through
// apt.GetInstall.
func ensureDependencies(series string) error {
	if series == "precise" {
		return fmt.Errorf("LXD is not supported in precise.")
	}

	pacman, err := getPackageManager(series)
	if err != nil {
		return err
	}
	pacconfer, err := getPackagingConfigurer(series)
	if err != nil {
		return err
	}

	for _, pack := range requiredPackages {
		pkg := pack
		if config.SeriesRequiresCloudArchiveTools(series) &&
			pacconfer.IsCloudArchivePackage(pack) {
			pkg = strings.Join(pacconfer.ApplyCloudArchiveTarget(pack), " ")
		}

		if config.RequiresBackports(series, pack) {
			pkg = fmt.Sprintf("--target-release %s-backports %s", series, pkg)
		}

		if err := pacman.Install(pkg); err != nil {
			return err
		}
	}

	if series >= "xenial" {
		for _, pack := range xenialPackages {
			pacman.Install(fmt.Sprintf("--no-install-recommends %s", pack))
		}
	}

	return err
}
Example #5
0
// addRequiredPackages is defined on the AdvancedPackagingConfig interface.
func (cfg *ubuntuCloudConfig) addRequiredPackages() {
	packages := []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",
		"cloud-utils",
		"tmux",
	}
	if featureflag.Enabled(feature.DeveloperMode) {
		packages = append(packages, "socat")
	}

	// The required packages need to come from the correct repo.
	// For precise, that might require an explicit --target-release parameter.
	// We cannot just pass packages 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).
	for _, pack := range packages {
		if config.SeriesRequiresCloudArchiveTools(cfg.series) && cfg.pacconfer.IsCloudArchivePackage(pack) {
			// On precise, we need to pass a --target-release entry in
			// pieces (as "packages") for it to work:
			// --target-release, precise-updates/cloud-tools,
			// package-name. All these 3 entries are needed so
			// cloud-init 0.6.3 can generate the correct apt-get
			// install command line for "package-name".
			args := cfg.pacconfer.ApplyCloudArchiveTarget(pack)
			for _, arg := range args {
				cfg.AddPackage(arg)
			}
		} else {
			cfg.AddPackage(pack)
		}
	}
}
Example #6
0
// ensureDependencies creates a set of install packages using
// apt.GetPreparePackages and runs each set of packages through
// apt.GetInstall.
func ensureDependencies(series string) error {
	pacman, err := getPackageManager(series)
	if err != nil {
		return err
	}
	pacconfer, err := getPackagingConfigurer(series)
	if err != nil {
		return err
	}

	for _, pack := range requiredPackages {
		pkg := pack
		if config.SeriesRequiresCloudArchiveTools(series) &&
			pacconfer.IsCloudArchivePackage(pack) {
			pkg = strings.Join(pacconfer.ApplyCloudArchiveTarget(pack), " ")
		}

		if err := pacman.Install(pkg); err != nil {
			return err
		}
	}

	return err
}
Example #7
0
// RequiresCloudArchiveCloudTools is defined on the AdvancedPackagingConfig
// interface.
func (cfg *cloudConfig) RequiresCloudArchiveCloudTools() bool {
	return config.SeriesRequiresCloudArchiveTools(cfg.series)
}