�
�Udac @` s d d l m Z m Z m Z e Z i d d 6d g d 6d d 6Z d Z d Z d d
l Z d d
l
Z
d d
l Z d d
l Z d d
l
Z
d d
l Z d d
l Z d d l m Z d d l m Z d
e f d � � YZ d e f d � � YZ d � Z e d k re � n d
S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont previewt statust 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( t shlex_quotet CronVarErrorc B` s e Z RS( ( t __name__t
__module__( ( ( sB /usr/lib/python2.7/site-packages/ansible/modules/system/cronvar.pyR
p s t CronVarc B` s� e Z d Z d d d � Z d � Z d � Z d d � Z d � Z d � Z d � Z
d � Z d � Z d
� Z
e d � Z d � Z d
� Z d � Z RS( 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
c C` s� | | _ | | _ d | _ d j d � t d � D� � | _ | j j d d t �| _ | r� d | _
t j j
| � r� | | _
q� t j j d | � | _
n d | _
| j � d S( Nt c s` s- | ]# } t | � d k r t | � Vq d S( t =t 't "N( R R R ( t chr( t .0t x( ( sB /usr/lib/python2.7/site-packages/ansible/modules/system/cronvar.pys <genexpr>� s i� t crontabt requireds /etc/cron.d( t modulet usert Nonet linest joint ranget wordcharst get_bin_patht Truet cron_cmdt cron_filet ost patht isabst read( t selfR R R! ( ( sB /usr/lib/python2.7/site-packages/ansible/modules/system/cronvar.pyt __init__| s " c C` s_ g | _ | j r� y5 t | j d � } | j � j � | _ | j � Wq[t k
r[ d St k
r� t d t j
� d � � q[Xn� | j j | j
� d t �\ } } } | d k r� | d k r� t d � � n | j � } d } xp | D]h } | d k s:t j d | � rMt j d | � rMt j d
| � rM| j j | � n | d 7} q� Wd S( Nt rs Unexpected error:i t use_unsafe_shelli s Unable to read crontabi s8 # DO NOT EDIT THIS FILE - edit the master and reinstall.s # \(/tmp/.*installed on.*\)s # \(.*version.*\)( R R! t openR% t
splitlinest closet IOErrort ExceptionR
t syst exc_infoR t run_commandt _read_user_executeR t ret matcht append( R&