Provide a boolean switch to enable/disable publisher refresh

pull/51201/head
Julian Paul Dasmarinas 6 years ago committed by ansibot
parent 2cb9ec9f0e
commit 0622f387c4

@ -44,12 +44,23 @@ options:
- creates a new boot environment with the given name
version_added: "2.8"
type: str
refresh:
description:
- refresh publishers before execution
version_added: "2.8"
type: bool
default: 'yes'
'''
EXAMPLES = '''
- name: Install Vim
pkg5:
name: editor/vim
- name: Install Vim without refreshing publishers
pkg5:
name: editor/vim
refresh: no
- name: Remove finger daemon
pkg5:
name: service/network/finger
@ -74,6 +85,7 @@ def main():
state=dict(type='str', default='present', choices=['absent', 'installed', 'latest', 'present', 'removed', 'uninstalled']),
accept_licenses=dict(type='bool', default=False, aliases=['accept', 'accept_licences']),
be_name=dict(type='str'),
refresh=dict(type='bool', default=True),
),
supports_check_mode=True,
)
@ -135,9 +147,14 @@ def ensure(module, state, packages, params):
else:
beadm = []
if params['refresh']:
no_refresh = []
else:
no_refresh = ['--no-refresh']
to_modify = filter(behaviour[state]['filter'], packages)
if to_modify:
rc, out, err = module.run_command(['pkg', behaviour[state]['subcommand']] + dry_run + accept_licenses + beadm + ['-q', '--'] + to_modify)
rc, out, err = module.run_command(['pkg', behaviour[state]['subcommand']] + dry_run + accept_licenses + beadm + no_refresh + ['-q', '--'] + to_modify)
response['rc'] = rc
response['results'].append(out)
response['msg'] += err

Loading…
Cancel
Save