W3cubDocs

/Ansible

getent - a wrapper to the unix getent utility

New in version 1.8.

Synopsis

  • Runs getent against one of it’s various databases and returns information into the host’s facts, in a getent_<database> prefixed variable

Options

parameter required default choices comments
database
yes
the name of a getent database supported by the target system (passwd, group, hosts, etc).
fail_key
no True
If a supplied key is missing this will make the task fail if True
key
no
key from which to return values from the specified database, otherwise the full contents are returned.
split
no None
character used to split the database values into lists/arrays such as ':' or ' ', otherwise it will try to pick one depending on the database

Examples

# 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

Notes

Note

  • Not all databases support enumeration, check system documentation for details

Status

This module is flagged as stableinterface which means that the maintainers for this module guarantee that no backward incompatible interface changes will be made.

Maintenance Info

For more information about Red Hat’s this support of this module, please refer to this knowledge base article<https://access.redhat.com/articles/rhel-top-support-policies>

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.

© 2012–2017 Michael DeHaan
© 2017 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/getent_module.html