- Docs »
- cronvar - Manage variables in crontabs
-
You are reading an unmaintained version of the Ansible documentation. Unmaintained Ansible versions can contain unfixed security vulnerabilities (CVE). Please upgrade to a maintained version. See the latest Ansible documentation.
cronvar - Manage variables in crontabs
- Use this module to manage crontab variables. This module allows you to create, update, or delete cron variable definitions.
The below requirements are needed on the host that executes this module.
Parameter |
Choices/Defaults |
Comments |
backup
bool |
|
If set, create a backup of the crontab before it is modified. The location of the backup is returned in the backup variable by this module.
|
cron_file
|
|
If specified, uses this file instead of an individual user's crontab. Without a leading /, this is assumed to be in /etc/cron.d. With a leading /, this is taken as absolute.
|
insertafter
|
|
If specified, the variable will be inserted after the variable specified.
Used with state=present .
|
insertbefore
|
|
Used with state=present . If specified, the variable will be inserted just before the variable specified.
|
name
required |
|
Name of the crontab variable.
|
state
|
Choices:
- absent
present ←
|
Whether to ensure that the variable is present or absent.
|
user
|
Default:
"root"
|
The specific user whose crontab should be modified.
|
value
|
|
The value to set this variable to.
Required if state=present .
|
- name: Ensure entry like "EMAIL=doug@ansibmod.con.com" exists
cronvar:
name: EMAIL
value: doug@ansibmod.con.com
- 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
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
This module is flagged as community which means that it is maintained by the Ansible Community. See Module Maintenance & Support for more info.
For a list of other modules that are also maintained by the Ansible Community, see here.
Hint
If you notice any issues in this documentation you can edit this document to improve it.