Add an accept_licenses option to pkg5 module

This accepts any software licences required by the package.
pull/18777/head
Peter Oliver 10 years ago committed by Matt Clay
parent f7d2f76976
commit c8c4305057

@ -38,6 +38,13 @@ options:
required: false required: false
default: present default: present
choices: [ present, latest, absent ] choices: [ present, latest, absent ]
accept_licenses:
description:
- Accept any licences.
required: false
default: false
choices: [ true, false ]
aliases: [ accept_licences, accept ]
''' '''
EXAMPLES = ''' EXAMPLES = '''
# Install Vim: # Install Vim:
@ -69,6 +76,11 @@ def main():
'removed', 'removed',
] ]
), ),
accept_licenses=dict(
choices=BOOLEANS,
default=False
aliases=['accept_licences', 'accept']
),
) )
) )
@ -88,14 +100,14 @@ def main():
packages.append(fragment) packages.append(fragment)
if params['state'] in ['present', 'installed']: if params['state'] in ['present', 'installed']:
ensure(module, 'present', packages) ensure(module, 'present', packages, params)
elif params['state'] in ['latest']: elif params['state'] in ['latest']:
ensure(module, 'latest', packages) ensure(module, 'latest', packages, params)
elif params['state'] in ['absent', 'uninstalled', 'removed']: 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 = { response = {
'results': [], 'results': [],
'msg': '', 'msg': '',
@ -118,7 +130,13 @@ def ensure(module, state, packages):
to_modify = filter(behaviour[state]['filter'], packages) to_modify = filter(behaviour[state]['filter'], packages)
if to_modify: if to_modify:
rc, out, err = module.run_command( 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['rc'] = rc
response['results'].append(out) response['results'].append(out)

Loading…
Cancel
Save