cronvar - Manage variables in crontabs

New in version 2.0.

Synopsis

  • Use this module to manage crontab variables. This module allows you to create, update, or delete cron variable definitions.

Requirements (on host that executes module)

  • cron

Options

parameter required default choices comments
backup
no
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
no
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
no
Used with state=present. If specified, the variable will be inserted after the variable specified.
insertbefore
no
Used with state=present. If specified, the variable will be inserted just before the variable specified.
name
yes
Name of the crontab variable.
state
no present
  • present
  • absent
Whether to ensure that the variable is present or absent.
user
no root
The specific user whose crontab should be modified.
value
no
The value to set this variable to. Required if state=present.

Examples

# Ensure a variable exists.
# Creates an entry like "[email protected]"
- cronvar:
    name: EMAIL
    value: [email protected]

# Make sure a variable is gone.  This will remove any variable named
# "LEGACY"
- cronvar:
    name: LEGACY
    state: absent

# Adds 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

Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.

© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.4/cronvar_module.html