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__/group.cpython-39.pyc
a

�)gHN�@sddlmZmZmZeZdZdZdZddl	Z	ddl
Z
ddlmZddl
mZddlmZGd	d
�d
e�ZGdd�de�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Zdd�Zedk�re�dS) �)�absolute_import�division�print_functionab
---
module: group
version_added: "0.0.2"
short_description: Add or remove groups
requirements:
- groupadd
- groupdel
- groupmod
description:
    - Manage presence of groups on a host.
    - For Windows targets, use the M(ansible.windows.win_group) module instead.
options:
    name:
        description:
            - Name of the group to manage.
        type: str
        required: true
    gid:
        description:
            - Optional I(GID) to set for the group.
        type: int
    state:
        description:
            - Whether the group should be present or not on the remote host.
        type: str
        choices: [ absent, present ]
        default: present
    system:
        description:
            - If I(yes), indicates that the group created is a system group.
        type: bool
        default: no
    local:
        description:
            - Forces the use of "local" command alternatives on platforms that implement it.
            - This is useful in environments that use centralized authentication when you want to manipulate the local groups.
              (for example, it uses C(lgroupadd) instead of C(groupadd)).
            - This requires that these commands exist on the targeted host, otherwise it will be a fatal error.
        type: bool
        default: no
        version_added: "2.6"
    non_unique:
        description:
            - This option allows to change the group ID to a non-unique value. Requires C(gid).
            - Not supported on macOS or BusyBox distributions.
        type: bool
        default: no
        version_added: "2.8"
extends_documentation_fragment: action_common_attributes
attributes:
    check_mode:
        support: full
    diff_mode:
        support: none
    platform:
        platforms: posix
seealso:
- module: ansible.builtin.user
- module: ansible.windows.win_group
author:
- Stephen Fromm (@sfromm)
z�
- name: Ensure group "somegroup" exists
  ansible.builtin.group:
    name: somegroup
    state: present

- name: Ensure group "docker" exists with correct gid
  ansible.builtin.group:
    name: docker
    state: present
    gid: 1750
a�
gid:
  description: Group ID of the group.
  returned: When C(state) is 'present'
  type: int
  sample: 1001
name:
  description: Group name.
  returned: always
  type: str
  sample: users
state:
  description: Whether the group is present or not.
  returned: always
  type: str
  sample: 'absent'
system:
  description: Whether the group is a system group or not.
  returned: When C(state) is 'present'
  type: bool
  sample: False
N)�to_bytes)�
AnsibleModule)�get_platform_subclasscsleZdZdZdZdZdZ�fdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Z�ZS)�Groupa-
    This is a generic Group manipulation class that is subclassed
    based on platform.

    A subclass may wish to override the following action methods:-
      - group_del()
      - group_add()
      - group_mod()

    All subclasses MUST define platform and distribution (which may be None).
    �GenericN�
/etc/groupcstt�}t||��|�S�N)rr�super�__new__)�cls�args�kwargsZnew_cls��	__class__��9/usr/lib/python3.9/site-packages/ansible/modules/group.pyr
�sz
Group.__new__cCsR||_|jd|_|jd|_|jd|_|jd|_|jd|_|jd|_dS)N�state�name�gid�system�local�
non_unique)�module�paramsrrrrrr)�selfrrrr�__init__�szGroup.__init__cCs|j�|�Sr)rZrun_command�r�cmdrrr�execute_command�szGroup.execute_commandcCs.|jrd}nd}|j�|d�|jg}|�|�S)NZ	lgroupdel�groupdelT)rr�get_bin_pathrr!)r�command_namer rrr�	group_del�s
zGroup.group_delcCsJ|jrFt��D]6}|j|jkr|j|jkr|jjd�|j|j�d�qdS)Nz)GID '{0}' already exists with group '{1}'��msg)	r�grp�getgrall�gr_gidr�gr_namer�	fail_json�format)rZgrrrr�_local_check_gid_exists�szGroup._local_check_gid_existscKs�|jrd}|��nd}|j�|d�g}|D]d}|dkrr||durr|�d�|�t||��|jr�|�d�q,|dkr,||dur,|�d�q,|�|j�|�|�S)	NZ	lgroupadd�groupaddTr�-g�-orz-r)	rr.rr#�append�strrrr!)rrr$r �keyrrr�	group_add�s

zGroup.group_addcKs�|jrd}|��nd}|j�|d�g}|��}|D]X}|dkr4||dur4|dt||�kr4|�d�|�t||��|jr4|�d�q4t	|�dkr�d	S|jj
r�d
S|�|j�|�|�S)NZ	lgroupmod�groupmodTr�r0r1��N�r:�rr:r:)
rr.rr#�
group_info�intr2r3r�len�
check_moderr!)rrr$r �infor4rrr�	group_mod�s&
 
zGroup.group_modcCs�|jr�tj�|j�s*|jjd�|j�d�d}d�|j�}t	|jd��B}|�
�ddd�}|D]}|�t|��r^d}qzq^Wd�n1s�0Y|s�|j�
dj|jd	��|Szt�|j�r�WdSWnty�YdS0dS)
NzI'local: true' specified but unable to find local group file {0} to parse.r&Fz{0}:�rb���Tz�'local: true' specified and group was not found in {file}. The local group may already exist if the local group database exists somewhere other than {file}.)�file)r�os�path�exists�	GROUPFILErr,r-r�open�	readlines�
startswithr�warnr(�getgrnam�KeyError)rrGZ	name_test�fZreversed_lines�linerrr�group_exists�s.$��
zGroup.group_existscCs:|��sdSztt�|j��}Wnty4YdS0|S)NF)rQ�listr(rMrrN)rr@rrrr<�szGroup.group_info)�__name__�
__module__�__qualname__�__doc__�platform�distributionrHr
rr!r%r.r5rArQr<�
__classcell__rrrrrvs	 rc@s$eZdZdZdZdZdZdd�ZdS)�SunOSz�
    This is a SunOS Group manipulation class. Solaris doesn't have
    the 'system' group concept.

    This overrides the following methods from the generic class:-
        - group_add()
    Nr
cKsp|j�dd�g}|D]D}|dkr||dur|�d�|�t||��|jr|�d�q|�|j�|�|�S)Nr/Trr0r1)rr#r2r3rrr!�rrr r4rrrr5s
zSunOS.group_add)rSrTrUrVrWrXrHr5rrrrrZ�s
rZc@s4eZdZdZdZdZdZdd�Zdd�Zdd	�Z	dS)
�AIXz�
    This is a AIX Group manipulation class.

    This overrides the following methods from the generic class:-
      - group_del()
      - group_add()
      - group_mod()
    Nr
cCs|j�dd�|jg}|�|�S)NZrmgroupT�rr#rr!rrrrr%"sz
AIX.group_delcKsz|j�dd�g}|D]N}|dkrD||durD|�dt||��q|dkr||dur|�d�q|�|j�|�|�S)NZmkgroupTr�id=rz-a)rr#r2r3rr!r[rrrr5&sz
AIX.group_addcKs�|j�dd�g}|��}|D]B}|dkr||dur|dt||�kr|�dt||��qt|�dkrpdS|jjr|dS|�|j�|�	|�S)	NZchgroupTrr7r^r8r9r;)
rr#r<r=r2r3r>r?rr!)rrr r@r4rrrrA0s z
AIX.group_mod�
rSrTrUrVrWrXrHr%r5rArrrrr\s	
r\c@s4eZdZdZdZdZdZdd�Zdd�Zd	d
�Z	dS)�FreeBsdGroupz�
    This is a FreeBSD Group manipulation class.

    This overrides the following methods from the generic class:-
      - group_del()
      - group_add()
      - group_mod()
    ZFreeBSDNr
cCs |j�dd�d|jg}|�|�S)N�pwTr"r]rrrrr%OszFreeBsdGroup.group_delcKsT|j�dd�d|jg}|jdurJ|�d�|�t|j��|jrJ|�d�|�|�S)NraTr/r0r1)rr#rrr2r3rr!�rrr rrrr5Ss


zFreeBsdGroup.group_addcKs�|j�dd�d|jg}|��}t|�}|jdurlt|j�|dkrl|�d�|�t|j��|j	rl|�d�|t|�kr�|jj
r�dS|�|�SdS)	NraTr6r7r0r1r;r9)rr#rr<r>rr=r2r3rr?r!)rrr r@Zcmd_lenrrrrA\s


zFreeBsdGroup.group_modr_rrrrr`As		r`c@seZdZdZdZdS)�DragonFlyBsdGroupzq
    This is a DragonFlyBSD Group manipulation class.
    It inherits all behaviors from FreeBsdGroup class.
    Z	DragonFlyN)rSrTrUrVrWrrrrrcmsrcc@s:eZdZdZdZdZdd�Zdd�Zddd	�Zd
d�Z	dS)
�DarwinGroupz�
    This is a Mac macOS Darwin Group manipulation class.

    This overrides the following methods from the generic class:-
      - group_del()
      - group_add()
      - group_mod()

    group manipulation are done using dseditgroup(1).
    ZDarwinNcKs�|j�dd�g}|ddg7}|jdur:|dt|j�g7}n@d|vrz|ddurz|��}|durzt|�|_|dt|j�g7}|d|jg7}|�|�\}}}|||fS)	N�dseditgroupTr1Zcreate�-irF�-L)rr#rr3�get_lowest_available_system_gidrr!)rrr r�rc�out�errrrrr5�s

zDarwinGroup.group_addcCsD|j�dd�g}|ddg7}|d|jg7}|�|�\}}}|||fS)NreTr1�deletergr])rr rirjrkrrrr%�s
zDarwinGroup.group_delcCs�|��}|jdur�t|j�|dkr�|j�dd�g}|ddg7}|durX|dt|�g7}|d|jg7}|�|�\}}}|||fSdS)	Nr7reTr1Zeditrfrgr9)r<rr=rr#r3rr!)rrr@r rirjrkrrrrA�s
zDarwinGroup.group_modc
Cs�z�|j�dd�g}|gd�7}|�|�\}}}|��}d}|D]:}|�d�}t|�dkr>t|d�}	|	|kr>|	dkr>|	}q>|dks�|d	kr�Wd
S|dWSty�Yd
S0dS)NZdsclT)z/Local/Defaultz-listz/GroupsZPrimaryGroupIDr� r8rCi�i�F)rr#r!�
splitlines�splitr>r=�	Exception)
rr rirjrk�linesZhighestr<�partsrrrrrh�s"

z+DarwinGroup.get_lowest_available_system_gid)N)
rSrTrUrVrWrXr5r%rArhrrrrrdxs
rdc@s4eZdZdZdZdZdZdd�Zdd�Zd	d
�Z	dS)�OpenBsdGroupz�
    This is a OpenBSD Group manipulation class.

    This overrides the following methods from the generic class:-
      - group_del()
      - group_add()
      - group_mod()
    ZOpenBSDNr
cCs|j�dd�|jg}|�|�S�Nr"Tr]rrrrr%�szOpenBsdGroup.group_delcKsZ|j�dd�g}|jdurD|�d�|�t|j��|jrD|�d�|�|j�|�|�S�Nr/Tr0r1�rr#rr2r3rrr!rbrrrr5�s


zOpenBsdGroup.group_addcKs�|j�dd�g}|��}|jdur^t|j�|dkr^|�d�|�t|j��|jr^|�d�t|�dkrndS|jj	rzdS|�|j
�|�|�S�	Nr6Tr7r0r1r8r9r;�rr#r<rr=r2r3rr>r?rr!�rrr r@rrrrA�s

zOpenBsdGroup.group_modr_rrrrrs�s	
rsc@s4eZdZdZdZdZdZdd�Zdd�Zd	d
�Z	dS)�NetBsdGroupz�
    This is a NetBSD Group manipulation class.

    This overrides the following methods from the generic class:-
      - group_del()
      - group_add()
      - group_mod()
    ZNetBSDNr
cCs|j�dd�|jg}|�|�Srtr]rrrrr%�szNetBsdGroup.group_delcKsZ|j�dd�g}|jdurD|�d�|�t|j��|jrD|�d�|�|j�|�|�Srurvrbrrrr5�s


zNetBsdGroup.group_addcKs�|j�dd�g}|��}|jdur^t|j�|dkr^|�d�|�t|j��|jr^|�d�t|�dkrndS|jj	rzdS|�|j
�|�|�SrwrxryrrrrAs

zNetBsdGroup.group_modr_rrrrrz�s	
rzc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�BusyBoxGroupz�
    BusyBox group manipulation class for systems that have addgroup and delgroup.

    It overrides the following methods:
        - group_add()
        - group_del()
        - group_mod()
    cKsT|j�dd�g}|jdur.|�dt|j�g�|jr>|�d�|�|j�|�|�S)N�addgroupTr0z-S)	rr#r�extendr3rr2rr!rbrrrr5$s

zBusyBoxGroup.group_addcCs|j�dd�|jg}|�|�S)NZdelgroupTr]rrrrr%0szBusyBoxGroup.group_delc	Ks�|��}|jdur�|j|dkr�tdd��}|��}Wd�n1sH0Yt|j�}d||df}d||jf}d|j|vr�|jjdj|jd�d�|jj	r�d	S|�
||�}tdd
��}|�|�Wd�n1s�0Yd	SdS)Nr7r
rBs%s:x:%d:s:%d:zgid '{gid}' in use�rr&r;�wbr9)r<rrI�readrrrr,r-r?�replace�write)	rrr@rOZb_groupsZb_nameZb_current_group_stringZb_new_group_stringZb_new_groupsrrrrA4s &
(zBusyBoxGroup.group_modN)rSrTrUrVr5r%rArrrrr{s	r{c@seZdZdZdZdS)�AlpineGroupZLinuxZAlpineN)rSrTrUrWrXrrrrr�Lsr�cCs�tttddddgd�tddd�tdd�td	d
d�td	d
d�td	d
d�d�dd
ddgggd�}t|�}|�d|j�|jr�|�d|j�d}d}d}i}|j|d<|j|d<|jdkr�|��r�|j	r�|j
dd�|��\}}}|dkr�|j|j|d�n||jdk�rv|���s>|j	�r$|j
dd�|j
|j|jd�\}}}n|j|jd�\}}}|du�rv|dk�rv|j|j|d�|du�r�d
|d<nd|d<|�r�||d<|�r�||d<|���r�|��}|j|d<|d|d<|j
fi|��dS)Nr3ZpresentZabsent)�type�default�choicesT)r��requiredr=)r��boolF)r�r�)rrrrrrrr)Z
argument_specZsupports_check_modeZrequired_ifz Group instantiated - platform %sz$Group instantiated - distribution %sr:rr)�changedr)rr')rrr~r��stdout�stderrrr7)r�dictr�debugrWrXrrrQr?Z	exit_jsonr%r,r5rrrAr<)r�grouprirjrk�resultr@rrr�mainRsd



�
��







r��__main__)Z
__future__rrrr�Z
__metaclass__Z
DOCUMENTATIONZEXAMPLESZRETURNr(rEZansible.module_utils._textrZansible.module_utils.basicrZ$ansible.module_utils.common.sys_infor�objectrrZr\r`rcrdrsrzr{r�r�rSrrrr�<module>s.@
-,E./2C