I have the following Ansible playbook to create a cronjob on red hat Linux servers, this works well, but the problem is that it runs every time irrespective of whether the same cronjob is already present or not. I know it runs because it generates new hour and minute values every time. Is there any way to make it not run when this job is already present in crontab?
- hosts: all
tasks:
- name: Generate randon minute
set_fact:
random_minute: "59"
run_once: yes
- debug: var=random_minute
- name: Generate random hour
set_fact:
random_hour: "23"
run_once: yes
- debug: var=random_hour
- name: "Cronjob Entry"
cron:
name: "### oscompliance cronjob"
minute: ""
hour: ""
day: "*"
month: "*"
weekday: "*"
job: /users/user1/scripts/os_check >> /tmp/os_checkoutput 2>&1
Aucun commentaire:
Enregistrer un commentaire