Skip to content

boutetnico/ansible-role-cron

Repository files navigation

tests Ansible Galaxy

ansible-role-cron

This role configures cron jobs.

Requirements

Ansible 2.10 or newer.

Supported Platforms

Role Variables

Variable Required Default Choices Comments
cron_dependencies yes [cron] list
cron_jobs yes [] list Cron jobs to install. See defaults/main.yml.

Dependencies

None

Example Playbook

- hosts: all
  roles:
    - ansible-role-cron
      cron_jobs:
        - name: "run backup script every 6 hours as admin"
          job: backup.sh
          hour: "*/6"
          minute: 0
          user: admin
        - name: "delete files in /tmp every hour as root"
          job: "rm -rf /tmp"
          special_time: "hourly"
        - name: "rsync files between 2 directories every 15 minutes using /etc/cron.d/rsync as root"
          job: "rsync -a /mnt /backup"
          cron_file: "rsync"
          user: root
        - name: "backup database daily using /etc/cron.d/backup_database as admin"
          job: "/home/admin/mysqldump.sh"
          cron_file: "backup_database"
          special_time: "daily"
          user: admin

Testing

molecule test

License

MIT

Author Information

@boutetnico