Anons79 Mini Shell

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

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlmZd
e
fd��YZdefd��YZdefd��YZd�Zedkr�e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys3
---
module: service_facts
short_description: Return service state information as fact data
description:
     - Return service state information as fact data for various service management utilities
version_added: "2.5"
requirements: ["Any of the following supported init systems: systemd, sysv, upstart"]

notes:
  - When accessing the C(ansible_facts.services) facts collected by this module,
    it is recommended to not use "dot notation" because services can have a C(-)
    character in their name which would result in invalid "dot notation", such as
    C(ansible_facts.services.zuul-gateway). It is instead recommended to
    using the string value of the service name as the key in order to obtain
    the fact data value like C(ansible_facts.services['zuul-gateway'])

author:
  - Adam Miller (@maxamillion)
s\
- name: Populate service facts
  service_facts:

- debug:
    var: ansible_facts.services

s�
ansible_facts:
  description: Facts to add to ansible_facts about the services on the system
  returned: always
  type: complex
  contains:
    services:
      description: States of the services with service name as key.
      returned: always
      type: complex
      contains:
        source:
          description: Init system of the service. One of C(systemd), C(sysv), C(upstart).
          returned: always
          type: str
          sample: sysv
        state:
          description: State of the service. Either C(running), C(stopped), or C(unknown).
          returned: always
          type: str
          sample: running
        status:
          description: State of the service. Either C(enabled), C(disabled), or C(unknown).
          returned: systemd systems or RedHat/SUSE flavored sysvinit/upstart
          type: str
          sample: enabled
        name:
          description: Name of the service.
          returned: always
          type: str
          sample: arp-ethers.service
N(t
AnsibleModuletBaseServicecB`seZd�ZRS(cC`s||_t|_dS(N(tmoduletFalsetincomplete_warning(tselfR
((sH/usr/lib/python2.7/site-packages/ansible/modules/system/service_facts.pyt__init__Vs	(t__name__t
__module__R(((sH/usr/lib/python2.7/site-packages/ansible/modules/system/service_facts.pyR	TstServiceScanServicecB`seZd�ZRS(cC`s~i}|jjd�}|dkr(dS|jjd�}|jjd�}|dk	r|dkr|jjd|dt�\}}}x�|jd�D]{}|j�}	t|	�dkr�q�ndj|	d	�}
|	d
dkr�d}nd
}i|
d6|d6dd6||
<q�Wn|dk	r+|dkr+tj	d�}|jjd|�\}}}|j
dd�}
x|
jd�D]�}|j|�}|s�q�n|jd�}
|jd�}|jd�}|jd�r�|jd�}nd}i|
d6|d6|d6dd6}|||
<q�WnO|dk	rztj	d�}|jjd|dt�\}}}t
}x/|jd�D]}|j|�r�t}q�q�W|sUtj	d�}t
}x/|jd�D]}|j|�r�t}q�q�W|r|jjd|dt�\}}}qUd|krU|jjd|dt�\}}}qUnx"|jd�D]}|j|�}|re|jd�}
d
}d}|jd �d!kr�d"}n|jjd#||
fdt�\}}}|}|d)kr�d}nEd%|ks/d&|j�ks/d'|j�kr>t|_qend
}i|
d6|d6|d(6dd6}|||
<qeqeWn|S(*Ntservicetinitctlt	chkconfigs.%s --status-all 2>&1 | grep -E "\[ (\+|\-) \]"tuse_unsafe_shells
it iit+trunningtstoppedtnametstatetsysvtsourcesR^\s?(?P<name>.*)\s(?P<goal>\w+)\/(?P<state>\w+)(\,\sprocess\s(?P<pid>[0-9]+))?\s*$s%s lists
ttgoaltpidtupstarts�(?P<service>.*?)\s+[0-9]:(?P<rl0>on|off)\s+[0-9]:(?P<rl1>on|off)\s+[0-9]:(?P<rl2>on|off)\s+[0-9]:(?P<rl3>on|off)\s+[0-9]:(?P<rl4>on|off)\s+[0-9]:(?P<rl5>on|off)\s+[0-9]:(?P<rl6>on|off)s%ss"(?P<service>.*?)\s+(?P<rl0>on|off)s%s -l --allservicess--lists	%s --listtdisabledtrl3tontenableds%s %s statusitroott
permissionsnot in sudoersR(i(R
tget_bin_pathtNonetrun_commandtTruetsplittlentjointretcompiletreplacetmatchtgroupRtlowerR(R
tservicestservice_pathtinitctl_pathtchkconfig_pathtrctstdouttstderrtlinet	line_datatservice_namet
service_statetptreal_stdouttmtservice_goalR tpayloadt	match_anytp_simpletservice_statustservice_data((sH/usr/lib/python2.7/site-packages/ansible/modules/system/service_facts.pytgather_services]s�%	&"	%

(+	+	0	"(RRRI(((sH/usr/lib/python2.7/site-packages/ansible/modules/system/service_facts.pyR[stSystemctlScanServicecB`seZd�Zd�ZRS(cC`sMytdd�}Wntk
r'tSXx|D]}d|kr/tSq/WtS(Ns/proc/1/commtrtsystemd(topentIOErrorRR+(R
tfR<((sH/usr/lib/python2.7/site-packages/ansible/modules/system/service_facts.pytsystemd_enabled�s

cC`sxi}|j�sdS|jjddddg�}|dkrDdS|jjd|dt�\}}}x�g|jd�D]$}d|kr|d	|kr||^q|D]v}|j�d
}d|kr�d}	n%d|kr�|j�d
}nd}	i|d6|	d6dd6dd6||<q�W|jjd|dt�\}}}x.g|jd�D]$}d|krVd	|krV|^qVD]�}y|j�d \}}
Wn-tk
r�|jjddj	|��nX||krb|jjd||fdt�\}}}d}|r9|dkr9|j
dd�j�}ni|d6|d6|
d6dd6||<q~|
||d<q~W|S(Nt	systemctltopt_dirss/usr/bins/usr/local/bins-%s list-units --no-pager --type service --allRs
s.services	not-foundiRtfailediRRRtunknownRRLRs2%s list-unit-files --no-pager --type service --allitmsgs=Malformed output discovered from systemd list-unit-files: {0}s!%s show %s --property=ActiveStateRsActiveState=(RPR)R
R(R*R+R,t
IndexErrort	fail_jsontformatR1trstrip(R
R5tsystemctl_pathR9R:R;tsvc_lineR<R>t	state_valt
status_valR((sH/usr/lib/python2.7/site-packages/ansible/modules/system/service_facts.pyRI�s:%A	*%A
 +)(RRRPRI(((sH/usr/lib/python2.7/site-packages/ansible/modules/system/service_facts.pyRJ�s	cC`stdt�dt�}tdddd�|_ttf}i}t}xT|D]L}||�}|j�}|dk	rO|j	|�|j
r�t}q�qOqOWt|�dkr�tdtdd	�}n+td
td|��}|r�d|d<n|j|�dS(
Nt
argument_spectsupports_check_modetLANGtCtLC_ALLitskippedRUsNFailed to find any services. Sometimes this is due to insufficient privileges.t
ansible_factsR5sbWARNING: Could not find status for all services. Sometimes this is due to insufficient privileges.(
RtdictR+trun_command_environ_updateRRJRRIR)tupdateRR-t	exit_json(R
tservice_modulestall_servicesRt
svc_moduletsvcmodtsvctresults((sH/usr/lib/python2.7/site-packages/ansible/modules/system/service_facts.pytmain�s$

	
t__main__(t
__future__RRRttypet
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR/tansible.module_utils.basicRtobjectR	RRJRoR(((sH/usr/lib/python2.7/site-packages/ansible/modules/system/service_facts.pyt<module>s


	![1	

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