summaryrefslogtreecommitdiff
path: root/lib/ansible/modules/dpkg_selections.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ansible/modules/dpkg_selections.py')
-rw-r--r--lib/ansible/modules/dpkg_selections.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/ansible/modules/dpkg_selections.py b/lib/ansible/modules/dpkg_selections.py
index 87cad529..7c8a7250 100644
--- a/lib/ansible/modules/dpkg_selections.py
+++ b/lib/ansible/modules/dpkg_selections.py
@@ -39,7 +39,7 @@ attributes:
support: full
platforms: debian
notes:
- - This module won't cause any packages to be installed/removed/purged, use the C(apt) module for that.
+ - This module will not cause any packages to be installed/removed/purged, use the M(ansible.builtin.apt) module for that.
'''
EXAMPLES = '''
- name: Prevent python from being upgraded
@@ -54,6 +54,7 @@ EXAMPLES = '''
'''
from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.common.locale import get_best_parsable_locale
def main():
@@ -67,12 +68,18 @@ def main():
dpkg = module.get_bin_path('dpkg', True)
+ locale = get_best_parsable_locale(module)
+ DPKG_ENV = dict(LANG=locale, LC_ALL=locale, LC_MESSAGES=locale, LC_CTYPE=locale)
+ module.run_command_environ_update = DPKG_ENV
+
name = module.params['name']
selection = module.params['selection']
# Get current settings.
rc, out, err = module.run_command([dpkg, '--get-selections', name], check_rc=True)
- if not out:
+ 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:
current = out.split()[1]