From c8c4305057c1c20017c608c27e070aeacfb761c7 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. --- .../modules/extras/packaging/os/pkg5.py | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/lib/ansible/modules/extras/packaging/os/pkg5.py b/lib/ansible/modules/extras/packaging/os/pkg5.py index 83c08af0c3b..67b39443a4d 100644 --- a/lib/ansible/modules/extras/packaging/os/pkg5.py +++ b/lib/ansible/modules/extras/packaging/os/pkg5.py @@ -38,6 +38,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: @@ -69,6 +76,11 @@ def main(): 'removed', ] ), + accept_licenses=dict( + choices=BOOLEANS, + default=False + aliases=['accept_licences', 'accept'] + ), ) ) @@ -88,14 +100,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': '', @@ -118,7 +130,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)