community.general.zypper (8.5.0) — module

Manage packages on SUSE and openSUSE

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

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

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

Also supports transactional updates, by running zypper inside C(/sbin/transactional-update --continue --drop-if-no-change --quiet run).


Requirements

Usage examples

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

Inputs

    
name:
    aliases:
    - pkg
    description:
    - Package name V(name) or package specifier or a list of either.
    - Can include a version like V(name=1.0), V(name>3.4) or V(name<=2.7). If a version
      is given, V(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 O(state=latest), this can be '*', which updates all installed packages.
    elements: str
    required: true
    type: list

type:
    choices:
    - package
    - patch
    - pattern
    - product
    - srcpackage
    - application
    default: package
    description:
    - The type of package to be operated on.
    required: false
    type: str

force:
    default: false
    description:
    - Adds C(--force) option to I(zypper). Allows to downgrade packages and change vendor
      or architecture.
    required: false
    type: bool

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

clean_deps:
    default: false
    description:
    - Adds C(--clean-deps) option to I(zypper) remove command.
    required: false
    type: bool
    version_added: 4.6.0
    version_added_collection: community.general

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
    type: str

oldpackage:
    default: false
    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

replacefiles:
    default: false
    description:
    - Adds C(--replacefiles) option to I(zypper) install/update command.
    required: false
    type: bool
    version_added: 0.2.0
    version_added_collection: community.general

update_cache:
    aliases:
    - refresh
    default: false
    description:
    - Run the equivalent of C(zypper refresh) before the operation. Disabled in check
      mode.
    required: false
    type: bool

force_resolution:
    default: false
    description:
    - Adds C(--force-resolution) option to I(zypper). Allows to (un)install packages with
      conflicting requirements (resolver will choose a solution).
    required: false
    type: bool
    version_added: 0.2.0
    version_added_collection: community.general

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

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

allow_vendor_change:
    default: false
    description:
    - Adds C(--allow_vendor_change) option to I(zypper) dist-upgrade command.
    required: false
    type: bool
    version_added: 0.2.0
    version_added_collection: community.general

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
    type: str