Anons79 Mini Shell

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

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zdd
l	Z	dd
l
Z
dd
lZddlm
Z
ddlmZd
�Zdefd��YZd�Zedkr�e�nd
S(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontstableinterfacetstatust	communitytsupported_bysS
---
module: svc
author:
- Brian Coca (@bcoca)
version_added: "1.9"
short_description:  Manage daemontools services
description:
    - Controls daemontools services on remote hosts using the svc utility.
options:
    name:
        description:
            - Name of the service to manage.
        type: str
        required: true
    state:
        description:
            - C(Started)/C(stopped) are idempotent actions that will not run
              commands unless necessary.  C(restarted) will always bounce the
              svc (svc -t) and C(killed) will always bounce the svc (svc -k).
              C(reloaded) will send a sigusr1 (svc -1).
              C(once) will run a normally downed svc once (svc -o), not really
              an idempotent operation.
        type: str
        choices: [ killed, once, reloaded, restarted, started, stopped ]
    downed:
        description:
            - Should a 'down' file exist or not, if it exists it disables auto startup.
              Defaults to no. Downed does not imply stopped.
        type: bool
        default: no
    enabled:
        description:
            - Whether the service is enabled or not, if disabled it also implies stopped.
              Take note that a service can be enabled and downed (no auto restart).
        type: bool
    service_dir:
        description:
            - Directory svscan watches for services
        type: str
        default: /service
    service_src:
        description:
            - Directory where services are defined, the source of symlinks to service_dir.
        type: str
        default: /etc/service
s4
- name: Start svc dnscache, if not running
  svc:
    name: dnscache
    state: started

- name: Stop svc dnscache, if running
  svc:
    name: dnscache
    state: stopped

- name: Kill svc dnscache, in all cases
  svc:
    name: dnscache
    state: killed

- name: Restart svc dnscache, in all cases
  svc:
    name: dnscache
    state: restarted

- name: Reload svc dnscache, in all cases
  svc:
    name: dnscache
    state: reloaded

- name: Using alternative svc directory location
  svc:
    name: dnscache
    state: reloaded
    service_dir: /var/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/svc.pyt_load_dist_subclassgs	tSvccB`s�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�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�ddg|_ddddddd	d
g|_||_|jd|_|jd|_|jd
|_d|_d|_	d|_
d|_d|_d|_
|jdd|j�|_|jdd|j�|_dj|j|jg�|_dj|j|jg�|_tjj|j�|_|jr[tjjd|j�|_	|j�n%tjjd|j�|_	d|_dS(Ns/commands/usr/local/bintstatetenabledtdownedtsvc_fulltsrc_fulltpidtdurationt
full_statetnametservice_dirtservice_srctsvctopt_dirstsvstatt/s%s/downtstopped(textra_pathstreport_varsR
R
R R!R"RRRRRRRtget_bin_pathtsvc_cmdt
svstat_cmdtjoinRRtostpathtlexistst
get_status(tselfR
((s>/usr/lib/python2.7/site-packages/ansible/modules/system/svc.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/svc.pytenable�s-cC`s�ytj|j�Wn9tk
rO}|jjd|jddt|��nX|j|jd|j	g�d|j	}tj
j|�r�|j|jd|g�ndS(NR/R4sError while unlinking: %ss-dxs%s/log(R.tunlinkRR7R
R8R	texecute_commandR+RR/R5(R2R9tsrc_log((s>/usr/lib/python2.7/site-packages/ansible/modules/system/svc.pytdisable�s*
cC`s,|j|j|jg�\}}}|dk	rI|rI||_|_n�||_tjd|�}|r|jd�|_	ntjd|�}|r�|jd�|_
ntjd|�r�d|_n+tjd|�r�d|_n
d|_dStjd	|�r|jd
7_n|jd7_dS(Ns
\(pid (\d+)\)is
(\d+) secondss up tstarts down tstopptunknowns want tingted(R<R,RRRRtretsearchtgroupRR(R2trctoutterrtm((s>/usr/lib/python2.7/site-packages/ansible/modules/system/svc.pyR1�s&$		cC`s|j|jd|jg�S(Ns-u(R<R+R(R2((s>/usr/lib/python2.7/site-packages/ansible/modules/system/svc.pyR?�scC`s
|j�S(N(tstop(R2((s>/usr/lib/python2.7/site-packages/ansible/modules/system/svc.pyR@�scC`s|j|jd|jg�S(Ns-d(R<R+R(R2((s>/usr/lib/python2.7/site-packages/ansible/modules/system/svc.pyRK�scC`s|j|jd|jg�S(Ns-o(R<R+R(R2((s>/usr/lib/python2.7/site-packages/ansible/modules/system/svc.pytonce�scC`s|j|jd|jg�S(Ns-1(R<R+R(R2((s>/usr/lib/python2.7/site-packages/ansible/modules/system/svc.pytreload�scC`s|j|jd|jg�S(Ns-t(R<R+R(R2((s>/usr/lib/python2.7/site-packages/ansible/modules/system/svc.pytrestart�scC`s|j|jd|jg�S(Ns-k(R<R+R(R2((s>/usr/lib/python2.7/site-packages/ansible/modules/system/svc.pytkill�scC`sty(|jjdj|��\}}}Wn<tk
rf}|jjddt|�dtj��nX|||fS(Nt R4sfailed to execute: %st	exception(R
trun_commandR-t	ExceptionR8R	t	tracebackt
format_exc(R2tcmdRGRHRIR9((s>/usr/lib/python2.7/site-packages/ansible/modules/system/svc.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/svc.pytreport�s

(t__name__t
__module__t__doc__R3R:R>R1R?R@RKRLRMRNROR<RZ(((s>/usr/lib/python2.7/site-packages/ansible/modules/system/svc.pyRzs													c	C`s�tdtdtdddt�dtddddd	d
ddd
g�dtdd�dtdd�dtdddd�dtdddd��dt�}tdddddddd�|_|jd}|jd}|jd}t|�}t}|j�}|dk	r�||j	kr�t}|j
s�y!|rE|j�n
|j�Wq�t
tfk
r�}|jddt|��q�Xq�n|dk	r�||jkr�t}|j
s�t||d ��q�n|dk	rp||jkrpt}|j
spd|j}y-|r&t|d �j�n
tj|�Wqmt
tfk
ri}|jdd!t|��qmXqpn|jd"|d#|j��dS($Nt
argument_specR ttypetstrtrequiredRtchoicestkilledRLtreloadedt	restartedtstartedR'RtboolRR!tdefaults/serviceR"s/etc/servicetsupports_check_modetLANGtCtLC_ALLtLC_MESSAGEStLC_CTYPER4s!Could not change service link: %si����s%s/downtas!Could not change downed file: %s tchangedR#(RtdicttTruetrun_command_environ_updateR
RtFalseRZRRt
check_modeR:R>R7tIOErrorR8R	RtgetattrRRtopentcloseR.R;t	exit_json(	R
RRRR#Rpt
orig_stateR9td_file((s>/usr/lib/python2.7/site-packages/ansible/modules/system/svc.pytmain�sP'	$


	
$		
$t__main__(t
__future__RRRR_t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLESR.RDRTtansible.module_utils.basicRtansible.module_utils._textR	RtobjectRR}R[(((s>/usr/lib/python2.7/site-packages/ansible/modules/system/svc.pyt<module>s 


0!	~	6

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