Brian Coca 2 weeks ago committed by GitHub
commit 2db91b344e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,2 @@
bugfixes:
- dpkg_selections now handles existing, but not primed, packages correctly.

@ -76,19 +76,24 @@ def main():
# Get current settings.
rc, out, err = module.run_command([dpkg, '--get-selections', name], check_rc=True)
if 'no packages found matching' in err:
module.fail_json(msg="Failed to find package '%s' to perform selection '%s'." % (name, selection))
elif not out:
current = 'not present'
else:
if rc == 0 and out:
current = out.split()[1]
elif 'no packages found matching' in err:
current = 'not found'
else:
current = 'not present'
changed = current != selection
if module.check_mode or not changed:
module.exit_json(changed=changed, before=current, after=selection)
module.run_command([dpkg, '--set-selections'], data="%s %s" % (name, selection), check_rc=True)
rc, out, err = module.run_command([dpkg, '--set-selections'], data="%s %s" % (name, selection), check_rc=True)
if rc != 0:
if 'package not in' in err:
module.fail_json(msg="Failed to find package '%s' to perform selection '%s'." % (name, selection))
module.fail_json(msg="Unexpected error when setting package '%s' to '%s': %s." % (name, selection, err))
module.exit_json(changed=changed, before=current, after=selection)

@ -90,7 +90,7 @@
- name: Try to select non-existent package
dpkg_selections:
name: kernel
name: kerfufle_bad_name_test
selection: hold
ignore_errors: yes
register: result

Loading…
Cancel
Save