Parameters: |
- name (str) -- The name of the package to be installed. This parameter is ignored if
either "pkgs" or "sources" is used. Additionally, please note that this
option can only be used to install packages from a software repository.
To install a package file manually, use the "sources" option detailed
below.
- version (str) --
Install a specific version of a package. This option is ignored if
either "pkgs" or "sources" is used. Currently, this option is supported
for the following pkg providers: apt ,
ebuild ,
pacman ,
yumpkg , and
zypper . The version number includes the
release designation where applicable, to allow Salt to target a
specific release of a given version. When in doubt, using the
pkg.latest_version function for an uninstalled package will tell
you the version available.
# salt myminion pkg.latest_version httpd
myminion:
2.2.15-30.el6.centos
Also, while this function is not yet implemented for all pkg frontends,
pkg.list_repo_pkgs will
show all versions available in the various repositories for a given
package, irrespective of whether or not it is installed.
# salt myminion pkg.list_repo_pkgs httpd
myminion:
----------
base:
|_
----------
httpd:
2.2.15-29.el6.centos
updates:
|_
----------
httpd:
2.2.15-30.el6.centos
The version strings returned by either of these functions can be used
as version specifiers in pkg states.
- refresh (bool) -- Update the repo database of available packages prior to installing the
requested package.
- fromrepo (str) --
Specify a repository from which to install
Note
Distros which use APT (Debian, Ubuntu, etc.) do not have a concept
of repositories, in the same way as YUM-based distros do. When a
source is added, it is assigned to a given release. Consider the
following source configuration:
deb http://ppa.launchpad.net/saltstack/salt/ubuntu precise main
The packages provided by this source would be made available via
the precise release, therefore fromrepo would need to be
set to precise for Salt to install the package from this
source.
Having multiple sources in the same release may result in the
default install candidate being newer than what is desired. If this
is the case, the desired version must be specified using the
version parameter.
If the pkgs parameter is being used to install multiple
packages in the same state, then instead of using version ,
use the method of version specification described in the Multiple
Package Installation Options section below.
Running the shell command apt-cache policy pkgname on a minion
can help elucidate the APT configuration and aid in properly
configuring states:
root@saltmaster:~# salt ubuntu01 cmd.run 'apt-cache policy ffmpeg'
ubuntu01:
ffmpeg:
Installed: (none)
Candidate: 7:0.10.11-1~precise1
Version table:
7:0.10.11-1~precise1 0
500 http://ppa.launchpad.net/jon-severinsson/ffmpeg/ubuntu/ precise/main amd64 Packages
4:0.8.10-0ubuntu0.12.04.1 0
500 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main amd64 Packages
500 http://security.ubuntu.com/ubuntu/ precise-security/main amd64 Packages
4:0.8.1-0ubuntu1 0
500 http://us.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
The release is located directly after the source's URL. The actual
release name is the part before the slash, so to install version
4:0.8.10-0ubuntu0.12.04.1 either precise-updates or
precise-security could be used for the fromrepo value.
- skip_verify (bool) -- Skip the GPG verification check for the package to be installed
- skip_suggestions (bool) --
Force strict package naming. Disables lookup of package alternatives.
- pkgs (list) --
A list of packages to install from a software repository. All packages
listed under pkgs will be installed via a single command.
Example:
mypkgs:
pkg.installed:
- pkgs:
- foo
- bar
- baz
- hold: True
NOTE: For apt ,
ebuild ,
pacman , yumpkg ,
and zypper , version numbers can be specified
in the pkgs argument. For 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. For
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.
With ebuild is also possible to specify a
use flag list and/or if the given packages should be in
package.accept_keywords file and/or the overlay from which you want the
package to be installed.
For example:
mypkgs:
pkg.installed:
- pkgs:
- foo: '~'
- bar: '~>=1.2:slot::overlay[use,-otheruse]'
- baz
Multiple Package Installation Options: (not supported in Windows or
pkgng)
- sources (list) --
A list of packages to install, along with the source URI or local path
from which to install each package. In the example below, foo ,
bar , baz , etc. refer to the name of the package, as it would
appear in the output of the pkg.version or pkg.list_pkgs salt
CLI commands.
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
- allow_updates (bool) --
Allow the package to be updated outside Salt's control (e.g. auto
updates on Windows). This means a package on the Minion can have a newer
version than the latest available in the repository without enforcing a
re-installation of the package.
Example:
httpd:
pkg.installed:
- fromrepo: mycustomrepo
- skip_verify: True
- skip_suggestions: True
- version: 2.0.6~ubuntu3
- refresh: True
- allow_updates: True
- hold: False
- pkg_verify (bool) --
For requested packages that are already installed and would not be targeted for
upgrade or downgrade, use pkg.verify to determine if any of the files installed
by the package have been altered. If files have been altered, the reinstall
option of pkg.install is used to force a reinstall. Types to ignore can be
passed to pkg.verify (see example below). Currently, this option is supported
for the following pkg providers: yumpkg .
Examples:
httpd:
pkg.installed:
- version: 2.2.15-30.el6.centos
- pkg_verify: True
mypkgs:
pkg.installed:
- pkgs:
- foo
- bar: 1.2.3-4
- baz
- pkg_verify:
- ignore_types: [config,doc]
- normalize (bool) --
Normalize the package name by removing the architecture. Default is True.
This is useful for poorly created packages which might include the
architecture as an actual part of the name such as kernel modules
which match a specific kernel version.
Example:
gpfs.gplbin-2.6.32-279.31.1.el6.x86_64:
pkg.installed:
- normalize: False
- kwargs --
These are specific to each OS. If it does not apply to the execution
module for your OS, it is ignored.
param bool hold: |
| Force the package to be held at the current installed version.
Currently works with YUM & APT based systems.
|
param list names: |
| A list of packages to install from a software repository. Each package
will be installed individually by the package manager.
Warning
Unlike pkgs , the names parameter cannot specify a version.
In addition, it makes a separate call to the package management
frontend to install each package, whereas pkgs makes just a
single call. It is therefore recommended to use pkgs instead of
names to install multiple packages, both for the additional
features and the performance improvement that it brings.
|
param bool install_recommends: |
| Whether to install the packages marked as recommended. Default is True.
Currently only works with APT based systems.
httpd:
pkg.installed:
- install_recommends: False
|
param bool only_upgrade: |
| Only upgrade the packages, if they are already installed. Default is
False. Currently only works with APT based systems.
httpd:
pkg.installed:
- only_upgrade: True
|
|