From 0622f387c46171ddd2334666ed46706b9b626d9a Mon Sep 17 00:00:00 2001 From: Julian Paul Dasmarinas Date: Wed, 14 Nov 2018 20:11:50 +0800 Subject: [PATCH] Provide a boolean switch to enable/disable publisher refresh --- lib/ansible/modules/packaging/os/pkg5.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/packaging/os/pkg5.py b/lib/ansible/modules/packaging/os/pkg5.py index 4690f7e860..8bdd2ffbdc 100644 --- a/lib/ansible/modules/packaging/os/pkg5.py +++ b/lib/ansible/modules/packaging/os/pkg5.py @@ -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