HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //proc/self/root/usr/lib/python3.9/site-packages/ansible/modules/__pycache__/getent.cpython-39.pyc
a

�)g?�@s^ddlmZmZmZeZdZdZdZddl	Z	ddl
mZddlm
Z
dd	�Zed
krZe�dS)�)�absolute_import�division�print_functiona�
---
module: getent
short_description: A wrapper to the unix getent utility
description:
     - Runs getent against one of its 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).
        type: str
        required: True
    key:
        description:
            - Key from which to return values from the specified database, otherwise the
              full contents are returned.
        type: str
        default: ''
    service:
        description:
            - Override all databases with the specified service
            - The underlying system must support the service flag which is not always available.
        type: str
        version_added: "2.9"
    split:
        description:
            - Character used to split the database values into lists/arrays such as C(:) or C(\t),
              otherwise it will try to pick one depending on the database.
        type: str
    fail_key:
        description:
            - If a supplied key is missing this will make the task fail if C(true).
        type: bool
        default: 'yes'
extends_documentation_fragment:
  - action_common_attributes
  - action_common_attributes.facts
attributes:
    check_mode:
        support: full
    diff_mode:
        support: none
    facts:
        support: full
    platform:
        platforms: posix
notes:
   - Not all databases support enumeration, check system documentation for details.
author:
- Brian Coca (@bcoca)
aD
- name: Get root user info
  ansible.builtin.getent:
    database: passwd
    key: root
- ansible.builtin.debug:
    var: ansible_facts.getent_passwd

- name: Get all groups
  ansible.builtin.getent:
    database: group
    split: ':'
- ansible.builtin.debug:
    var: ansible_facts.getent_group

- name: Get all hosts, split by tab
  ansible.builtin.getent:
    database: hosts
- ansible.builtin.debug:
    var: ansible_facts.getent_hosts

- name: Get http service info, no error if missing
  ansible.builtin.getent:
    database: services
    key: http
    fail_key: False
- ansible.builtin.debug:
    var: ansible_facts.getent_services

- name: Get user password hash (requires sudo/root)
  ansible.builtin.getent:
    database: shadow
    key: www-data
    split: ':'
- ansible.builtin.debug:
    var: ansible_facts.getent_shadow

a�
ansible_facts:
  description: Facts to add to ansible_facts.
  returned: always
  type: dict
  contains:
    getent_<database>:
      description:
        - A list of results or a single result as a list of the fields the db provides
        - The list elements depend on the database queried, see getent man page for the structure
        - Starting at 2.11 it now returns multiple duplicate entries, previouslly it only returned the last one
      returned: always
      type: list
N)�
AnsibleModule)�	to_nativec
Csbtttddd�tddd�tdd�tdd�tddd�d	�dd
�}gd�}|jd}|j�d
�}|j�d�}|j�d�}|j�d�}|�dd�}|dur�|||g}n||g}|dur�|�d|g�|dur�||vr�d}z|�|�\}	}
}Wn<t�y"}z"|jt	|�t
��d�WYd}~n
d}~00d}
d|}|ii}|	dk�ri}|
��D]�}|�
|�}|d|v�r�||ddk�r�|||dg|||d<|||d�|dd��||dd7<n$|dd�|||d<d||d<�qN|j|d�nN|	dk�rd}
n>|	dk�rDd}
|�sRd|||<|j||
d�n|	dk�rRd}
|j|
d �dS)!N�strT)�type�requiredF)rZno_log)r�bool)r�default)�database�key�service�split�fail_key)Z
argument_specZsupports_check_mode)�passwdZshadow�groupZgshadowrr
rrrZgetentz-s�:)�msg�	exceptionzUnexpected failure!z	getent_%sr�)�
ansible_factsz'Missing arguments, or database unknown.�z<One or more supplied key could not be found in the database.)rr�z+Enumeration not supported on this database.)r)r�dict�params�getZget_bin_path�extendZrun_command�	ExceptionZ	fail_jsonr�	traceback�
format_exc�
splitlinesr�appendZ	exit_json)�module�colonrr
rrrZ
getent_bin�cmd�rc�out�err�erZdbtree�results�seen�line�record�r.�:/usr/lib/python3.9/site-packages/ansible/modules/getent.py�main}sj


��
,




r0�__main__)Z
__future__rrrrZ
__metaclass__Z
DOCUMENTATIONZEXAMPLESZRETURNrZansible.module_utils.basicrZansible.module_utils._textrr0�__name__r.r.r.r/�<module>s7'J