mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add toggle for verbose logging to pkg5.py (#8382)
* Add toggle for verbose logging Updated params with 'verbose' mode (defaults to False, which is existing behavior) to allow users to toggle verbose to True, which disables the '-q' flag that was hardcoded in the original module * Create 8379-verbose-mode-pkg5.yml * update pkg5.py to conform to PEP8 length requirements The new verbosity argument on line 172 broke the 160 character length PEP8 requirement - split the line in two to conform to PEP8 * Add PR link to changelog fragement yml Co-authored-by: Felix Fontein <felix@fontein.de> * Add version_added and make the description of the verbose param clearer * Update pkg5.py verbose description to conform to ansible documentation for semantic markup Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
f82e7a7b83
commit
bebe162a22
2 changed files with 16 additions and 1 deletions
2
changelogs/fragments/8379-verbose-mode-pkg5.yml
Normal file
2
changelogs/fragments/8379-verbose-mode-pkg5.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- pkg5 - add support for non-silent execution (https://github.com/ansible-collections/community.general/issues/8379, https://github.com/ansible-collections/community.general/pull/8382).
|
|
@ -54,6 +54,12 @@ options:
|
||||||
- Refresh publishers before execution.
|
- Refresh publishers before execution.
|
||||||
type: bool
|
type: bool
|
||||||
default: true
|
default: true
|
||||||
|
verbose:
|
||||||
|
description:
|
||||||
|
- Set to V(true) to disable quiet execution.
|
||||||
|
type: bool
|
||||||
|
default: false
|
||||||
|
version_added: 9.0.0
|
||||||
'''
|
'''
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
- name: Install Vim
|
- name: Install Vim
|
||||||
|
@ -90,6 +96,7 @@ def main():
|
||||||
accept_licenses=dict(type='bool', default=False, aliases=['accept', 'accept_licences']),
|
accept_licenses=dict(type='bool', default=False, aliases=['accept', 'accept_licences']),
|
||||||
be_name=dict(type='str'),
|
be_name=dict(type='str'),
|
||||||
refresh=dict(type='bool', default=True),
|
refresh=dict(type='bool', default=True),
|
||||||
|
verbose=dict(type='bool', default=False),
|
||||||
),
|
),
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
@ -156,9 +163,15 @@ def ensure(module, state, packages, params):
|
||||||
else:
|
else:
|
||||||
no_refresh = ['--no-refresh']
|
no_refresh = ['--no-refresh']
|
||||||
|
|
||||||
|
if params['verbose']:
|
||||||
|
verbosity = []
|
||||||
|
else:
|
||||||
|
verbosity = ['-q']
|
||||||
|
|
||||||
to_modify = list(filter(behaviour[state]['filter'], packages))
|
to_modify = list(filter(behaviour[state]['filter'], packages))
|
||||||
if to_modify:
|
if to_modify:
|
||||||
rc, out, err = module.run_command(['pkg', behaviour[state]['subcommand']] + dry_run + accept_licenses + beadm + no_refresh + ['-q', '--'] + to_modify)
|
rc, out, err = module.run_command(
|
||||||
|
['pkg', behaviour[state]['subcommand']] + dry_run + accept_licenses + beadm + no_refresh + verbosity + ['--'] + to_modify)
|
||||||
response['rc'] = rc
|
response['rc'] = rc
|
||||||
response['results'].append(out)
|
response['results'].append(out)
|
||||||
response['msg'] += err
|
response['msg'] += err
|
||||||
|
|
Loading…
Reference in a new issue