W3cubDocs

/Ansible

zypper - Manage packages on SUSE and openSUSE

Synopsis

Manage packages on SUSE and openSUSE using the zypper and rpm tools.

Requirements (on host that executes module)

  • zypper >= 1.0 # included in openSuSE >= 11.1 or SuSE Linux Enterprise Server/Desktop >= 11.0
  • python-xml
  • rpm

Options

parameter required default choices comments
disable_gpg_check
no no
  • yes
  • no
Whether to disable to GPG signature checking of the package signature being installed. Has an effect only if state is present or latest.
disable_recommends
(added in 1.8)
no yes
  • yes
  • no
Corresponds to the --no-recommends option for zypper. Default behavior (yes) modifies zypper's default behavior; no does install recommended packages.
force
(added in 2.2)
no no
  • yes
  • no
Adds --force option to zypper. Allows to downgrade packages and change vendor or architecture.
name
yes
Package name name or package specifier.
Can include a version like name=1.0, name>3.4 or name<=2.7. If a version is given, oldpackage is implied and zypper is allowed to update the package within the version range given.
You can also pass a url or a local path to a rpm file.
When using state=latest, this can be '*', which updates all installed packages.
aliases: pkg
oldpackage
(added in 2.2)
no no
  • yes
  • no
Adds --oldpackage option to zypper. Allows to downgrade packages with less side-effects than force. This is implied as soon as a version is specified as part of the package name.
state
no present
  • present
  • latest
  • absent
present will make sure the package is installed. latest will make sure the latest version of the package is installed. absent will make sure the specified package is not installed.
type
(added in 2.0)
no package
  • package
  • patch
  • pattern
  • product
  • srcpackage
  • application
The type of package to be operated on.
update_cache
(added in 2.2)
no no
  • yes
  • no
Run the equivalent of zypper refresh before the operation.
aliases: refresh

Examples

# Install "nmap"
- zypper: name=nmap state=present

# Install apache2 with recommended packages
- zypper: name=apache2 state=present disable_recommends=no

# Apply a given patch
- zypper: name=openSUSE-2016-128 state=present type=patch

# Remove the "nmap" package
- zypper: name=nmap state=absent

# Install the nginx rpm from a remote repo
- zypper: name=http://nginx.org/packages/sles/12/x86_64/RPMS/nginx-1.8.0-1.sles12.ngx.x86_64.rpm state=present

# Install local rpm file
- zypper: name=/tmp/fancy-software.rpm state=present

# Update all packages
- zypper: name=* state=latest

# Apply all available patches
- zypper: name=* state=latest type=patch

# Refresh repositories and update package "openssl"
- zypper: name=openssl state=present update_cache=yes

# Install specific version (possible comparisons: <, >, <=, >=, =)
- zypper: name=docker>=1.10 state=installed

This is an Extras Module

For more information on what this means please read Extras Modules

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, developing_test_pr and Developing Modules.

© 2012–2016 Michael DeHaan
© 2016 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/zypper_module.html