1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Provide a boolean switch to enable/disable publisher refresh

This commit is contained in:
Julian Paul Dasmarinas 2018-11-14 20:11:50 +08:00 committed by ansibot
parent 2cb9ec9f0e
commit 0622f387c4

View file

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