community.general.cronvar module – Manage variables in crontabs
Note
This module is part of the community.general collection (version 9.4.0).
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.general.cronvar
.
Synopsis
Use this module to manage crontab variables.
This module allows you to create, update, or delete cron variable definitions.
Requirements
The below requirements are needed on the host that executes this module.
cron
Parameters
Parameter |
Comments |
---|---|
If set, create a backup of the crontab before it is modified. The location of the backup is returned in the Choices:
|
|
If specified, uses this file instead of an individual user’s crontab. Without a leading With a leading |
|
If specified, the variable will be inserted after the variable specified. Used with |
|
Used with |
|
Name of the crontab variable. |
|
Whether to ensure that the variable is present or absent. Choices:
|
|
The specific user whose crontab should be modified. This parameter defaults to |
|
The value to set this variable to. Required if |
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: none |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
Examples
- name: Ensure entry like "EMAIL=doug@ansibmod.con.com" exists
community.general.cronvar:
name: EMAIL
value: doug@ansibmod.con.com
- name: Ensure a variable does not exist. This may remove any variable named "LEGACY"
community.general.cronvar:
name: LEGACY
state: absent
- name: Add a variable to a file under /etc/cron.d
community.general.cronvar:
name: LOGFILE
value: /var/log/yum-autoupdate.log
user: root
cron_file: ansible_yum-autoupdate