Anons79 Mini Shell

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

�
�Udac@`sddlmZmZmZeZidd6dgd6dd6ZdZd	Zdd
l	Z	dd
l
Z
dd
lZdd
lZdd
l
Z
dd
lZdd
lZddlmZddlmZd
efd��YZdefd��YZd�Zedkre�nd
S(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys`
---
module: cronvar
short_description: Manage variables in crontabs
description:
  - Use this module to manage crontab variables.
  - This module allows you to create, update, or delete cron variable definitions.
version_added: "2.0"
options:
  name:
    description:
      - Name of the crontab variable.
    type: str
    required: yes
  value:
    description:
      - The value to set this variable to.
      - Required if C(state=present).
    type: str
  insertafter:
    description:
      - If specified, the variable will be inserted after the variable specified.
      - Used with C(state=present).
    type: str
  insertbefore:
    description:
      - Used with C(state=present). If specified, the variable will be inserted
        just before the variable specified.
    type: str
  state:
    description:
      - Whether to ensure that the variable is present or absent.
    type: str
    choices: [ absent, present ]
    default: present
  user:
    description:
      - The specific user whose crontab should be modified.
      - This parameter defaults to C(root) when unset.
    type: str
  cron_file:
    description:
      - If specified, uses this file instead of an individual user's crontab.
      - Without a leading C(/), this is assumed to be in I(/etc/cron.d).
      - With a leading C(/), this is taken as absolute.
    type: str
  backup:
    description:
      - If set, create a backup of the crontab before it is modified.
        The location of the backup is returned in the C(backup) variable by this module.
    type: bool
    default: no
requirements:
  - cron
author:
- Doug Luce (@dougluce)
s�
- name: Ensure entry like "[email protected]" exists
  cronvar:
    name: EMAIL
    value: [email protected]

- name: Ensure a variable does not exist. This may remove any variable named "LEGACY"
  cronvar:
    name: LEGACY
    state: absent

- name: Add a variable to a file under /etc/cron.d
  cronvar:
    name: LOGFILE
    value: /var/log/yum-autoupdate.log
    user: root
    cron_file: ansible_yum-autoupdate
N(t
AnsibleModule(tshlex_quotetCronVarErrorcB`seZRS((t__name__t
__module__(((sB/usr/lib/python2.7/site-packages/ansible/modules/system/cronvar.pyR
pstCronVarcB`s�eZdZddd�Zd�Zd�Zdd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
ed�Zd�Zd
�Zd�ZRS(s�
        CronVar object to write variables to crontabs.

        user      - the user of the crontab (defaults to root)
        cron_file - a cron file under /etc/cron.d
    cC`s�||_||_d|_djd�td�D��|_|jjddt�|_	|r�d|_
tjj
|�r�||_
q�tjjd|�|_
n	d|_
|j�dS(Ntcs`s-|]#}t|�dkrt|�VqdS(t=t't"N(RRR(tchr(t.0tx((sB/usr/lib/python2.7/site-packages/ansible/modules/system/cronvar.pys	<genexpr>�si�tcrontabtrequireds/etc/cron.d(tmoduletusertNonetlinestjointranget	wordcharstget_bin_pathtTruetcron_cmdt	cron_filetostpathtisabstread(tselfRRR!((sB/usr/lib/python2.7/site-packages/ansible/modules/system/cronvar.pyt__init__|s			"		cC`s_g|_|jr�y5t|jd�}|j�j�|_|j�Wq[tk
r[dStk
r�tdt	j
�d��q[Xn�|jj|j
�dt�\}}}|dkr�|dkr�td��n|j�}d}xp|D]h}|dks:tjd|�rMtjd	|�rMtjd
|�rM|jj|�n|d7}q�WdS(NtrsUnexpected error:ituse_unsafe_shellisUnable to read crontabis8# DO NOT EDIT THIS FILE - edit the master and reinstall.s# \(/tmp/.*installed on.*\)s# \(.*version.*\)(RR!topenR%t
splitlinestclosetIOErrort	ExceptionR
tsystexc_infoRtrun_commandt_read_user_executeRtretmatchtappend(R&tftrctoutterrRtcounttl((sB/usr/lib/python2.7/site-packages/ansible/modules/system/cronvar.pyR%�s(		

 '
&cC`s|jjd|�dS(Ns
ansible: "%s"(Rtdebug(R&tmessage((sB/usr/lib/python2.7/site-packages/ansible/modules/system/cronvar.pytlog_message�scC`s�|rt|d�}nH|jr6t|jd�}n*tjdd�\}}tj|d�}|j|j��|j�|r�dS|js�|j	j
|j|�dt�\}}}tj
|�|dkr�|j	jd|�q�ndS(sI
        Write the crontab to the system. Saves all information.
        twtprefixRNR)itmsg(R*R!ttempfiletmkstempR"tfdopentwritetrenderR,RR1t_write_executeRtunlinkt	fail_json(R&tbackup_filetfilehtfiledR#R7R8R9((sB/usr/lib/python2.7/site-packages/ansible/modules/system/cronvar.pyRE�s	
	*
cC`sZytj|j�tSWn;tk
r,tStk
rUtdtj	�d��nXdS(NsUnexpected error:i(
R"RHR!RtOSErrortFalseR.R
R/R0(R&((sB/usr/lib/python2.7/site-packages/ansible/modules/system/cronvar.pytremove_variable_file�s

cC`shtj|�}|j|_|j�}|j�dk}dj|�}|rX||fStd��dS(NRRsNot a variable.(tshlexRt	get_tokenRR
(R&tlinetlexertvarnamet
is_env_vartvalue((sB/usr/lib/python2.7/site-packages/ansible/modules/system/cronvar.pyt
parse_for_var�s
cC`sUxN|jD]C}y)|j|�\}}||kr8|SWq
tk
rLq
Xq
WdS(N(RRWR
R(R&tnameR;RTRV((sB/usr/lib/python2.7/site-packages/ansible/modules/system/cronvar.pyt
find_variable�s
cC`sXg}xK|jD]@}y&|j|�\}}|j|�Wqtk
rOqXqW|S(N(RRWR5R
(R&t	var_namesR;tvar_namet_((sB/usr/lib/python2.7/site-packages/ansible/modules/system/cronvar.pyt
get_var_names�s
c	C`s|dkr8|dkr8|jjdd||f�n�g}x�|jD]�}y�|j|�\}}||kr�|jd||f�|j|�n9||kr�|j|�|jd||f�nt�WqHtk
r�|j|�qHXqHW||_dS(Nis%s=%s(RRtinsertRWR5R
(	R&RXRVtinsertbeforetinsertaftertnewlinesR;RTR\((sB/usr/lib/python2.7/site-packages/ansible/modules/system/cronvar.pytadd_variable�s  


cC`s|j|ddt�dS(Ntremove(tupdate_variableRR(R&RX((sB/usr/lib/python2.7/site-packages/ansible/modules/system/cronvar.pytremove_variablescC`s�g}x�|jD]u}yN|j|�\}}||krCt�n|sc|jd||f�nWqtk
r�|j|�qXqW||_dS(Ns%s=%s(RRWR
R5(R&RXRVRcRaR;RTR\((sB/usr/lib/python2.7/site-packages/ansible/modules/system/cronvar.pyRds	
cC`s9dj|j�}|r5|ddkr5|d7}n|S(s)
        Render a proper crontab
        s
i����s
(s
s
(RR(R&tresult((sB/usr/lib/python2.7/site-packages/ansible/modules/system/cronvar.pyRFs
cC`s�d}|jr�tj�dkrAdt|j�t|j�fStj�dkrsdt|j�t|j�fStj�dkr�d|jdt|j�fStjtj��d	|jkr�d
t|j�}q�nd|j|dfS(s@
        Returns the command line for reading a crontab
        RtSunOSssu %s -c '%s -l'tAIXs%s -l %ssHP-UXs%s %s %ss-lis-u %s(	RtplatformtsystemR	R tpwdtgetpwuidR"tgetuid(R&R((sB/usr/lib/python2.7/site-packages/ansible/modules/system/cronvar.pyR2"s	  "cC`s�d}|jr�tj�d	krYdt|j�t|�t|j�|jt|�fStjtj��d|jkr�dt|j�}q�nd|j|t|�fS(
s?
        Return the command line for writing a crontab
        RRgsHP-UXRhs chown %s %s ; su '%s' -c '%s %s'is-u %ss%s %s %s(sSunOSsHP-UXsAIX(	RRiRjR	R RkRlR"Rm(R&R#R((sB/usr/lib/python2.7/site-packages/ansible/modules/system/cronvar.pyRG3s	5"N(RRt__doc__RR'R%R>RERORWRYR]RbReRNRdRFR2RG(((sB/usr/lib/python2.7/site-packages/ansible/modules/system/cronvar.pyR
ts			
	
	
	
					cC`s]tdtdtdddt�dtdd�dtdd�dtdd�d	tdd�d
tdd�dtdddd
ddd
g�dtdddt��dd
d	ggdt�}|jd}|jd}|jd}|jd}|jd	}|jd
}|jd}|jd}|d
k}	t}
t�}tjtdd��t|||�}|j	d|�|dkr�|	r�|jdd�n|dkr�|	r�|jdd�n|dkr�|	r�|jdd�n|rtj
dd�\}
}|j|�n|jrY|rY|	rY|j�}
|jd|
d|d|�n|j|�}|	r�|dkr�|j||||�t}
q�||kr�|j||�t}
q�n"|dk	r�|j|�t}
ni|j�d6|
d6}|
r|j�n|r9|
r)||d<q9tj|�n|rL||d<n|j|�dS( Nt
argument_specRXttypetstrRRVRR!R`R_tstatetdefaulttpresenttchoicestabsenttbackuptbooltmutually_exclusivetsupports_check_modet022is!cronvar instantiated - name: "%s"RAs5You must specify 'name' to insert a new cron variables6You must specify 'value' to insert a new cron variables1You must specify 'name' to remove a cron variableR@tcronvartchangedtvarsRJ(RtdictRRNtparamsR"tumasktintR
R<RRIRBRCRER!tremove_job_filet	exit_jsonRYRbRdReR]RH(RRXRVRR!R`R_RrRwtensure_presentR}tres_argsR|R\RJt	old_value((sB/usr/lib/python2.7/site-packages/ansible/modules/system/cronvar.pytmainCsz!	







		
	




t__main__(t
__future__RRRRpt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLESR"RiRkR3RPR/RBtansible.module_utils.basicRtansible.module_utils.six.movesR	R.R
tobjectR
R�R(((sB/usr/lib/python2.7/site-packages/ansible/modules/system/cronvar.pyt<module>s(


:�	h

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