Package


package_absent

Enforce the absence of a package

Compatible with nodes running Rudder 4.0 or higher.

Usage

See package_state for documentation.

Parameters

  • name: Name of the package
  • version: Version of the package or "any" for any version (defaults to "any")
  • architecture: Architecture of the package, can be an architecture name or "default" (defaults to "default")
  • provider: Package provider to use, can be "yum", "apt", "pkg" or "default" for system default package manager (defaults to "default")

Classes defined

package_absent_${name}_{kept, repaired, not_ok, reached}


package_check_installed

Verify if a package is installed in any version

Compatible with nodes running Rudder 3.1 or higher.

Usage

This bundle will define a class package_check_installed_${file_name}_{ok, reached, kept} if the package is installed, or package_check_installed_${file_name}_{not_ok, reached, not_kept, failed} if the package is not installed

Parameters

  • package_name: Name of the package to check

Classes defined

package_check_installed_${package_name}_{kept, repaired, not_ok, reached}


package_install

Install or update a package in its latest version available

Compatible with nodes running Rudder 3.1 or higher.

Parameters

  • package_name: Name of the package to install

Classes defined

package_install_${package_name}_{kept, repaired, not_ok, reached}


package_install_version

Install or update a package in a specific version

Compatible with nodes running Rudder 3.1 or higher.

Parameters

  • package_name: Name of the package to install
  • package_version: Version of the package to install (can be "latest" to install it in its latest version)

Classes defined

package_install_${package_name}_{kept, repaired, not_ok, reached}


package_install_version_cmp

Install a package or verify if it is installed in a specific version, or higher or lower version than a version specified

Compatible with nodes running Rudder 3.1 or higher.

Usage

Example:

methods:
    "any" usebundle => package_install_version_cmp("postgresql", ">=", "9.1", "verify");

Parameters

  • package_name: Name of the package to install or verify
  • version_comparator: Comparator between installed version and defined version, can be ==,⇐,>=,<,>,!=
  • package_version: The version of the package to verify (can be "latest" for latest version)
  • action: Action to perform, can be add, verify (defaults to verify)

Classes defined

package_install_${package_name}_{kept, repaired, not_ok, reached}


package_install_version_cmp_update

Install a package or verify if it is installed in a specific version, or higher or lower version than a version specified, optionally test update or not (Debian-, Red Hat- or SuSE-like systems only)

Compatible with nodes running Rudder 3.1 or higher.

Usage

Example:

methods:
    "any" usebundle => package_install_version_cmp_update("postgresql", ">=", "9.1", "verify", "false");

Parameters

  • package_name: Name of the package to install or verify
  • version_comparator: Comparator between installed version and defined version, can be ==,⇐,>=,<,>,!=
  • package_version: The version of the package to verify (can be "latest" for latest version)
  • action: Action to perform, can be add, verify (defaults to verify)
  • update_policy: While verifying packages, check against latest version ("true") or just installed ("false")

Classes defined

package_install_${package_name}_{kept, repaired, not_ok, reached}


package_present

Enforce the presence of a package

Compatible with nodes running Rudder 4.0 or higher.

Usage

See package_state for documentation.

Parameters

  • name: Name of the package, or path to a local package
  • version: Version of the package, can be "latest" for latest version or "any" for any version (defaults to "any")
  • architecture: Architecture of the package, can be an architecture name or "default" (defaults to "default")
  • provider: Package provider to use, can be "yum", "apt", "pkg" or "default" for system default package manager (defaults to "default")

Classes defined

package_present_${name}_{kept, repaired, not_ok, reached}


package_remove

Remove a package

Compatible with nodes running Rudder 3.1 or higher.

Usage

Example:

methods:
    "any" usebundle => package_remove("htop");

Parameters

  • package_name: Name of the package to remove

Classes defined

package_remove_${package_name}_{kept, repaired, not_ok, reached}


package_state

Enforce the state of a package

Compatible with nodes running Rudder 4.0 or higher.

Usage

These methods manage packages using a package manager on the system.

package_present and package_absent use a new package implementation, different from package_install_*, package_remove_* and package_verify_*. It should be more reliable, and handle upgrades better. It is compatible though, and you can call generic methods from both implementations on the same host. The only drawback is that the agent will have to maintain double caches for package lists, which may cause a little unneeded overhead.

Setup

If you are using ncf inside Rudder, no specific setup is necessary.

If your are using ncf without Rudder, you need to call the initialization bundle before using package methods.

Package parameters

There is only one mandatory parameter, which is the package name to install. When it should be installed from a local package, you need to specify the full path to the package as name.

The version parameter allows specifying a version you want installed. It should be the complete versions string as used by the used package manager. This parameter allows two special values:

  • any which is the default value, and is satisfied by any version of the given package
  • latest which will ensure, at each run, that the package is at the latest available version.

The last parameter is the provider, which is documented in the next section.

You can use package_state_options to pass options to the underlying package manager (currently only with apt package manager).

Package providers

This method supports several package managers. You can specify the package manager you want to use or let the method choose the default for the local system.

The package providers include a caching system for package information. The package lists (installed, available and available updates) are only updated when the cache expires, or when an operation is made by the agent on packages.

Note: The implementation of package operations is done in scripts called modules, which you can find in ${sys.workdir}/modules/packages/.

apt

This package provider uses apt/dpkg to manage packages on the system. dpkg will be used for all local actions, and apt is only needed to manage update and installation from a repository.

rpm

This package provider uses yum/rpm to manage packages on the system. rpm will be used for all local actions, and yum is only needed to manage update and installation from a repository.

It is able to downgrade packages when specifying an older version.

zypper

This package provider uses zypper/rpm to manage packages on the system. rpm will be used for all local actions, and zypper is only needed to manage update and installation from a repository.

pkg

This package provider uses FreeBSD’s pkg to manage packages on the system.

Examples

# To install postgresql in version 9.1 for x86_64 atchitecture
package_present("postgresql", "9.1", "x86_64", "");
# To ensure postgresql is always in the latest available version
package_present("postgresql", "latest", "", "");
# To ensure installing postgresql in any version
package_present("postgresql", "", "", "");
# To ensure installing postgresql in any version, forcing the yum provider
package_present("postgresql", "", "", "yum");
# To ensure installing postgresql from a local package
package_present("/tmp/postgresql-9.1-1.x86_64.rpm", "", "", "");
# To remove postgresql
package_absent("postgresql", "", "", "");

See also : package_present, package_absent, package_state_options

Parameters

  • name: Name of the package, or path to a local package if state is present
  • version: Version of the package, can be "latest" for latest version or "any" for any version (defaults to "any")
  • architecture: Architecture of the package, can be an architecture name or "default" (defaults to "default")
  • provider: Package provider to use, can be "yum", "apt", "zypper", "pkg" or "default" for system default package manager (defaults to "default")
  • state: State of the package, can be "present" or "absent" (defaults to "present")

Classes defined

package_state_${name}_{kept, repaired, not_ok, reached}


package_state_options

Enforce the state of a package with options

Compatible with nodes running Rudder 4.0 or higher.

Usage

See package_state for documentation.

Parameters

  • name: Name of the package, or path to a local package if state is present
  • version: Version of the package, can be "latest" for latest version or "any" for any version (defaults to "any")
  • architecture: Architecture of the package, can be an architecture name or "default" (defaults to "default")
  • provider: Package provider to use, can be "yum", "apt", "zypper", "pkg" or "default" for system default package manager (defaults to "default")
  • state: State of the package, can be "present" or "absent" (defaults to "present")
  • options: Options no pass to the package manager (defaults to empty)

Classes defined

package_state_options_${name}_{kept, repaired, not_ok, reached}


package_verify

Verify if a package is installed in its latest version available

Compatible with nodes running Rudder 3.1 or higher.

Parameters

  • package_name: Name of the package to verify

Classes defined

package_install_${package_name}_{kept, repaired, not_ok, reached}


package_verify_version

Verify if a package is installed in a specific version

Compatible with nodes running Rudder 3.1 or higher.

Parameters

  • package_name: Name of the package to verify
  • package_version: Version of the package to verify (can be "latest" for latest version)

Classes defined

package_install_${package_name}_{kept, repaired, not_ok, reached}