|
|
|
@ -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)
|
|
|
|
|