From 2d4cbe0d5b45f5b367b638fdafecaec8eab2420f Mon Sep 17 00:00:00 2001 From: William L Thomson Jr Date: Tue, 14 May 2019 12:17:19 -0400 Subject: [PATCH] Modify/fix handling of noreplace option issue #55365 (#55967) Presently setting noreplace: no/false has no effect. Negating the default to true from false and modifying conditionals seems to correct this. Making it such that you can re-install and existing package. That did not seem possible without such modifications. Potential fix for issue #55365 pending issue reporter testing and feedback. --- lib/ansible/modules/packaging/os/portage.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/packaging/os/portage.py b/lib/ansible/modules/packaging/os/portage.py index ac5f98b9937..0b453a39a99 100644 --- a/lib/ansible/modules/packaging/os/portage.py +++ b/lib/ansible/modules/packaging/os/portage.py @@ -74,7 +74,7 @@ options: description: - Do not re-emerge installed packages (--noreplace) type: bool - default: 'no' + default: 'yes' nodeps: description: @@ -288,9 +288,9 @@ def emerge_packages(module, packages): """Run emerge command against given list of atoms.""" p = module.params - if not (p['update'] or p['noreplace'] or p['state'] == 'latest'): + if p['noreplace'] and not (p['update'] or p['state'] == 'latest'): for package in packages: - if not query_package(module, package, 'emerge'): + if p['noreplace'] and not query_package(module, package, 'emerge'): break else: module.exit_json(changed=False, msg='Packages already present.') @@ -472,7 +472,7 @@ def main(): newuse=dict(default=False, type='bool'), changed_use=dict(default=False, type='bool'), oneshot=dict(default=False, type='bool'), - noreplace=dict(default=False, type='bool'), + noreplace=dict(default=True, type='bool'), nodeps=dict(default=False, type='bool'), onlydeps=dict(default=False, type='bool'), depclean=dict(default=False, type='bool'),