|
|
|
@ -33,8 +33,8 @@ options:
|
|
|
|
|
name:
|
|
|
|
|
description:
|
|
|
|
|
- Description of a crontab entry or, if env is set, the name of environment variable.
|
|
|
|
|
- Required if C(state=absent).
|
|
|
|
|
- Note that if name is not set and C(state=present), then a
|
|
|
|
|
- Required if I(state=absent).
|
|
|
|
|
- Note that if name is not set and I(state=present), then a
|
|
|
|
|
new crontab entry will always be created, regardless of existing ones.
|
|
|
|
|
- This parameter will always be required in future releases.
|
|
|
|
|
type: str
|
|
|
|
@ -47,7 +47,7 @@ options:
|
|
|
|
|
description:
|
|
|
|
|
- The command to execute or, if env is set, the value of environment variable.
|
|
|
|
|
- The command should not contain line breaks.
|
|
|
|
|
- Required if C(state=present).
|
|
|
|
|
- Required if I(state=present).
|
|
|
|
|
type: str
|
|
|
|
|
aliases: [ value ]
|
|
|
|
|
state:
|
|
|
|
@ -60,10 +60,10 @@ options:
|
|
|
|
|
description:
|
|
|
|
|
- If specified, uses this file instead of an individual user's crontab.
|
|
|
|
|
- If this is a relative path, it is interpreted with respect to I(/etc/cron.d).
|
|
|
|
|
- If it is absolute, it will typically be I(/etc/crontab).
|
|
|
|
|
- If it is absolute, it will typically be C(/etc/crontab).
|
|
|
|
|
- Many linux distros expect (and some require) the filename portion to consist solely
|
|
|
|
|
of upper- and lower-case letters, digits, underscores, and hyphens.
|
|
|
|
|
- To use the C(cron_file) parameter you must specify the C(user) as well.
|
|
|
|
|
- To use the I(cron_file) parameter you must specify the I(user) as well.
|
|
|
|
|
type: str
|
|
|
|
|
backup:
|
|
|
|
|
description:
|
|
|
|
@ -73,34 +73,34 @@ options:
|
|
|
|
|
default: no
|
|
|
|
|
minute:
|
|
|
|
|
description:
|
|
|
|
|
- Minute when the job should run ( 0-59, *, */2, etc )
|
|
|
|
|
- Minute when the job should run (C(0-59), C(*), C(*/2), and so on).
|
|
|
|
|
type: str
|
|
|
|
|
default: "*"
|
|
|
|
|
hour:
|
|
|
|
|
description:
|
|
|
|
|
- Hour when the job should run ( 0-23, *, */2, etc )
|
|
|
|
|
- Hour when the job should run (C(0-23), C(*), C(*/2), and so on).
|
|
|
|
|
type: str
|
|
|
|
|
default: "*"
|
|
|
|
|
day:
|
|
|
|
|
description:
|
|
|
|
|
- Day of the month the job should run ( 1-31, *, */2, etc )
|
|
|
|
|
- Day of the month the job should run (C(1-31), C(*), C(*/2), and so on).
|
|
|
|
|
type: str
|
|
|
|
|
default: "*"
|
|
|
|
|
aliases: [ dom ]
|
|
|
|
|
month:
|
|
|
|
|
description:
|
|
|
|
|
- Month of the year the job should run ( 1-12, *, */2, etc )
|
|
|
|
|
- Month of the year the job should run (C(1-12), C(*), C(*/2), and so on).
|
|
|
|
|
type: str
|
|
|
|
|
default: "*"
|
|
|
|
|
weekday:
|
|
|
|
|
description:
|
|
|
|
|
- Day of the week that the job should run ( 0-6 for Sunday-Saturday, *, etc )
|
|
|
|
|
- Day of the week that the job should run (C(0-6) for Sunday-Saturday, C(*), and so on).
|
|
|
|
|
type: str
|
|
|
|
|
default: "*"
|
|
|
|
|
aliases: [ dow ]
|
|
|
|
|
reboot:
|
|
|
|
|
description:
|
|
|
|
|
- If the job should be run at reboot. This option is deprecated. Users should use special_time.
|
|
|
|
|
- If the job should be run at reboot. This option is deprecated. Users should use I(special_time).
|
|
|
|
|
version_added: "1.0"
|
|
|
|
|
type: bool
|
|
|
|
|
default: no
|
|
|
|
@ -113,7 +113,7 @@ options:
|
|
|
|
|
disabled:
|
|
|
|
|
description:
|
|
|
|
|
- If the job should be disabled (commented out) in the crontab.
|
|
|
|
|
- Only has effect if C(state=present).
|
|
|
|
|
- Only has effect if I(state=present).
|
|
|
|
|
type: bool
|
|
|
|
|
default: no
|
|
|
|
|
version_added: "2.0"
|
|
|
|
@ -121,66 +121,68 @@ options:
|
|
|
|
|
description:
|
|
|
|
|
- If set, manages a crontab's environment variable.
|
|
|
|
|
- New variables are added on top of crontab.
|
|
|
|
|
- C(name) and C(value) parameters are the name and the value of environment variable.
|
|
|
|
|
- I(name) and I(value) parameters are the name and the value of environment variable.
|
|
|
|
|
type: bool
|
|
|
|
|
default: false
|
|
|
|
|
version_added: "2.1"
|
|
|
|
|
insertafter:
|
|
|
|
|
description:
|
|
|
|
|
- Used with C(state=present) and C(env).
|
|
|
|
|
- Used with I(state=present) and I(env).
|
|
|
|
|
- If specified, the environment variable will be inserted after the declaration of specified environment variable.
|
|
|
|
|
type: str
|
|
|
|
|
version_added: "2.1"
|
|
|
|
|
insertbefore:
|
|
|
|
|
description:
|
|
|
|
|
- Used with C(state=present) and C(env).
|
|
|
|
|
- Used with I(state=present) and I(env).
|
|
|
|
|
- If specified, the environment variable will be inserted before the declaration of specified environment variable.
|
|
|
|
|
type: str
|
|
|
|
|
version_added: "2.1"
|
|
|
|
|
requirements:
|
|
|
|
|
- cron (or cronie on CentOS)
|
|
|
|
|
author:
|
|
|
|
|
- Dane Summers (@dsummersl)
|
|
|
|
|
- Mike Grozak (@rhaido)
|
|
|
|
|
- Patrick Callahan (@dirtyharrycallahan)
|
|
|
|
|
- Evan Kaufman (@EvanK)
|
|
|
|
|
- Luca Berruti (@lberruti)
|
|
|
|
|
- Dane Summers (@dsummersl)
|
|
|
|
|
- Mike Grozak (@rhaido)
|
|
|
|
|
- Patrick Callahan (@dirtyharrycallahan)
|
|
|
|
|
- Evan Kaufman (@EvanK)
|
|
|
|
|
- Luca Berruti (@lberruti)
|
|
|
|
|
notes:
|
|
|
|
|
- Supports C(check_mode).
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
EXAMPLES = r'''
|
|
|
|
|
- name: Ensure a job that runs at 2 and 5 exists. Creates an entry like "0 5,2 * * ls -alh > /dev/null"
|
|
|
|
|
cron:
|
|
|
|
|
ansible.builtin.cron:
|
|
|
|
|
name: "check dirs"
|
|
|
|
|
minute: "0"
|
|
|
|
|
hour: "5,2"
|
|
|
|
|
job: "ls -alh > /dev/null"
|
|
|
|
|
|
|
|
|
|
- name: 'Ensure an old job is no longer present. Removes any job that is prefixed by "#Ansible: an old job" from the crontab'
|
|
|
|
|
cron:
|
|
|
|
|
ansible.builtin.cron:
|
|
|
|
|
name: "an old job"
|
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
|
|
- name: Creates an entry like "@reboot /some/job.sh"
|
|
|
|
|
cron:
|
|
|
|
|
ansible.builtin.cron:
|
|
|
|
|
name: "a job for reboot"
|
|
|
|
|
special_time: reboot
|
|
|
|
|
job: "/some/job.sh"
|
|
|
|
|
|
|
|
|
|
- name: Creates an entry like "PATH=/opt/bin" on top of crontab
|
|
|
|
|
cron:
|
|
|
|
|
ansible.builtin.cron:
|
|
|
|
|
name: PATH
|
|
|
|
|
env: yes
|
|
|
|
|
job: /opt/bin
|
|
|
|
|
|
|
|
|
|
- name: Creates an entry like "APP_HOME=/srv/app" and insert it after PATH declaration
|
|
|
|
|
cron:
|
|
|
|
|
ansible.builtin.cron:
|
|
|
|
|
name: APP_HOME
|
|
|
|
|
env: yes
|
|
|
|
|
job: /srv/app
|
|
|
|
|
insertafter: PATH
|
|
|
|
|
|
|
|
|
|
- name: Creates a cron file under /etc/cron.d
|
|
|
|
|
cron:
|
|
|
|
|
ansible.builtin.cron:
|
|
|
|
|
name: yum autoupdate
|
|
|
|
|
weekday: "2"
|
|
|
|
|
minute: "0"
|
|
|
|
@ -190,18 +192,20 @@ EXAMPLES = r'''
|
|
|
|
|
cron_file: ansible_yum-autoupdate
|
|
|
|
|
|
|
|
|
|
- name: Removes a cron file from under /etc/cron.d
|
|
|
|
|
cron:
|
|
|
|
|
ansible.builtin.cron:
|
|
|
|
|
name: "yum autoupdate"
|
|
|
|
|
cron_file: ansible_yum-autoupdate
|
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
|
|
- name: Removes "APP_HOME" environment variable from crontab
|
|
|
|
|
cron:
|
|
|
|
|
ansible.builtin.cron:
|
|
|
|
|
name: APP_HOME
|
|
|
|
|
env: yes
|
|
|
|
|
state: absent
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
RETURN = r'''#'''
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
import platform
|
|
|
|
|
import pwd
|
|
|
|
|