diff --git a/plugins/modules/zypper.py b/plugins/modules/zypper.py index fae859fe74..ac5b6657ba 100644 --- a/plugins/modules/zypper.py +++ b/plugins/modules/zypper.py @@ -18,143 +18,141 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -DOCUMENTATION = ''' ---- +DOCUMENTATION = r""" module: zypper author: - - "Patrick Callahan (@dirtyharrycallahan)" - - "Alexander Gubin (@alxgu)" - - "Thomas O'Donnell (@andytom)" - - "Robin Roth (@robinro)" - - "Andrii Radyk (@AnderEnder)" + - "Patrick Callahan (@dirtyharrycallahan)" + - "Alexander Gubin (@alxgu)" + - "Thomas O'Donnell (@andytom)" + - "Robin Roth (@robinro)" + - "Andrii Radyk (@AnderEnder)" short_description: Manage packages on SUSE and openSUSE 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). + - 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). extends_documentation_fragment: - - community.general.attributes - - community.general.attributes + - community.general.attributes + - community.general.attributes attributes: - check_mode: - support: full - diff_mode: - support: full + check_mode: + support: full + diff_mode: + support: full options: - name: - 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. - required: true - aliases: [ 'pkg' ] - type: list - elements: str - state: - 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 - choices: [ present, latest, absent, dist-upgrade, installed, removed ] - default: "present" - type: str - type: - description: - - The type of package to be operated on. - required: false - choices: [ package, patch, pattern, product, srcpackage, application ] - default: "package" - type: str - extra_args_precommand: - required: false - description: - - Add additional global target options to C(zypper). - - Options should be supplied in a single line as if given in the command line. - type: str - disable_gpg_check: - 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 - default: false - type: bool - disable_recommends: - 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 - default: true - type: bool - force: - description: - - Adds C(--force) option to I(zypper). Allows to downgrade packages and change vendor or architecture. - required: false - default: false - type: bool - force_resolution: - description: - - Adds C(--force-resolution) option to I(zypper). Allows to (un)install packages with conflicting requirements (resolver will choose a solution). - required: false - default: false - type: bool - version_added: '0.2.0' - update_cache: - description: - - Run the equivalent of C(zypper refresh) before the operation. Disabled in check mode. - required: false - default: false - type: bool - aliases: [ "refresh" ] - oldpackage: - 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 - default: false - type: bool - extra_args: - required: false - description: - - Add additional options to C(zypper) command. - - Options should be supplied in a single line as if given in the command line. - type: str - allow_vendor_change: - type: bool - required: false - default: false - description: - - Adds C(--allow_vendor_change) option to I(zypper) dist-upgrade command. - version_added: '0.2.0' - replacefiles: - type: bool - required: false - default: false - description: - - Adds C(--replacefiles) option to I(zypper) install/update command. - version_added: '0.2.0' - clean_deps: - type: bool - required: false - default: false - description: - - Adds C(--clean-deps) option to I(zypper) remove command. - version_added: '4.6.0' + name: + 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 V(*), which updates all installed packages. + required: true + aliases: ['pkg'] + type: list + elements: str + state: + 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 + choices: [present, latest, absent, dist-upgrade, installed, removed] + default: "present" + type: str + type: + description: + - The type of package to be operated on. + required: false + choices: [package, patch, pattern, product, srcpackage, application] + default: "package" + type: str + extra_args_precommand: + required: false + description: + - Add additional global target options to C(zypper). + - Options should be supplied in a single line as if given in the command line. + type: str + disable_gpg_check: + 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 + default: false + type: bool + disable_recommends: + 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 + default: true + type: bool + force: + description: + - Adds C(--force) option to I(zypper). Allows to downgrade packages and change vendor or architecture. + required: false + default: false + type: bool + force_resolution: + description: + - Adds C(--force-resolution) option to I(zypper). Allows to (un)install packages with conflicting requirements (resolver will choose a solution). + required: false + default: false + type: bool + version_added: '0.2.0' + update_cache: + description: + - Run the equivalent of C(zypper refresh) before the operation. Disabled in check mode. + required: false + default: false + type: bool + aliases: ["refresh"] + oldpackage: + 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 + default: false + type: bool + extra_args: + required: false + description: + - Add additional options to C(zypper) command. + - Options should be supplied in a single line as if given in the command line. + type: str + allow_vendor_change: + type: bool + required: false + default: false + description: + - Adds C(--allow_vendor_change) option to I(zypper) dist-upgrade command. + version_added: '0.2.0' + replacefiles: + type: bool + required: false + default: false + description: + - Adds C(--replacefiles) option to I(zypper) install/update command. + version_added: '0.2.0' + clean_deps: + type: bool + required: false + default: false + description: + - Adds C(--clean-deps) option to I(zypper) remove command. + version_added: '4.6.0' notes: - - When used with a C(loop:) each package will be processed individually, - it is much more efficient to pass the list directly to the O(name) option. + - When used with a C(loop:) each package will be processed individually, it is much more efficient to pass the list directly to the O(name) + option. # informational: requirements for nodes requirements: - - "zypper >= 1.0 # included in openSUSE >= 11.1 or SUSE Linux Enterprise Server/Desktop >= 11.0" - - python-xml - - rpm -''' + - "zypper >= 1.0 # included in openSUSE >= 11.1 or SUSE Linux Enterprise Server/Desktop >= 11.0" + - python-xml + - rpm +""" -EXAMPLES = ''' +EXAMPLES = r""" - name: Install nmap community.general.zypper: name: nmap @@ -228,7 +226,7 @@ EXAMPLES = ''' state: present environment: ZYPP_LOCK_TIMEOUT: 20 -''' +""" import os.path import xml diff --git a/plugins/modules/zypper_repository.py b/plugins/modules/zypper_repository.py index 5a0356cc37..18f9ff0824 100644 --- a/plugins/modules/zypper_repository.py +++ b/plugins/modules/zypper_repository.py @@ -11,91 +11,88 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -DOCUMENTATION = ''' ---- +DOCUMENTATION = r""" module: zypper_repository author: "Matthias Vogelgesang (@matze)" short_description: Add and remove Zypper repositories description: - - Add or remove Zypper repositories on SUSE and openSUSE + - Add or remove Zypper repositories on SUSE and openSUSE. extends_documentation_fragment: - - community.general.attributes + - community.general.attributes attributes: - check_mode: - support: none - diff_mode: - support: none + check_mode: + support: none + diff_mode: + support: none options: - name: - description: - - A name for the repository. Not required when adding repofiles. - type: str - repo: - description: - - URI of the repository or .repo file. Required when state=present. - type: str - state: - description: - - A source string state. - choices: [ "absent", "present" ] - default: "present" - type: str + name: description: - description: - - A description of the repository - type: str - disable_gpg_check: - description: - - Whether to disable GPG signature checking of - all packages. Has an effect only if O(state=present). - - Needs zypper version >= 1.6.2. - type: bool - default: false - autorefresh: - description: - - Enable autorefresh of the repository. - type: bool - default: true - aliases: [ "refresh" ] - priority: - description: - - Set priority of repository. Packages will always be installed - from the repository with the smallest priority number. - - Needs zypper version >= 1.12.25. - type: int - overwrite_multiple: - description: - - Overwrite multiple repository entries, if repositories with both name and - URL already exist. - type: bool - default: false - auto_import_keys: - description: - - Automatically import the gpg signing key of the new or changed repository. - - Has an effect only if O(state=present). Has no effect on existing (unchanged) repositories or in combination with O(state=absent). - - Implies runrefresh. - - Only works with C(.repo) files if `name` is given explicitly. - type: bool - default: false - runrefresh: - description: - - Refresh the package list of the given repository. - - Can be used with repo=* to refresh all repositories. - type: bool - default: false - enabled: - description: - - Set repository to enabled (or disabled). - type: bool - default: true + - A name for the repository. Not required when adding repofiles. + type: str + repo: + description: + - URI of the repository or full path of a C(.repo) file. Required when O(state=present). + type: str + state: + description: + - Whether the repository should exist or not. + - A source string state. + choices: ["absent", "present"] + default: "present" + type: str + description: + description: + - A description of the repository. + type: str + disable_gpg_check: + description: + - Whether to disable GPG signature checking of all packages. Has an effect only if O(state=present). + - Needs C(zypper) version >= 1.6.2. + type: bool + default: false + autorefresh: + description: + - Enable autorefresh of the repository. + type: bool + default: true + aliases: ["refresh"] + priority: + description: + - Set priority of repository. Packages will always be installed from the repository with the smallest priority number. + - Needs C(zypper) version >= 1.12.25. + type: int + overwrite_multiple: + description: + - Overwrite multiple repository entries, if repositories with both name and URL already exist. + type: bool + default: false + auto_import_keys: + description: + - Automatically import the gpg signing key of the new or changed repository. + - Has an effect only if O(state=present). Has no effect on existing (unchanged) repositories or in combination with O(state=absent). + - Implies O(runrefresh). + - Only works with C(.repo) files if O(name) is given explicitly. + type: bool + default: false + runrefresh: + description: + - Refresh the package list of the given repository. + - Can be used with O(repo=*) to refresh all repositories. + type: bool + default: false + enabled: + description: + - Set repository to enabled (or disabled). + type: bool + default: true requirements: - - "zypper >= 1.0 # included in openSUSE >= 11.1 or SUSE Linux Enterprise Server/Desktop >= 11.0" - - python-xml -''' + - "zypper >= 1.0 # included in openSUSE >= 11.1 or SUSE Linux Enterprise Server/Desktop >= 11.0" + - python-xml +""" -EXAMPLES = ''' +EXAMPLES = r""" - name: Add NVIDIA repository for graphics drivers community.general.zypper_repository: name: nvidia-repo @@ -128,7 +125,7 @@ EXAMPLES = ''' name: my_ci_repo state: present runrefresh: true -''' +""" import traceback diff --git a/plugins/modules/zypper_repository_info.py b/plugins/modules/zypper_repository_info.py index dab4b9bbe5..9512d32eed 100644 --- a/plugins/modules/zypper_repository_info.py +++ b/plugins/modules/zypper_repository_info.py @@ -10,72 +10,67 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -DOCUMENTATION = ''' ---- +DOCUMENTATION = r""" module: zypper_repository_info author: "Tobias Zeuch (@TobiasZeuch181)" version_added: 10.0.0 short_description: List Zypper repositories description: - - List Zypper repositories on SUSE and openSUSE. + - List Zypper repositories on SUSE and openSUSE. extends_documentation_fragment: - - community.general.attributes - - community.general.attributes.info_module + - community.general.attributes + - community.general.attributes.info_module requirements: - - "zypper >= 1.0 (included in openSUSE >= 11.1 or SUSE Linux Enterprise Server/Desktop >= 11.0)" - - python-xml + - "zypper >= 1.0 (included in openSUSE >= 11.1 or SUSE Linux Enterprise Server/Desktop >= 11.0)" + - python-xml notes: - - "For info about packages, use the module M(ansible.builtin.package_facts)." -''' + - "For info about packages, use the module M(ansible.builtin.package_facts)." +""" -EXAMPLES = ''' +EXAMPLES = r""" - name: List registered repositories and store in variable repositories community.general.zypper_repository_info: {} register: repodatalist -''' +""" -RETURN = ''' +RETURN = r""" repodatalist: - description: - - A list of repository descriptions like it is returned by the command C(zypper repos). - type: list - returned: always - elements: dict - contains: - alias: - description: The alias of the repository. - type: str - autorefresh: - description: Indicates, if autorefresh is enabled on the repository. - type: int - enabled: - description: indicates, if the repository is enabled - type: int - gpgcheck: - description: indicates, if the GPG signature of the repository meta data is checked - type: int - name: - description: the name of the repository - type: str - priority: - description: the priority of the repository - type: int - url: - description: The URL of the repository on the internet. - type: str - sample: [ - { - "alias": "SLE-Product-SLES", - "autorefresh": "1", - "enabled": "1", - "gpgcheck": "1", - "name": "SLE-Product-SLES", - "priority": "99", - "url": "http://repo:50000/repo/SUSE/Products/SLE-Product-SLES/15-SP2/x86_64/product" - } - ] -''' + description: + - A list of repository descriptions like it is returned by the command C(zypper repos). + type: list + returned: always + elements: dict + contains: + alias: + description: The alias of the repository. + type: str + sample: "SLE-Product-SLES" + autorefresh: + description: Indicates, if autorefresh is enabled on the repository. + type: int + sample: "1" + enabled: + description: Indicates, if the repository is enabled. + type: int + sample: "1" + gpgcheck: + description: Indicates, if the GPG signature of the repository meta data is checked. + type: int + sample: "1" + name: + description: The name of the repository. + type: str + sample: "SLE-Product-SLES" + priority: + description: The priority of the repository. + type: int + sample: "99" + url: + description: The URL of the repository on the internet. + type: str + sample: "http://repo:50000/repo/SUSE/Products/SLE-Product-SLES/15-SP2/x86_64/product" +""" from ansible_collections.community.general.plugins.module_utils import deps