community.general.cronvar (8.5.0) — module

Manage variables in crontabs

Authors: Doug Luce (@dougluce)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

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
  community.general.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"
  community.general.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
  community.general.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 V(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 O(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 V(/), this is assumed to be in C(/etc/cron.d).
    - With a leading V(/), this is taken as absolute.
    type: str

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

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