Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/system/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/system/runit.pyo

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zdd
l	Z	dd
l
Z
ddlmZddl
mZd
�Zdefd��YZd�Zedkr�e�nd
S(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontstableinterfacetstatust	communitytsupported_bys+
---
module: runit
author:
- James Sumners (@jsumners)
version_added: "2.3"
short_description: Manage runit services
description:
    - Controls runit services on remote hosts using the sv utility.
options:
    name:
        description:
            - Name of the service to manage.
        type: str
        required: yes
    state:
        description:
            - C(started)/C(stopped) are idempotent actions that will not run
              commands unless necessary.  C(restarted) will always bounce the
              service (sv restart) and C(killed) will always bounce the service (sv force-stop).
              C(reloaded) will send a HUP (sv reload).
              C(once) will run a normally downed sv once (sv once), not really
              an idempotent operation.
        type: str
        choices: [ killed, once, reloaded, restarted, started, stopped ]
    enabled:
        description:
            - Whether the service is enabled or not, if disabled it also implies stopped.
        type: bool
    service_dir:
        description:
            - directory runsv watches for services
        type: str
        default: /var/service
    service_src:
        description:
            - directory where services are defined, the source of symlinks to service_dir.
        type: str
        default: /etc/sv
s8
- name: Start sv dnscache, if not running
  runit:
    name: dnscache
    state: started

- name: Stop sv dnscache, if running
  runit:
    name: dnscache
    state: stopped

- name: Kill sv dnscache, in all cases
  runit:
    name: dnscache
    state: killed

- name: Restart sv dnscache, in all cases
  runit:
    name: dnscache
    state: restarted

- name: Reload sv dnscache, in all cases
  runit:
    name: dnscache
    state: reloaded

- name: Use alternative sv directory location
  runit:
    name: dnscache
    state: reloaded
    service_dir: /run/service
N(t
AnsibleModule(t	to_nativecO`s�d}|djd}|dk	rdx>|j�D]-}|jdk	r0|j|kr0|}q0q0Wn|dkry|}nt||�j|�S(s-
    Used for derivative implementations
    tmoduletdistroN(tNonetparamst__subclasses__Rtsupert__new__(tclstargstkwargstsubclassRtsc((s@/usr/lib/python2.7/site-packages/ansible/modules/system/runit.pyt_load_dist_subclassas	tSvcB`s�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�ZRS(s�
    Main class that handles daemontools, can be subclassed and overridden in case
    we want to use a 'derivative' like encore, s6, etc
    cC`s@g|_dddddddg|_||_|jd|_|jd	|_|jd
|_d|_d|_	d|_
d|_d|_|j
dd|jd
t�|_|j
dd|j�|_dj|j|jg�|_dj|j|jg�|_tjj|j�|_|jr3|j�n	d|_
dS(Ntstatetenabledtsvc_fulltsrc_fulltpidtdurationt
full_statetnametservice_dirtservice_srctsvtopt_dirstrequiredt/tstopped(textra_pathstreport_varsR
R
RR R!RRRRRRtget_bin_pathtTruetsvc_cmdt
svstat_cmdtjoinRRtostpathtlexistst
get_status(tselfR
((s@/usr/lib/python2.7/site-packages/ansible/modules/system/runit.pyt__init__}s&							!	
cC`s�tjj|j�rnytj|j|j�Wq�tk
rj}|jjd|jddt	|��q�Xn|jjdd|j�dS(NR/tmsgsError while linking: %ss1Could not find source for service to enable (%s).(
R.R/texistsRtsymlinkRtOSErrorR
t	fail_jsonR	(R2te((s@/usr/lib/python2.7/site-packages/ansible/modules/system/runit.pytenable�s-cC`sp|j|jd|jg�ytj|j�Wn9tk
rk}|jjd|jddt	|��nXdS(Ns
force-stopR/R4sError while unlinking: %s(
texecute_commandR+RR.tunlinkRR7R
R8R	(R2R9((s@/usr/lib/python2.7/site-packages/ansible/modules/system/runit.pytdisable�s
cC`s|j|jd|jg�\}}}|dk	rL|rL||_|_n�||_|jjd�d}tjd|�}|r�|j	d�|_
ntjd|�}|r�|j	d�|_ntjd|�r�d|_n+tjd	|�rd
|_n
d|_dSdS(NRs; is
\(pid (\d+)\)is (\d+)ss^run:tstarteds^down:R&tunknown(R;R,RRRRtsplittretsearchtgroupRR(R2trctoutterrtfull_state_no_loggertm((s@/usr/lib/python2.7/site-packages/ansible/modules/system/runit.pyR1�s"'		cC`s
|j�S(N(tstart(R2((s@/usr/lib/python2.7/site-packages/ansible/modules/system/runit.pyR>�scC`s|j|jd|jg�S(NRI(R;R+R(R2((s@/usr/lib/python2.7/site-packages/ansible/modules/system/runit.pyRI�scC`s
|j�S(N(tstop(R2((s@/usr/lib/python2.7/site-packages/ansible/modules/system/runit.pyR&�scC`s|j|jd|jg�S(NRJ(R;R+R(R2((s@/usr/lib/python2.7/site-packages/ansible/modules/system/runit.pyRJ�scC`s|j|jd|jg�S(Ntonce(R;R+R(R2((s@/usr/lib/python2.7/site-packages/ansible/modules/system/runit.pyRK�scC`s
|j�S(N(treload(R2((s@/usr/lib/python2.7/site-packages/ansible/modules/system/runit.pytreloaded�scC`s|j|jd|jg�S(NRL(R;R+R(R2((s@/usr/lib/python2.7/site-packages/ansible/modules/system/runit.pyRL�scC`s
|j�S(N(trestart(R2((s@/usr/lib/python2.7/site-packages/ansible/modules/system/runit.pyt	restarted�scC`s|j|jd|jg�S(NRN(R;R+R(R2((s@/usr/lib/python2.7/site-packages/ansible/modules/system/runit.pyRN�scC`s
|j�S(N(tkill(R2((s@/usr/lib/python2.7/site-packages/ansible/modules/system/runit.pytkilled�scC`s|j|jd|jg�S(Ns
force-stop(R;R+R(R2((s@/usr/lib/python2.7/site-packages/ansible/modules/system/runit.pyRP�scC`shy(|jjdj|��\}}}Wn0tk
rZ}|jjddt|��nX|||fS(Nt R4sfailed to execute: %s(R
trun_commandR-t	ExceptionR8R	(R2tcmdRDRERFR9((s@/usr/lib/python2.7/site-packages/ansible/modules/system/runit.pyR;�s
(!cC`s9|j�i}x"|jD]}|j|||<qW|S(N(R1R(t__dict__(R2tstatestk((s@/usr/lib/python2.7/site-packages/ansible/modules/system/runit.pytreport�s

(t__name__t
__module__t__doc__R3R:R=R1R>RIR&RJRKRMRLRORNRQRPR;RY(((s@/usr/lib/python2.7/site-packages/ansible/modules/system/runit.pyRts$																	cC`s�tdtdtdddt�dtddddd	d
ddd
g�dtdd�dtdddd�dtdddd�dtdddd��dt�}tdddddddd�|_|jd}|jd}t|�}t}|j�}|dk	r�||j	kr�t}|j
s�y!|r>|j�n
|j�Wq�t
tfk
r~}|jddt|��q�Xq�n|dk	r�||jkr�t}|j
s�t||��q�n|jd|d |j��dS(!Nt
argument_specRttypetstrR$RtchoicesRQRKRMROR>R&RtbooltdisttdefaulttrunitR s/var/serviceR!s/etc/svtsupports_check_modetLANGtCtLC_ALLtLC_MESSAGEStLC_CTYPER4s!Could not change service link: %stchangedR"(RtdictR*trun_command_environ_updateR
RtFalseRYRRt
check_modeR:R=R7tIOErrorR8R	Rtgetattrt	exit_json(R
RRR"Rkt
orig_stateR9((s@/usr/lib/python2.7/site-packages/ansible/modules/system/runit.pytmain�s:'	$

	
$	t__main__(t
__future__RRRR^t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLESR.RAtansible.module_utils.basicRtansible.module_utils._textR	RtobjectRRtRZ(((s@/usr/lib/python2.7/site-packages/ansible/modules/system/runit.pyt<module>s


+!		)

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]