From e95641f371e4e20afbe71fc2a5363f1b40ca4b27 Mon Sep 17 00:00:00 2001 From: "William L. Thomson Jr" Date: Mon, 28 Nov 2016 17:05:47 -0500 Subject: [PATCH] Portage module improvements (#3520) * packaging/os/portage.py: Added portage parameter --keep-going * packaging/os/portage.py: Added portage parameter --load-avg [FLOAT] * packaging/os/portage.py: Added portage parameter --jobs[=INT] * packaging/os/portage.py: Added myself to Authors --- .../modules/extras/packaging/os/portage.py | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/extras/packaging/os/portage.py b/lib/ansible/modules/extras/packaging/os/portage.py index d137a2e813d..f88b67fa9ae 100644 --- a/lib/ansible/modules/extras/packaging/os/portage.py +++ b/lib/ansible/modules/extras/packaging/os/portage.py @@ -1,8 +1,10 @@ #!/usr/bin/python # -*- coding: utf-8 -*- +# (c) 2016, William L Thomson Jr # (c) 2013, Yap Sok Ann # Written by Yap Sok Ann +# Modified by William L. Thomson Jr. # Based on apt module written by Matthew Williams # # This module is free software: you can redistribute it and/or modify @@ -146,8 +148,36 @@ options: default: False choices: [ "yes", "no" ] + keepgoing: + description: + - Continue as much as possible after an error. + required: false + default: False + choices: [ "yes", "no" ] + version_added: 2.3 + + jobs: + description: + - Specifies the number of packages to build simultaneously. + required: false + default: None + type: int + version_added: 2.3 + + loadavg: + description: + - Specifies that no new builds should be started if there are + - other builds running and the load average is at least LOAD + required: false + default: None + type: float + version_added: 2.3 + requirements: [ gentoolkit ] -author: Yap Sok Ann, Andrew Udvare +author: + - "William L Thomson Jr (@wltjr)" + - "Yap Sok Ann (@sayap)" + - "Andrew Udvare" notes: [] ''' @@ -270,6 +300,7 @@ def emerge_packages(module, packages): 'getbinpkg': '--getbinpkg', 'usepkgonly': '--usepkgonly', 'usepkg': '--usepkg', + 'keepgoing': '--keep-going', } for flag, arg in emerge_flags.iteritems(): if p[flag]: @@ -278,6 +309,15 @@ def emerge_packages(module, packages): if p['usepkg'] and p['usepkgonly']: module.fail_json(msg='Use only one of usepkg, usepkgonly') + emerge_flags = { + 'jobs': '--jobs=', + 'loadavg': '--load-average ', + } + + for flag, arg in emerge_flags.iteritems(): + if p[flag] is not None: + args.append(arg + str(p[flag])) + cmd, (rc, out, err) = run_emerge(module, packages, *args) if rc != 0: module.fail_json( @@ -414,6 +454,9 @@ def main(): getbinpkg=dict(default=False, type='bool'), usepkgonly=dict(default=False, type='bool'), usepkg=dict(default=False, type='bool'), + keepgoing=dict(default=False, type='bool'), + jobs=dict(default=None, type='int'), + loadavg=dict(default=None, type='float'), ), required_one_of=[['package', 'sync', 'depclean']], mutually_exclusive=[['nodeps', 'onlydeps'], ['quiet', 'verbose']],