ansible.builtin.cronvar (v2.9.27) — module

Manage variables in crontabs

| "added in version" 2.0 of ansible.builtin"

Authors: Doug Luce (@dougluce)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.27

Description

Use this module to manage crontab variables.

This module allows you to create, update, or delete cron variable definitions.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Ensure entry like "EMAIL=doug@ansibmod.con.com" exists
  cronvar:
    name: EMAIL
    value: doug@ansibmod.con.com
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Ensure a variable does not exist. This may remove any variable named "LEGACY"
  cronvar:
    name: LEGACY
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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

Inputs

    
name:
    description:
    - Name of the crontab variable.
    required: true
    type: str

user:
    description:
    - The specific user whose crontab should be modified.
    - This parameter defaults to C(root) when unset.
    type: str

state:
    choices:
    - absent
    - present
    default: present
    description:
    - Whether to ensure that the variable is present or absent.
    type: str

value:
    description:
    - The value to set this variable to.
    - Required if C(state=present).
    type: str

backup:
    default: false
    description:
    - If set, create a backup of the crontab before it is modified. The location of the
      backup is returned in the C(backup) variable by this module.
    type: bool

cron_file:
    description:
    - If specified, uses this file instead of an individual user's crontab.
    - Without a leading C(/), this is assumed to be in I(/etc/cron.d).
    - With a leading C(/), this is taken as absolute.
    type: str

insertafter:
    description:
    - If specified, the variable will be inserted after the variable specified.
    - Used with C(state=present).
    type: str

insertbefore:
    description:
    - Used with C(state=present). If specified, the variable will be inserted just before
      the variable specified.
    type: str