From 9d720f52c805e3843fca49926127de7f94afff31 Mon Sep 17 00:00:00 2001 From: Peter Oliver Date: Sat, 4 Apr 2015 19:27:37 +0100 Subject: [PATCH] Add an accept_licenses option to pkg5 module This accepts any software licences required by the package. --- packaging/os/pkg5.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/packaging/os/pkg5.py b/packaging/os/pkg5.py index eea860e7be2..0e4c565b90e 100644 --- a/packaging/os/pkg5.py +++ b/packaging/os/pkg5.py @@ -39,6 +39,13 @@ options: required: false default: present choices: [ present, latest, absent ] + accept_licenses: + description: + - Accept any licences. + required: false + default: false + choices: [ true, false ] + aliases: [ accept_licences, accept ] ''' EXAMPLES = ''' # Install Vim: @@ -70,6 +77,11 @@ def main(): 'removed', ] ), + accept_licenses=dict( + choices=BOOLEANS, + default=False + aliases=['accept_licences', 'accept'] + ), ) ) @@ -89,14 +101,14 @@ def main(): packages.append(fragment) if params['state'] in ['present', 'installed']: - ensure(module, 'present', packages) + ensure(module, 'present', packages, params) elif params['state'] in ['latest']: - ensure(module, 'latest', packages) + ensure(module, 'latest', packages, params) elif params['state'] in ['absent', 'uninstalled', 'removed']: - ensure(module, 'absent', packages) + ensure(module, 'absent', packages, params) -def ensure(module, state, packages): +def ensure(module, state, packages, params): response = { 'results': [], 'msg': '', @@ -119,7 +131,13 @@ def ensure(module, state, packages): to_modify = filter(behaviour[state]['filter'], packages) if to_modify: rc, out, err = module.run_command( - ['pkg', behaviour[state]['subcommand'], '-q', '--'] + to_modify + [ + 'pkg', behaviour[state]['subcommand'] + ] + + (['--accept'] if params['accept_licenses'] else []) + + [ + '-q', '--' + ] + to_modify ) response['rc'] = rc response['results'].append(out)