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.
base:
pkgrepo.managed:
- humanname: Logstash PPA
- name: ppa:wolfnet/logstash
- dist: precise
- file: /etc/apt/sources.list.d/logstash.list
- keyid: 28B04E4A
- keyserver: keyserver.ubuntu.com
logstash:
pkg.installed
- fromrepo: ppa:wolfnet/logstash
Multiple packages can also be installed with the use of the pkgs state module
dotdeb.repo:
pkgrepo.managed:
- humanname: Dotdeb
- name: deb http://packages.dotdeb.org wheezy-php55 all
- dist: wheezy-php55
- file: /etc/apt/sources.list.d/dotbeb.list
- keyid: 89DF5277
- keyserver: keys.gnupg.net
- refresh_db: true
php.packages:
pkg.installed:
- fromrepo: wheezy-php55
- pkgs:
- php5-fpm
- php5-cli
- php5-curl
Warning
Package names are currently case-sensitive. If the minion is using a
package manager which is not case-sensitive (such as pkgng
), then this state will fail if the proper case is not
used. This will be addressed in a future release of Salt.
salt.states.pkg.
group_installed
(name, skip=None, include=None, **kwargs)¶New in version 2015.8.0.
Ensure that an entire package group is installed. This state is only
supported for the yum
package manager.
Packages that would normally be installed by the package group ("default" packages), which should not be installed.
Load Balancer:
pkg.group_installed:
- skip:
- piranha
Packages which are included in a group, which would not normally be
installed by a yum groupinstall
("optional" packages). Note that
this will not enforce group membership; if you include packages which
are not members of the specified groups, they will still be installed.
Can be passed either as a comma-separated list or a python list.
Load Balancer:
pkg.group_installed:
- include:
- haproxy
Note
Because this is essentially a wrapper around pkg.install
, any argument which can be passed to
pkg.install may also be included here, and it will be passed along
wholesale.
salt.states.pkg.
installed
(name, version=None, refresh=None, fromrepo=None, skip_verify=False, skip_suggestions=False, pkgs=None, sources=None, allow_updates=False, pkg_verify=False, normalize=True, **kwargs)¶Ensure that the package is installed, and that it is the correct version (if specified).
Parameters: |
|
||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns: | A dictionary containing the state of the software installation |
||||||||||||||||
Rtype dict: |
salt.states.pkg.
latest
(name, refresh=None, fromrepo=None, skip_verify=False, pkgs=None, watch_flags=True, **kwargs)¶Ensure 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)
mypkgs:
pkg.latest:
- pkgs:
- foo
- bar
- baz
Whether to install the packages marked as recommended. Default is
True
. Currently only works with APT-based systems.
New in version 2015.5.0.
httpd:
pkg.latest:
- install_recommends: False
Only upgrade the packages, if they are already installed. Default is
False
. Currently only works with APT-based systems.
New in version 2015.5.0.
httpd:
pkg.latest:
- only_upgrade: True
salt.states.pkg.
mod_aggregate
(low, chunks, running)¶The mod_aggregate function which looks up all packages in the available low chunks and merges them into a single pkgs ref in the present low data
salt.states.pkg.
purged
(name, version=None, pkgs=None, normalize=True, **kwargs)¶Verify that a package is not installed, calling pkg.purge
if necessary
to purge the package. All configuration files are also removed.
Normalize the package name by removing the architecture, if the architecture of the package is different from the architecture of the operating system. The ability to disable this behavior is useful for poorly-created packages which include the architecture as an actual part of the name, such as kernel modules which match a specific kernel version.
New in version 2015.8.0.
Multiple Package Options:
name
parameter will be ignored if this option is passed. It accepts
version numbers as well.New in version 0.16.0.
salt.states.pkg.
removed
(name, version=None, pkgs=None, normalize=True, **kwargs)¶Verify that a package is not installed, calling pkg.remove
if necessary
to remove the package.
Normalize the package name by removing the architecture, if the architecture of the package is different from the architecture of the operating system. The ability to disable this behavior is useful for poorly-created packages which include the architecture as an actual part of the name, such as kernel modules which match a specific kernel version.
New in version 2015.8.0.
Multiple Package Options:
name
parameter will be ignored if this option is passed. It accepts
version numbers as well.New in version 0.16.0.
salt.states.pkg.
uptodate
(name, refresh=False, **kwargs)¶New in version 2014.7.0.
Verify that the system is completely up to date.
Any keyword arguments to pass through to pkg.upgrade
.
New in version 2015.5.0.