Salt can manage software packages via the pkg state module, packages can be set up to be installed, latest, removed and purged. Package management declarations are typically rather simple:
vim:
pkg.installed
A more involved example involves pulling from a custom repository. Note that the pkgrepo has a require_in clause. This is necessary and can not be replaced by a require clause in the pkg.
base:
pkgrepo.managed:
- human_name: Logstash PPA
- name: deb http://ppa.launchpad.net/wolfnet/logstash/ubuntu precise main
- dist: precise
- file: /etc/apt/sources.list.d/logstash.list
- keyid: 28B04E4A
- keyserver: keyserver.ubuntu.com
- require_in:
- pkg: logstash
logstash:
pkg.installed
Verify that the package is installed, and that it is the correct version (if specified).
Usage:
httpd:
pkg.installed:
- fromrepo: mycustomrepo
- skip_verify: True
- version: 2.0.6~ubuntu3
Multiple Package Installation Options: (not supported in Windows or pkgng)
Usage:
mypkgs:
pkg.installed:
- pkgs:
- foo
- bar
- baz
NOTE: For apt, ebuild, pacman, yumpkg, yumpkg5, and zypper, version numbers can be specified in the pkgs argument. Example:
mypkgs:
pkg.installed:
- pkgs:
- foo
- bar: 1.2.3-4
- baz
Additionally, ebuild, pacman and zypper support the <, <=, >=, and > operators for more control over what versions will be installed. Example:
mypkgs:
pkg.installed:
- pkgs:
- foo
- bar: '>=1.2.3-4'
- baz
NOTE: When using comparison operators, the expression must be enclosed in quotes to avoid a YAML render error.
Usage:
mypkgs:
pkg.installed:
- sources:
- foo: salt://rpms/foo.rpm
- bar: http://somesite.org/bar.rpm
- baz: ftp://someothersite.org/baz.rpm
- qux: /minion/path/to/qux.rpm
Verify that the named package is installed and the latest available package. If the package can be updated this state function will update the package. Generally it is better for the installed function to be used, as latest will update the package whenever a new package is available.
Multiple Package Installation Options:
(Not yet supported for: Windows, FreeBSD, OpenBSD, MacOS, and Solaris pkgutil)
Usage:
mypkgs:
pkg.latest:
- pkgs:
- foo
- bar
- baz
Verify that a package is not installed, calling pkg.purge if necessary to purge the package.
Multiple Package Options:
Verify that a package is not installed, calling pkg.remove if necessary to remove the package.
Multiple Package Options: