ansible.builtin.zypper (v2.9.27) — module

Manage packages on SUSE and openSUSE

| "added in version" 1.2 of ansible.builtin"

Authors: Patrick Callahan (@dirtyharrycallahan), Alexander Gubin (@alxgu), Thomas O'Donnell (@andytom), Robin Roth (@robinro), Andrii Radyk (@AnderEnder)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.27

Description

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


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Install "nmap"
- zypper:
    name: nmap
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Install apache2 with recommended packages
- zypper:
    name: apache2
    state: present
    disable_recommends: no
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Apply a given patch
- zypper:
    name: openSUSE-2016-128
    state: present
    type: patch
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Remove the "nmap" package
- zypper:
    name: nmap
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Install local rpm file
- zypper:
    name: /tmp/fancy-software.rpm
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Update all packages
- zypper:
    name: '*'
    state: latest
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Apply all available patches
- zypper:
    name: '*'
    state: latest
    type: patch
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Perform a dist-upgrade with additional arguments
- zypper:
    name: '*'
    state: dist-upgrade
    extra_args: '--no-allow-vendor-change --allow-arch-change'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Refresh repositories and update package "openssl"
- zypper:
    name: openssl
    state: present
    update_cache: yes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Install specific version (possible comparisons: <, >, <=, >=, =)
- zypper:
    name: 'docker>=1.10'
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Wait 20 seconds to acquire the lock before failing
- zypper:
    name: mosh
    state: present
  environment:
    ZYPP_LOCK_TIMEOUT: 20

Inputs

    
name:
    aliases:
    - pkg
    description:
    - Package name C(name) or package specifier or a list of either.
    - Can include a version like C(name=1.0), C(name>3.4) or C(name<=2.7). If a version
      is given, C(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.
    required: true

type:
    choices:
    - package
    - patch
    - pattern
    - product
    - srcpackage
    - application
    default: package
    description:
    - The type of package to be operated on.
    required: false
    version_added: '2.0'
    version_added_collection: ansible.builtin

force:
    default: 'no'
    description:
    - Adds C(--force) option to I(zypper). Allows to downgrade packages and change vendor
      or architecture.
    required: false
    type: bool
    version_added: '2.2'
    version_added_collection: ansible.builtin

state:
    choices:
    - present
    - latest
    - absent
    - dist-upgrade
    default: present
    description:
    - C(present) will make sure the package is installed. C(latest)  will make sure the
      latest version of the package is installed. C(absent)  will make sure the specified
      package is not installed. C(dist-upgrade) will make sure the latest version of all
      installed packages from all enabled repositories is installed.
    - When using C(dist-upgrade), I(name) should be C('*').
    required: false

extra_args:
    description:
    - Add additional options to C(zypper) command.
    - Options should be supplied in a single line as if given in the command line.
    required: false
    version_added: '2.4'
    version_added_collection: ansible.builtin

oldpackage:
    default: 'no'
    description:
    - Adds C(--oldpackage) option to I(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.
    required: false
    type: bool
    version_added: '2.2'
    version_added_collection: ansible.builtin

update_cache:
    aliases:
    - refresh
    default: 'no'
    description:
    - Run the equivalent of C(zypper refresh) before the operation. Disabled in check
      mode.
    required: false
    type: bool
    version_added: '2.2'
    version_added_collection: ansible.builtin

disable_gpg_check:
    default: 'no'
    description:
    - Whether to disable to GPG signature checking of the package signature being installed.
      Has an effect only if state is I(present) or I(latest).
    required: false
    type: bool

disable_recommends:
    default: 'yes'
    description:
    - Corresponds to the C(--no-recommends) option for I(zypper). Default behavior (C(yes))
      modifies zypper's default behavior; C(no) does install recommended packages.
    required: false
    type: bool
    version_added: '1.8'
    version_added_collection: ansible.builtin

extra_args_precommand:
    description:
    - Add additional global target options to C(zypper).
    - Options should be supplied in a single line as if given in the command line.
    required: false
    version_added: '2.6'
    version_added_collection: ansible.builtin