cronjob-exists

Description

Ensures a cron job exists.

This mostly just forwards arguments to the 'cron' Ansible module, please check it's documentation for more details.

Resources

Variables

Name Type Default Description

job

string --

The command to execute. Required

name

string --

Description of a crontab entry. Required

day

string --

Day of the month the job should run ( 1-31, *, */2, etc ).

hour

string --

Hour when the job should run ( 0-23, *, */2, etc ).

minute

string --

Minute when the job should run ( 0-59, *, */2, etc ).

month

string --

Month of the year the job should run ( 1-12, *, */2, etc ).

special_time

string --

Special time specification nickname.

user

string root

The specific user whose crontab should be modified. When unset, this parameter defaults to using root.

weekday

string --

Day of the week that the job should run ( 0-6 for Sunday-Saturday, *, etc ).

Code

doc:
  short_help: Ensures a cron job exists.
  help: |
    Ensures a cron job exists.

    This mostly just forwards arguments to the 'cron' Ansible module, please check it's documentation for more details.
  references:
    "'cron' Ansible module": https://docs.ansible.com/ansible/latest/modules/cron_module.html

args:
  name:
    doc:
      short_help: Description of a crontab entry.
    type: string
    required: true
  job:
    doc:
      short_help: The command to execute.
    type: string
    required: true
  month:
    doc:
      short_help: Month of the year the job should run ( 1-12, *, */2, etc ).
    type: string
    required: false
  day:
    doc:
      short_help: Day of the month the job should run ( 1-31, *, */2, etc ).
    type: string
    required: false
  hour:
    doc:
      short_help: Hour when the job should run ( 0-23, *, */2, etc ).
    type: string
    required: false
  minute:
    doc:
      short_help: Minute when the job should run ( 0-59, *, */2, etc ).
    type: string
    required: false
  weekday:
    doc:
      short_help: Day of the week that the job should run ( 0-6 for Sunday-Saturday,
        *, etc ).
    type: string
    required: false
  special_time:
    doc:
      short_help: Special time specification nickname.
    type: string
    required: false
    allowed:
    - annually
    - daily
    - hourly
    - monthly
    - reboot
    - weekly
    - yearly
  user:
    doc:
      short_help: The specific user whose crontab should be modified. When unset,
        this parameter defaults to using root.
    type: string
    required: false
    default: root

frecklets:
- frecklet:
    name: cron
    type: ansible-module
    properties:
      idempotent: true
      internet: false
      elevated: true
    desc:
      short: "adding cronjob for '{{:: user ::}}': {{:: job ::}}"
  task:
    become: true
  vars:
    name: '{{:: name ::}}'
    job: '{{:: job ::}}'
    minute: '{{:: minute ::}}'
    hour: '{{:: hour ::}}'
    day: '{{:: day ::}}'
    month: '{{:: month ::}}'
    weekday: '{{:: weekday ::}}'
    special_time: '{{:: special_time ::}}'
    state: present
    user: '{{:: user ::}}'
frecklecute cronjob-exists --help

Usage: frecklecute cronjob-exists [OPTIONS]

  Ensures a cron job exists.

  This mostly just forwards arguments to the 'cron' Ansible module, please
  check it's documentation for more details.

Options:
  --job JOB                    The command to execute.  [required]
  --name NAME                  Description of a crontab entry.  [required]
  --day DAY                    Day of the month the job should run ( 1-31, *,
                               */2, etc ).
  --hour HOUR                  Hour when the job should run ( 0-23, *, */2,
                               etc ).
  --minute MINUTE              Minute when the job should run ( 0-59, *, */2,
                               etc ).
  --month MONTH                Month of the year the job should run ( 1-12, *,
                               */2, etc ).
  --special-time SPECIAL_TIME  Special time specification nickname.
  --user USER                  The specific user whose crontab should be
                               modified. When unset, this parameter defaults
                               to using root.
  --weekday WEEKDAY            Day of the week that the job should run ( 0-6
                               for Sunday-Saturday, *, etc ).
  --help                       Show this message and exit.
# -*- coding: utf-8 -*-


#
# module path: pycklets.cronjob_exists.CronjobExists
#


from dataclasses import dataclass
from pyckles import AutoPycklet
from typing import *    # noqa

@dataclass
class CronjobExists(AutoPycklet):
    """Ensures a cron job exists.

     This mostly just forwards arguments to the 'cron' Ansible module, please check it's documentation for more details.

       Args:
         day: Day of the month the job should run ( 1-31, *, */2, etc ).
         hour: Hour when the job should run ( 0-23, *, */2, etc ).
         job: The command to execute.
         minute: Minute when the job should run ( 0-59, *, */2, etc ).
         month: Month of the year the job should run ( 1-12, *, */2, etc ).
         name: Description of a crontab entry.
         special_time: Special time specification nickname.
         user: The specific user whose crontab should be modified. When unset, this parameter defaults to using root.
         weekday: Day of the week that the job should run ( 0-6 for Sunday-Saturday, *, etc ).

    """

    FRECKLET_ID = "cronjob-exists"

    day: str = None
    hour: str = None
    job: str = None
    minute: str = None
    month: str = None
    name: str = None
    special_time: str = None
    user: str = None
    weekday: str = None


    def __post_init__(self):
        super(CronjobExists, self).__init__(var_names=["day", "hour", "job", "minute", "month", "name", "special_time", "user", "weekday"])


frecklet_class = CronjobExists
# -*- coding: utf-8 -*-


#
# module path: pycklets.cronjob_exists.CronjobExists
#


from pyckles import AutoPycklet

class CronjobExists(AutoPycklet):
    """Ensures a cron job exists.

     This mostly just forwards arguments to the 'cron' Ansible module, please check it's documentation for more details.

       Args:
         day: Day of the month the job should run ( 1-31, *, */2, etc ).
         hour: Hour when the job should run ( 0-23, *, */2, etc ).
         job: The command to execute.
         minute: Minute when the job should run ( 0-59, *, */2, etc ).
         month: Month of the year the job should run ( 1-12, *, */2, etc ).
         name: Description of a crontab entry.
         special_time: Special time specification nickname.
         user: The specific user whose crontab should be modified. When unset, this parameter defaults to using root.
         weekday: Day of the week that the job should run ( 0-6 for Sunday-Saturday, *, etc ).

    """

    FRECKLET_ID = "cronjob-exists"

    def __init__(self, day=None, hour=None, job=None, minute=None, month=None, name=None, special_time=None, user="root", weekday=None):

        super(CronjobExists, self).__init__(var_names=["day", "hour", "job", "minute", "month", "name", "special_time", "user", "weekday"])
        self._day = day
        self._hour = hour
        self._job = job
        self._minute = minute
        self._month = month
        self._name = name
        self._special_time = special_time
        self._user = user
        self._weekday = weekday

    @property
    def day(self):
        return self._day

    @day.setter
    def day(self, day):
        self._day = day

    @property
    def hour(self):
        return self._hour

    @hour.setter
    def hour(self, hour):
        self._hour = hour

    @property
    def job(self):
        return self._job

    @job.setter
    def job(self, job):
        self._job = job

    @property
    def minute(self):
        return self._minute

    @minute.setter
    def minute(self, minute):
        self._minute = minute

    @property
    def month(self):
        return self._month

    @month.setter
    def month(self, month):
        self._month = month

    @property
    def name(self):
        return self._name

    @name.setter
    def name(self, name):
        self._name = name

    @property
    def special_time(self):
        return self._special_time

    @special_time.setter
    def special_time(self, special_time):
        self._special_time = special_time

    @property
    def user(self):
        return self._user

    @user.setter
    def user(self, user):
        self._user = user

    @property
    def weekday(self):
        return self._weekday

    @weekday.setter
    def weekday(self, weekday):
        self._weekday = weekday



frecklet_class = CronjobExists