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: //usr/lib/python3.9/site-packages/ansible/modules/__pycache__/sysvinit.cpython-39.pyc
a

�)g�5�@s~ddlmZmZmZeZdZdZdZddl	Z	ddl
mZddlm
Z
ddlmZmZmZmZmZmZd	d
�Zedkrze�dS)�)�absolute_import�division�print_functiona�

module: sysvinit
author:
    - "Ansible Core Team"
version_added: "2.6"
short_description:  Manage SysV services.
description:
    - Controls services on target hosts that use the SysV init system.
options:
    name:
        required: true
        description:
            - Name of the service.
        type: str
        aliases: ['service']
    state:
        choices: [ 'started', 'stopped', 'restarted', 'reloaded' ]
        description:
            - C(started)/C(stopped) are idempotent actions that will not run commands unless necessary.
              Not all init scripts support C(restarted) nor C(reloaded) natively, so these will both trigger a stop and start as needed.
        type: str
    enabled:
        type: bool
        description:
            - Whether the service should start on boot. B(At least one of state and enabled are required.)
    sleep:
        default: 1
        description:
            - If the service is being C(restarted) or C(reloaded) then sleep this many seconds between the stop and start command.
              This helps to workaround badly behaving services.
        type: int
    pattern:
        description:
            - A substring to look for as would be found in the output of the I(ps) command as a stand-in for a status result.
            - If the string is found, the service will be assumed to be running.
            - "This option is mainly for use with init scripts that don't support the 'status' option."
        type: str
    runlevels:
        description:
            - The runlevels this script should be enabled/disabled from.
            - Use this to override the defaults set by the package or init script itself.
        type: list
        elements: str
    arguments:
        description:
            - Additional arguments provided on the command line that some init scripts accept.
        type: str
        aliases: [ 'args' ]
    daemonize:
        type: bool
        description:
            - Have the module daemonize as the service itself might not do so properly.
            - This is useful with badly written init scripts or daemons, which
              commonly manifests as the task hanging as it is still holding the
              tty or the service dying when the task is over as the connection
              closes the session.
        default: no
extends_documentation_fragment: action_common_attributes
attributes:
    check_mode:
        support: full
    diff_mode:
        support: none
    platform:
        platforms: posix
notes:
    - One option other than name is required.
    - The service names might vary by specific OS/distribution
requirements:
    - That the service managed has a corresponding init script.
a:
- name: Make sure apache2 is started
  ansible.builtin.sysvinit:
      name: apache2
      state: started
      enabled: yes

- name: Make sure apache2 is started on runlevels 3 and 5
  ansible.builtin.sysvinit:
      name: apache2
      state: started
      enabled: yes
      runlevels:
        - 3
        - 5
az
results:
    description: results from actions taken
    returned: always
    type: complex
    sample: {
            "attempts": 1,
            "changed": true,
            "name": "apache2",
            "status": {
                "enabled": {
                    "changed": true,
                    "rc": 0,
                    "stderr": "",
                    "stdout": ""
                },
                "stopped": {
                    "changed": true,
                    "rc": 0,
                    "stderr": "",
                    "stdout": "Stopping web server: apache2.\n"
                }
            }
        }
N)�sleep)�
AnsibleModule)�sysv_is_enabled�get_sysv_script�sysv_exists�fail_if_missing�get_ps�	daemonizec
s�tttdddgd�tgd�dd�tdd�td	d
d�tdd�tddgd
�tddd�tddd�d�dddggd���jd��jd��jd}�jd}�jd}�jd}d}d}}�did�}t�t����t���gd�}gd�}	i}
i}|	D]}�j||d�||<q�|�rB|D]&}
|
�|
i�t�|
d�|
|
d<�qnt��|
d<d}d}|�rnt	�|�}}�n:|�
d��r�d |d�f}n��r�d!�}n�jd"d#���|�\}}}|d$k�sp�d%k�r�d&|v�r�d}d}|�s\|�
d'�d
k�r\|������d�}d(D]}||v�rd}�q(�q|�s\d)D](}||v�r2d*|v�r2d}d}�q\�q2|�sp|d+v�rpd}|�s�|dk�r�d}d}nt	����r�d}d}��d,�|�s���d-�|d.�di�d|d.dd/<d|d.dd0<d|d.dd1<d|d.dd2<|�r4||d.dd<|D]0}
||
|
dk�r"d|d/<d|d.dd/<�q"�j�s"|d/�r"|�r�|�
d3��r���d4|d3�d5�|�f�\}}}n0|�
d6��r2��d7|d6d�|��f�\}}}nb|�
d3��r��d8|d3�d5�|�f�\}}}n0|�
d6��r"��d9|d6d�|��f�\}}}n�|du�rd||
dk�rdd|d/<d|d.dd/<�j�s"|d/�r"|�r�|�
d3��r���d:|d3�f�\}}}n(|�
d6��r"��d;|d6�f�\}}}nR|�
d3��r���d<|d3�f�\}}}n(|�
d6��r"��d=|d6�f�\}}}�j�s�|d.dd/�r�||d.dd0<||d.dd1<||d.dd2<d>\}}}d?|d.dd2v�r��jfd@dA�i|��|d.��jdi�d|d.�jdd/<d|d.�jdd0<d|d.�jdd1<d|d.�jdd2<��r�t�dBd���������fdCdD�}�dEk�r�d|d/<d|d.�jdd/<�j�sdFD]"}||�\}}}|�rpt|��qpn�|�dGkk�r�d|d/<d|d.�jdd/<�j�s|��\}}}nB|�dHkk�rd|d/<d|d.�jdd/<�j�s|��\}}}�j�s�|d.�jdd/�r�||d.�jdd0<||d.�jdd1<||d.�jdd2<d>\}}}�jfi|��dS)INT�str�service)�required�type�aliases)�started�stoppedZ	restartedZreloaded)�choicesr�bool)r�int�)r�default�args)rr�list)r�elementsF)�name�state�enabledr�pattern�	arguments�	runlevelsrrr)Z
argument_specZsupports_check_modeZrequired_one_ofrr!rrr�)r�changed�status)z/sbinz	/usr/sbinz/binz/usr/bin)�	chkconfig�update-rc.dZinsservr)Zopt_dirs)Zrunlevelz%s %s statusz	%s statusz"Unable to determine service status)�msg���ZiptablesZACCEPT�
)�stopzis dead z	dead but zcould not access pid fileZinactive)�run�startZactiveznot )r����EzTUsed ps output to match service name and determine it is up, this is very unreliablez9Unable to determine if service is up, assuming it is downr$r#�rc�stdout�stderrr&z%s %s enable %s� r%z%s --level %s %s onz%s %s disable %sz%s --level %s %s offz%s %s defaultsz%s %s onz
%s %s disablez	%s %s off)NNNzillegal runlevel specifiedr'z=Illegal runlevel specified for enable operation on service %szp?ed$cs|�jd}d�||durdn|f}�jdr@t�|�\}}}n��|�\}}}|dkrr�jd��f|||d�|||fS)Nr z%s %s %sr"rrzFailed to %s service: %s)r'r1r2r3)�paramsr�run_command�	fail_json)Zdoitr�cmdr1�out�err��action�modulerZscript��</usr/lib/python3.9/site-packages/ansible/modules/sysvinit.py�runme8s

zmain.<locals>.runmeZrestart)r*r,r,r*)r�dictr5r
r	rZget_bin_path�
setdefaultrr�getr7r6�count�lower�replace�warnZ
check_mode�join�re�subrZ	exit_json)rr!rZ	sleep_forr1r9r:�result�pathsZbinariesZrunlevel_status�locationZbinaryZrlZ
is_startedZworkedr8ZcleanoutrZstarted_statusr@Zdothisr>r;r?�main�s,


�
�





�







&&&&

 
rN�__main__)Z
__future__rrrrZ
__metaclass__Z
DOCUMENTATIONZEXAMPLESZRETURNrI�timerZansible.module_utils.basicrZansible.module_utils.servicerrr	r
rrrN�__name__r>r>r>r?�<module>sH h