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