From b7229b04679ef3bce36f8d46e15d46b253d8068b Mon Sep 17 00:00:00 2001 From: "William L. Thomson Jr" Date: Sun, 26 Feb 2017 17:21:34 -0500 Subject: [PATCH] Adds latest to portage module (#21918) --- lib/ansible/modules/packaging/os/portage.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/packaging/os/portage.py b/lib/ansible/modules/packaging/os/portage.py index 5e2b241c83..da50127193 100644 --- a/lib/ansible/modules/packaging/os/portage.py +++ b/lib/ansible/modules/packaging/os/portage.py @@ -45,7 +45,7 @@ options: - State of the package atom required: false default: "present" - choices: [ "present", "installed", "emerged", "absent", "removed", "unmerged" ] + choices: [ "present", "installed", "emerged", "absent", "removed", "unmerged", "latest" ] update: description: @@ -196,7 +196,7 @@ EXAMPLES = ''' package: foo state: absent -# Update package foo to the "best" version +# Update package foo to the "latest" version ( os specific alternative to latest ) - portage: package: foo update: yes @@ -298,7 +298,7 @@ def sync_repositories(module, webrsync=False): def emerge_packages(module, packages): p = module.params - if not (p['update'] or p['noreplace']): + if not (p['update'] or p['noreplace'] or p['state']=='latest'): for package in packages: if not query_package(module, package, 'emerge'): break @@ -328,6 +328,9 @@ def emerge_packages(module, packages): if p[flag]: args.append(arg) + if p['state'] and p['state']=='latest': + args.append("--update") + if p['usepkg'] and p['usepkgonly']: module.fail_json(msg='Use only one of usepkg, usepkgonly') @@ -449,7 +452,7 @@ def run_emerge(module, packages, *args): return cmd, module.run_command(cmd) -portage_present_states = ['present', 'emerged', 'installed'] +portage_present_states = ['present', 'emerged', 'installed', 'latest'] portage_absent_states = ['absent', 'unmerged', 'removed']