mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-13 07:25:10 +00:00
Reformat everything.
This commit is contained in:
parent
3f2213791a
commit
340ff8586d
1008 changed files with 61301 additions and 58309 deletions
|
|
@ -283,7 +283,7 @@ class Package:
|
|||
self.name = name
|
||||
self.prefix = prefix
|
||||
self.version = version
|
||||
self.shouldinstall = (prefix == '+')
|
||||
self.shouldinstall = prefix == "+"
|
||||
|
||||
def __str__(self):
|
||||
return self.prefix + self.name + self.version
|
||||
|
|
@ -302,37 +302,37 @@ def split_name_version(name):
|
|||
Also allows a prefix indicating remove "-", "~" or install "+"
|
||||
"""
|
||||
|
||||
prefix = ''
|
||||
if name[0] in ['-', '~', '+']:
|
||||
prefix = ""
|
||||
if name[0] in ["-", "~", "+"]:
|
||||
prefix = name[0]
|
||||
name = name[1:]
|
||||
if prefix == '~':
|
||||
prefix = '-'
|
||||
if prefix == "~":
|
||||
prefix = "-"
|
||||
|
||||
version_check = re.compile('^(.*?)((?:<|>|<=|>=|=)[0-9.-]*)?$')
|
||||
version_check = re.compile("^(.*?)((?:<|>|<=|>=|=)[0-9.-]*)?$")
|
||||
try:
|
||||
reres = version_check.match(name)
|
||||
name, version = reres.groups()
|
||||
if version is None:
|
||||
version = ''
|
||||
version = ""
|
||||
return prefix, name, version
|
||||
except Exception:
|
||||
return prefix, name, ''
|
||||
return prefix, name, ""
|
||||
|
||||
|
||||
def get_want_state(names, remove=False):
|
||||
packages = []
|
||||
urls = []
|
||||
for name in names:
|
||||
if '://' in name or name.endswith('.rpm'):
|
||||
if "://" in name or name.endswith(".rpm"):
|
||||
urls.append(name)
|
||||
else:
|
||||
prefix, pname, version = split_name_version(name)
|
||||
if prefix not in ['-', '+']:
|
||||
if prefix not in ["-", "+"]:
|
||||
if remove:
|
||||
prefix = '-'
|
||||
prefix = "-"
|
||||
else:
|
||||
prefix = '+'
|
||||
prefix = "+"
|
||||
packages.append(Package(pname, prefix, version))
|
||||
return packages, urls
|
||||
|
||||
|
|
@ -340,8 +340,8 @@ def get_want_state(names, remove=False):
|
|||
def get_installed_state(m, packages):
|
||||
"get installed state of packages"
|
||||
|
||||
cmd = get_cmd(m, 'search')
|
||||
cmd.extend(['--match-exact', '--details', '--installed-only'])
|
||||
cmd = get_cmd(m, "search")
|
||||
cmd.extend(["--match-exact", "--details", "--installed-only"])
|
||||
cmd.extend([p.name for p in packages])
|
||||
return parse_zypper_xml(m, cmd, fail_not_found=False)[0]
|
||||
|
||||
|
|
@ -352,13 +352,12 @@ def parse_zypper_xml(m, cmd, fail_not_found=True, packages=None):
|
|||
try:
|
||||
dom = parseXML(stdout)
|
||||
except xml.parsers.expat.ExpatError as exc:
|
||||
m.fail_json(msg=f"Failed to parse zypper xml output: {exc}",
|
||||
rc=rc, stdout=stdout, stderr=stderr, cmd=cmd)
|
||||
m.fail_json(msg=f"Failed to parse zypper xml output: {exc}", rc=rc, stdout=stdout, stderr=stderr, cmd=cmd)
|
||||
|
||||
if rc == 104:
|
||||
# exit code 104 is ZYPPER_EXIT_INF_CAP_NOT_FOUND (no packages found)
|
||||
if fail_not_found:
|
||||
errmsg = dom.getElementsByTagName('message')[-1].childNodes[0].data
|
||||
errmsg = dom.getElementsByTagName("message")[-1].childNodes[0].data
|
||||
m.fail_json(msg=errmsg, rc=rc, stdout=stdout, stderr=stderr, cmd=cmd)
|
||||
else:
|
||||
return {}, rc, stdout, stderr
|
||||
|
|
@ -374,40 +373,40 @@ def parse_zypper_xml(m, cmd, fail_not_found=True, packages=None):
|
|||
packages = {}
|
||||
else:
|
||||
firstrun = False
|
||||
solvable_list = dom.getElementsByTagName('solvable')
|
||||
solvable_list = dom.getElementsByTagName("solvable")
|
||||
for solvable in solvable_list:
|
||||
name = solvable.getAttribute('name')
|
||||
name = solvable.getAttribute("name")
|
||||
packages[name] = {}
|
||||
packages[name]['version'] = solvable.getAttribute('edition')
|
||||
packages[name]['oldversion'] = solvable.getAttribute('edition-old')
|
||||
status = solvable.getAttribute('status')
|
||||
packages[name]['installed'] = status == "installed"
|
||||
packages[name]['group'] = solvable.parentNode.nodeName
|
||||
packages[name]["version"] = solvable.getAttribute("edition")
|
||||
packages[name]["oldversion"] = solvable.getAttribute("edition-old")
|
||||
status = solvable.getAttribute("status")
|
||||
packages[name]["installed"] = status == "installed"
|
||||
packages[name]["group"] = solvable.parentNode.nodeName
|
||||
if rc == 103 and firstrun:
|
||||
# if this was the first run and it failed with 103
|
||||
# run zypper again with the same command to complete update
|
||||
return parse_zypper_xml(m, cmd, fail_not_found=fail_not_found, packages=packages)
|
||||
if rc == 107 and m.params['skip_post_errors'] and firstrun:
|
||||
if rc == 107 and m.params["skip_post_errors"] and firstrun:
|
||||
# if this was the first run and it failed with 107 with skip_post_errors flag
|
||||
# run zypper again with the same command to complete update
|
||||
return parse_zypper_xml(m, cmd, fail_not_found=fail_not_found, packages=packages)
|
||||
|
||||
# apply simple_errors logic to rc 0,102,103,106,107
|
||||
if m.params['simple_errors']:
|
||||
if m.params["simple_errors"]:
|
||||
stdout = get_simple_errors(dom) or stdout
|
||||
|
||||
return packages, rc, stdout, stderr
|
||||
|
||||
# apply simple_errors logic to rc other than 0,102,103,106,107
|
||||
if m.params['simple_errors']:
|
||||
if m.params["simple_errors"]:
|
||||
stdout = get_simple_errors(dom) or stdout
|
||||
|
||||
m.fail_json(msg=f'Zypper run command failed with return code {rc}.', rc=rc, stdout=stdout, stderr=stderr, cmd=cmd)
|
||||
m.fail_json(msg=f"Zypper run command failed with return code {rc}.", rc=rc, stdout=stdout, stderr=stderr, cmd=cmd)
|
||||
|
||||
|
||||
def get_simple_errors(dom):
|
||||
simple_errors = []
|
||||
message_xml_tags = dom.getElementsByTagName('message')
|
||||
message_xml_tags = dom.getElementsByTagName("message")
|
||||
|
||||
if message_xml_tags is None:
|
||||
return None
|
||||
|
|
@ -419,49 +418,55 @@ def get_simple_errors(dom):
|
|||
|
||||
def get_cmd(m, subcommand):
|
||||
"puts together the basic zypper command arguments with those passed to the module"
|
||||
is_install = subcommand in ['install', 'update', 'patch', 'dist-upgrade']
|
||||
is_refresh = subcommand == 'refresh'
|
||||
cmd = [m.get_bin_path('zypper', required=True), '--non-interactive', '--xmlout']
|
||||
if m.params['quiet']:
|
||||
cmd.append('--quiet')
|
||||
is_install = subcommand in ["install", "update", "patch", "dist-upgrade"]
|
||||
is_refresh = subcommand == "refresh"
|
||||
cmd = [m.get_bin_path("zypper", required=True), "--non-interactive", "--xmlout"]
|
||||
if m.params["quiet"]:
|
||||
cmd.append("--quiet")
|
||||
if transactional_updates():
|
||||
cmd = [m.get_bin_path('transactional-update', required=True), '--continue', '--drop-if-no-change', '--quiet', 'run'] + cmd
|
||||
if m.params['extra_args_precommand']:
|
||||
args_list = m.params['extra_args_precommand'].split()
|
||||
cmd = [
|
||||
m.get_bin_path("transactional-update", required=True),
|
||||
"--continue",
|
||||
"--drop-if-no-change",
|
||||
"--quiet",
|
||||
"run",
|
||||
] + cmd
|
||||
if m.params["extra_args_precommand"]:
|
||||
args_list = m.params["extra_args_precommand"].split()
|
||||
cmd.extend(args_list)
|
||||
# add global options before zypper command
|
||||
if (is_install or is_refresh) and m.params['disable_gpg_check']:
|
||||
cmd.append('--no-gpg-checks')
|
||||
if is_install and m.params['auto_import_keys']:
|
||||
cmd.append('--gpg-auto-import-keys')
|
||||
if (is_install or is_refresh) and m.params["disable_gpg_check"]:
|
||||
cmd.append("--no-gpg-checks")
|
||||
if is_install and m.params["auto_import_keys"]:
|
||||
cmd.append("--gpg-auto-import-keys")
|
||||
|
||||
if subcommand == 'search':
|
||||
cmd.append('--disable-repositories')
|
||||
if subcommand == "search":
|
||||
cmd.append("--disable-repositories")
|
||||
|
||||
cmd.append(subcommand)
|
||||
if subcommand not in ['patch', 'dist-upgrade'] and not is_refresh:
|
||||
cmd.extend(['--type', m.params['type']])
|
||||
if m.check_mode and subcommand != 'search':
|
||||
cmd.append('--dry-run')
|
||||
if subcommand not in ["patch", "dist-upgrade"] and not is_refresh:
|
||||
cmd.extend(["--type", m.params["type"]])
|
||||
if m.check_mode and subcommand != "search":
|
||||
cmd.append("--dry-run")
|
||||
if is_install:
|
||||
cmd.append('--auto-agree-with-licenses')
|
||||
if m.params['disable_recommends']:
|
||||
cmd.append('--no-recommends')
|
||||
if m.params['force']:
|
||||
cmd.append('--force')
|
||||
if m.params['force_resolution']:
|
||||
cmd.append('--force-resolution')
|
||||
if m.params['oldpackage']:
|
||||
cmd.append('--oldpackage')
|
||||
if m.params['replacefiles']:
|
||||
cmd.append('--replacefiles')
|
||||
if subcommand == 'remove':
|
||||
if m.params['clean_deps']:
|
||||
cmd.append('--clean-deps')
|
||||
if subcommand == 'dist-upgrade' and m.params['allow_vendor_change']:
|
||||
cmd.append('--allow-vendor-change')
|
||||
if m.params['extra_args']:
|
||||
args_list = m.params['extra_args'].split(' ')
|
||||
cmd.append("--auto-agree-with-licenses")
|
||||
if m.params["disable_recommends"]:
|
||||
cmd.append("--no-recommends")
|
||||
if m.params["force"]:
|
||||
cmd.append("--force")
|
||||
if m.params["force_resolution"]:
|
||||
cmd.append("--force-resolution")
|
||||
if m.params["oldpackage"]:
|
||||
cmd.append("--oldpackage")
|
||||
if m.params["replacefiles"]:
|
||||
cmd.append("--replacefiles")
|
||||
if subcommand == "remove":
|
||||
if m.params["clean_deps"]:
|
||||
cmd.append("--clean-deps")
|
||||
if subcommand == "dist-upgrade" and m.params["allow_vendor_change"]:
|
||||
cmd.append("--allow-vendor-change")
|
||||
if m.params["extra_args"]:
|
||||
args_list = m.params["extra_args"].split(" ")
|
||||
cmd.extend(args_list)
|
||||
|
||||
return cmd
|
||||
|
|
@ -469,38 +474,38 @@ def get_cmd(m, subcommand):
|
|||
|
||||
def set_diff(m, retvals, result):
|
||||
# TODO: if there is only one package, set before/after to version numbers
|
||||
packages = {'installed': [], 'removed': [], 'upgraded': []}
|
||||
packages = {"installed": [], "removed": [], "upgraded": []}
|
||||
if result:
|
||||
for p in result:
|
||||
group = result[p]['group']
|
||||
if group == 'to-upgrade':
|
||||
group = result[p]["group"]
|
||||
if group == "to-upgrade":
|
||||
versions = f" ({result[p]['oldversion']} => {result[p]['version']})"
|
||||
packages['upgraded'].append(p + versions)
|
||||
elif group == 'to-install':
|
||||
packages['installed'].append(p)
|
||||
elif group == 'to-remove':
|
||||
packages['removed'].append(p)
|
||||
packages["upgraded"].append(p + versions)
|
||||
elif group == "to-install":
|
||||
packages["installed"].append(p)
|
||||
elif group == "to-remove":
|
||||
packages["removed"].append(p)
|
||||
|
||||
output = ''
|
||||
output = ""
|
||||
for state in packages:
|
||||
if packages[state]:
|
||||
output += f"{state}: {', '.join(packages[state])}\n"
|
||||
if 'diff' not in retvals:
|
||||
retvals['diff'] = {}
|
||||
if 'prepared' not in retvals['diff']:
|
||||
retvals['diff']['prepared'] = output
|
||||
if "diff" not in retvals:
|
||||
retvals["diff"] = {}
|
||||
if "prepared" not in retvals["diff"]:
|
||||
retvals["diff"]["prepared"] = output
|
||||
else:
|
||||
retvals['diff']['prepared'] += f"\n{output}"
|
||||
retvals["diff"]["prepared"] += f"\n{output}"
|
||||
|
||||
|
||||
def package_present(m, name, want_latest):
|
||||
"install and update (if want_latest) the packages in name_install, while removing the packages in name_remove"
|
||||
retvals = {'rc': 0, 'stdout': '', 'stderr': ''}
|
||||
retvals = {"rc": 0, "stdout": "", "stderr": ""}
|
||||
packages, urls = get_want_state(name)
|
||||
|
||||
# add oldpackage flag when a version is given to allow downgrades
|
||||
if any(p.version for p in packages):
|
||||
m.params['oldpackage'] = True
|
||||
m.params["oldpackage"] = True
|
||||
|
||||
if not want_latest:
|
||||
# for state=present: filter out already installed packages
|
||||
|
|
@ -518,8 +523,8 @@ def package_present(m, name, want_latest):
|
|||
return None, retvals
|
||||
|
||||
# zypper install also updates packages
|
||||
cmd = get_cmd(m, 'install')
|
||||
cmd.append('--')
|
||||
cmd = get_cmd(m, "install")
|
||||
cmd.append("--")
|
||||
cmd.extend(urls)
|
||||
# pass packages to zypper
|
||||
# allow for + or - prefixes in install/remove lists
|
||||
|
|
@ -528,8 +533,8 @@ def package_present(m, name, want_latest):
|
|||
# for example "-exim postfix" runs without removing packages depending on mailserver
|
||||
cmd.extend([str(p) for p in packages])
|
||||
|
||||
retvals['cmd'] = cmd
|
||||
result, retvals['rc'], retvals['stdout'], retvals['stderr'] = parse_zypper_xml(m, cmd)
|
||||
retvals["cmd"] = cmd
|
||||
result, retvals["rc"], retvals["stdout"], retvals["stderr"] = parse_zypper_xml(m, cmd)
|
||||
|
||||
return result, retvals
|
||||
|
||||
|
|
@ -537,30 +542,30 @@ def package_present(m, name, want_latest):
|
|||
def package_update_all(m):
|
||||
"run update or patch on all available packages"
|
||||
|
||||
retvals = {'rc': 0, 'stdout': '', 'stderr': ''}
|
||||
if m.params['type'] == 'patch':
|
||||
cmdname = 'patch'
|
||||
elif m.params['state'] == 'dist-upgrade':
|
||||
cmdname = 'dist-upgrade'
|
||||
retvals = {"rc": 0, "stdout": "", "stderr": ""}
|
||||
if m.params["type"] == "patch":
|
||||
cmdname = "patch"
|
||||
elif m.params["state"] == "dist-upgrade":
|
||||
cmdname = "dist-upgrade"
|
||||
else:
|
||||
cmdname = 'update'
|
||||
cmdname = "update"
|
||||
|
||||
cmd = get_cmd(m, cmdname)
|
||||
retvals['cmd'] = cmd
|
||||
result, retvals['rc'], retvals['stdout'], retvals['stderr'] = parse_zypper_xml(m, cmd)
|
||||
retvals["cmd"] = cmd
|
||||
result, retvals["rc"], retvals["stdout"], retvals["stderr"] = parse_zypper_xml(m, cmd)
|
||||
return result, retvals
|
||||
|
||||
|
||||
def package_absent(m, name):
|
||||
"remove the packages in name"
|
||||
retvals = {'rc': 0, 'stdout': '', 'stderr': ''}
|
||||
retvals = {"rc": 0, "stdout": "", "stderr": ""}
|
||||
# Get package state
|
||||
packages, urls = get_want_state(name, remove=True)
|
||||
if any(p.prefix == '+' for p in packages):
|
||||
if any(p.prefix == "+" for p in packages):
|
||||
m.fail_json(msg="Can not combine '+' prefix with state=remove/absent.")
|
||||
if urls:
|
||||
m.fail_json(msg="Can not remove via URL.")
|
||||
if m.params['type'] == 'patch':
|
||||
if m.params["type"] == "patch":
|
||||
m.fail_json(msg="Can not remove patches.")
|
||||
prerun_state = get_installed_state(m, packages)
|
||||
packages = [p for p in packages if p.name in prerun_state]
|
||||
|
|
@ -568,40 +573,40 @@ def package_absent(m, name):
|
|||
if not packages:
|
||||
return None, retvals
|
||||
|
||||
cmd = get_cmd(m, 'remove')
|
||||
cmd = get_cmd(m, "remove")
|
||||
cmd.extend([p.name + p.version for p in packages])
|
||||
|
||||
retvals['cmd'] = cmd
|
||||
result, retvals['rc'], retvals['stdout'], retvals['stderr'] = parse_zypper_xml(m, cmd)
|
||||
retvals["cmd"] = cmd
|
||||
result, retvals["rc"], retvals["stdout"], retvals["stderr"] = parse_zypper_xml(m, cmd)
|
||||
return result, retvals
|
||||
|
||||
|
||||
def repo_refresh(m):
|
||||
"update the repositories"
|
||||
retvals = {'rc': 0, 'stdout': '', 'stderr': ''}
|
||||
retvals = {"rc": 0, "stdout": "", "stderr": ""}
|
||||
|
||||
cmd = get_cmd(m, 'refresh')
|
||||
cmd = get_cmd(m, "refresh")
|
||||
|
||||
retvals['cmd'] = cmd
|
||||
result, retvals['rc'], retvals['stdout'], retvals['stderr'] = parse_zypper_xml(m, cmd)
|
||||
retvals["cmd"] = cmd
|
||||
result, retvals["rc"], retvals["stdout"], retvals["stderr"] = parse_zypper_xml(m, cmd)
|
||||
|
||||
return retvals
|
||||
|
||||
|
||||
def get_fs_type_and_readonly_state(mount_point):
|
||||
with open('/proc/mounts', 'r') as file:
|
||||
with open("/proc/mounts", "r") as file:
|
||||
for line in file.readlines():
|
||||
fields = line.split()
|
||||
path = fields[1]
|
||||
if path == mount_point:
|
||||
fs = fields[2]
|
||||
opts = fields[3]
|
||||
return fs, 'ro' in opts.split(',')
|
||||
return fs, "ro" in opts.split(",")
|
||||
return None
|
||||
|
||||
|
||||
def transactional_updates():
|
||||
return os.path.exists('/usr/sbin/transactional-update') and get_fs_type_and_readonly_state('/') == ('btrfs', True)
|
||||
return os.path.exists("/usr/sbin/transactional-update") and get_fs_type_and_readonly_state("/") == ("btrfs", True)
|
||||
|
||||
|
||||
# ===========================================
|
||||
|
|
@ -611,33 +616,37 @@ def transactional_updates():
|
|||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
name=dict(required=True, aliases=['pkg'], type='list', elements='str'),
|
||||
state=dict(default='present', choices=['absent', 'installed', 'latest', 'present', 'removed', 'dist-upgrade']),
|
||||
type=dict(default='package', choices=['package', 'patch', 'pattern', 'product', 'srcpackage', 'application']),
|
||||
name=dict(required=True, aliases=["pkg"], type="list", elements="str"),
|
||||
state=dict(
|
||||
default="present", choices=["absent", "installed", "latest", "present", "removed", "dist-upgrade"]
|
||||
),
|
||||
type=dict(
|
||||
default="package", choices=["package", "patch", "pattern", "product", "srcpackage", "application"]
|
||||
),
|
||||
extra_args_precommand=dict(),
|
||||
disable_gpg_check=dict(default=False, type='bool'),
|
||||
auto_import_keys=dict(default=False, type='bool'),
|
||||
disable_recommends=dict(default=True, type='bool'),
|
||||
force=dict(default=False, type='bool'),
|
||||
force_resolution=dict(default=False, type='bool'),
|
||||
update_cache=dict(aliases=['refresh'], default=False, type='bool'),
|
||||
oldpackage=dict(default=False, type='bool'),
|
||||
disable_gpg_check=dict(default=False, type="bool"),
|
||||
auto_import_keys=dict(default=False, type="bool"),
|
||||
disable_recommends=dict(default=True, type="bool"),
|
||||
force=dict(default=False, type="bool"),
|
||||
force_resolution=dict(default=False, type="bool"),
|
||||
update_cache=dict(aliases=["refresh"], default=False, type="bool"),
|
||||
oldpackage=dict(default=False, type="bool"),
|
||||
extra_args=dict(),
|
||||
allow_vendor_change=dict(default=False, type='bool'),
|
||||
replacefiles=dict(default=False, type='bool'),
|
||||
clean_deps=dict(default=False, type='bool'),
|
||||
simple_errors=dict(default=False, type='bool'),
|
||||
quiet=dict(default=True, type='bool'),
|
||||
skip_post_errors=dict(default=False, type='bool'),
|
||||
allow_vendor_change=dict(default=False, type="bool"),
|
||||
replacefiles=dict(default=False, type="bool"),
|
||||
clean_deps=dict(default=False, type="bool"),
|
||||
simple_errors=dict(default=False, type="bool"),
|
||||
quiet=dict(default=True, type="bool"),
|
||||
skip_post_errors=dict(default=False, type="bool"),
|
||||
),
|
||||
supports_check_mode=True
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
module.run_command_environ_update = dict(LANG='C', LC_ALL='C', LC_MESSAGES='C')
|
||||
module.run_command_environ_update = dict(LANG="C", LC_ALL="C", LC_MESSAGES="C")
|
||||
|
||||
name = module.params['name']
|
||||
state = module.params['state']
|
||||
update_cache = module.params['update_cache']
|
||||
name = module.params["name"]
|
||||
state = module.params["state"]
|
||||
update_cache = module.params["update_cache"]
|
||||
|
||||
# remove empty strings from package list
|
||||
name = [_f for _f in name if _f]
|
||||
|
|
@ -646,31 +655,31 @@ def main():
|
|||
if update_cache and not module.check_mode:
|
||||
retvals = repo_refresh(module)
|
||||
|
||||
if retvals['rc'] != 0:
|
||||
if retvals["rc"] != 0:
|
||||
module.fail_json(msg="Zypper refresh run failed.", **retvals)
|
||||
|
||||
# Perform requested action
|
||||
if name == ['*'] and state in ['latest', 'dist-upgrade']:
|
||||
if name == ["*"] and state in ["latest", "dist-upgrade"]:
|
||||
packages_changed, retvals = package_update_all(module)
|
||||
elif name != ['*'] and state == 'dist-upgrade':
|
||||
elif name != ["*"] and state == "dist-upgrade":
|
||||
module.fail_json(msg="Can not dist-upgrade specific packages.")
|
||||
else:
|
||||
if state in ['absent', 'removed']:
|
||||
if state in ["absent", "removed"]:
|
||||
packages_changed, retvals = package_absent(module, name)
|
||||
elif state in ['installed', 'present', 'latest']:
|
||||
packages_changed, retvals = package_present(module, name, state == 'latest')
|
||||
elif state in ["installed", "present", "latest"]:
|
||||
packages_changed, retvals = package_present(module, name, state == "latest")
|
||||
|
||||
retvals['changed'] = retvals['rc'] in [0, 102] and bool(packages_changed)
|
||||
retvals["changed"] = retvals["rc"] in [0, 102] and bool(packages_changed)
|
||||
|
||||
if module._diff:
|
||||
set_diff(module, retvals, packages_changed)
|
||||
|
||||
if retvals['rc'] not in [0, 102]:
|
||||
if retvals["rc"] not in [0, 102]:
|
||||
module.fail_json(msg="Zypper run failed.", **retvals)
|
||||
|
||||
if not retvals['changed']:
|
||||
del retvals['stdout']
|
||||
del retvals['stderr']
|
||||
if not retvals["changed"]:
|
||||
del retvals["stdout"]
|
||||
del retvals["stderr"]
|
||||
|
||||
module.exit_json(name=name, state=state, update_cache=update_cache, **retvals)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue