getent: PEP8 compliancy and doc fixes (#30885)

This PR includes:
- PEP8 compliancy fixes
- Documentation fixes
This commit is contained in:
Dag Wieers 2017-10-30 00:58:04 +01:00 committed by GitHub
parent 11f8d9659d
commit 3ae42afbc7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 33 deletions

View file

@ -1,54 +1,48 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# (c) 2014, Brian Coca <brian.coca+dev@gmail.com> # Copyright: (c) 2014, Brian Coca <brian.coca+dev@gmail.com>
#
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1', ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'], 'status': ['stableinterface'],
'supported_by': 'core'} 'supported_by': 'core'}
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: getent module: getent
short_description: a wrapper to the unix getent utility short_description: A wrapper to the unix getent utility
description: description:
- Runs getent against one of it's various databases and returns information into - Runs getent against one of it's various databases and returns information into
the host's facts, in a getent_<database> prefixed variable the host's facts, in a getent_<database> prefixed variable.
version_added: "1.8" version_added: "1.8"
options: options:
database: database:
required: True
description: description:
- the name of a getent database supported by the target system (passwd, group, - The name of a getent database supported by the target system (passwd, group,
hosts, etc). hosts, etc).
required: True
key: key:
required: False
default: ''
description: description:
- key from which to return values from the specified database, otherwise the - Key from which to return values from the specified database, otherwise the
full contents are returned. full contents are returned.
default: ''
split: split:
required: False
default: None
description: description:
- "character used to split the database values into lists/arrays such as ':' or '\t', otherwise it will try to pick one depending on the database" - "Character used to split the database values into lists/arrays such as ':' or '\t', otherwise it will try to pick one depending on the database."
fail_key: fail_key:
required: False
default: True
description: description:
- If a supplied key is missing this will make the task fail if True - If a supplied key is missing this will make the task fail if C(yes).
type: bool
default: 'yes'
notes: notes:
- "Not all databases support enumeration, check system documentation for details" - Not all databases support enumeration, check system documentation for details.
requirements: [ ] author:
author: "Brian Coca (@bcoca)" - Brian Coca (@bcoca)
''' '''
EXAMPLES = ''' EXAMPLES = '''
@ -97,28 +91,28 @@ from ansible.module_utils._text import to_native
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec = dict( argument_spec=dict(
database = dict(required=True), database=dict(type='str', required=True),
key = dict(required=False, default=None), key=dict(type='str'),
split = dict(required=False, default=None), split=dict(type='str'),
fail_key = dict(required=False, type='bool', default=True), fail_key=dict(type='bool', default=True),
), ),
supports_check_mode = True, supports_check_mode=True,
) )
colon = [ 'passwd', 'shadow', 'group', 'gshadow' ] colon = ['passwd', 'shadow', 'group', 'gshadow']
database = module.params['database'] database = module.params['database']
key = module.params.get('key') key = module.params.get('key')
split = module.params.get('split') split = module.params.get('split')
fail_key = module.params.get('fail_key') fail_key = module.params.get('fail_key')
getent_bin = module.get_bin_path('getent', True) getent_bin = module.get_bin_path('getent', True)
if key is not None: if key is not None:
cmd = [ getent_bin, database, key ] cmd = [getent_bin, database, key]
else: else:
cmd = [ getent_bin, database ] cmd = [getent_bin, database]
if split is None and database in colon: if split is None and database in colon:
split = ':' split = ':'
@ -130,7 +124,7 @@ def main():
msg = "Unexpected failure!" msg = "Unexpected failure!"
dbtree = 'getent_%s' % database dbtree = 'getent_%s' % database
results = { dbtree: {} } results = {dbtree: {}}
if rc == 0: if rc == 0:
for line in out.splitlines(): for line in out.splitlines():

View file

@ -342,7 +342,6 @@ lib/ansible/modules/system/debconf.py
lib/ansible/modules/system/facter.py lib/ansible/modules/system/facter.py
lib/ansible/modules/system/filesystem.py lib/ansible/modules/system/filesystem.py
lib/ansible/modules/system/gconftool2.py lib/ansible/modules/system/gconftool2.py
lib/ansible/modules/system/getent.py
lib/ansible/modules/system/gluster_volume.py lib/ansible/modules/system/gluster_volume.py
lib/ansible/modules/system/group.py lib/ansible/modules/system/group.py
lib/ansible/modules/system/hostname.py lib/ansible/modules/system/hostname.py