�
�Udac @` s� d d l m Z m Z m Z e Z i d d 6d g d 6d d 6Z d Z d Z d d
l Z d d l
m Z d d l m
Z
d
� Z e d k r� e � n d
S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont stableinterfacet statust coret supported_bys/
---
module: getent
short_description: A wrapper to the unix getent utility
description:
- Runs getent against one of it's various databases and returns information into
the host's facts, in a getent_<database> prefixed variable.
version_added: "1.8"
options:
database:
description:
- The name of a getent database supported by the target system (passwd, group,
hosts, etc).
required: True
key:
description:
- Key from which to return values from the specified database, otherwise the
full contents are returned.
default: ''
service:
description:
- Override all databases with the specified service
- The underlying system must support the service flag which is not always available.
version_added: "2.9"
split:
description:
- "Character used to split the database values into lists/arrays such as ':' or ' ', otherwise it will try to pick one depending on the database."
fail_key:
description:
- If a supplied key is missing this will make the task fail if C(yes).
type: bool
default: 'yes'
notes:
- Not all databases support enumeration, check system documentation for details.
author:
- Brian Coca (@bcoca)
s@
# get root user info
- getent:
database: passwd
key: root
- debug:
var: getent_passwd
# get all groups
- getent:
database: group
split: ':'
- debug:
var: getent_group
# get all hosts, split by tab
- getent:
database: hosts
- debug:
var: getent_hosts
# get http service info, no error if missing
- getent:
database: services
key: http
fail_key: False
- debug:
var: getent_services
# get user password hash (requires sudo/root)
- getent:
database: shadow
key: www-data
split: ':'
- debug:
var: getent_shadow
N( t
AnsibleModule( t to_nativec C` s� t d t d t d d d t � d t d d � d t d d � d t d d � d t d d
d t � � d t � } d
d d d g } | j d } | j j d � } | j j d � } | j j d � } | j j d � } | j d t � } | d k r| | | g } n | | g } | d k r4| j d | g � n | d k rU| | k rUd } n y | j | � \ } }
} Wn5 t k
r�} | j
d t | � d t j
� � n Xd }
d | } i i | 6} | d k r!x9 |
j � D]+ } | j | � } | d | | | d <q�W| j d | � nl | d k r6d }
nW | d k rxd }
| s�d | | | <| j d | d |
� q�n | d k r�d }
n | j
d |
� d S( Nt
argument_spect databaset typet strt requiredt keyt servicet splitt fail_keyt boolt defaultt supports_check_modet passwdt shadowt groupt gshadowt getents -st :t msgt exceptions Unexpected failure!s getent_%si i t
ansible_factss'