xoxys.yum/tasks/yum_cron.yml
Robert Kaussow 240b4c06a0
All checks were successful
continuous-integration/drone/push Build is passing
fix: dont use cron_file: /etc/crontab
2021-12-06 21:16:15 +01:00

57 lines
1.6 KiB
YAML

---
- block:
- name: Install yum-cron
package:
name: yum-cron
state: present
- name: Ensure yum-cron is enabled and running
service:
name: yum-cron
state: started
- name: Adjust yum-cron config file
template:
src: etc/yum/yum-cron.conf.j2
dest: /etc/yum/yum-cron.conf
owner: root
group: root
mode: 0644
notify: __yum_cron_restart
become: True
become_user: root
- block:
- name: Disable default cronjobs for yum-cron
copy:
content: |
# Ansible managed.
# File was moved to '/etc/cron.d/x-yum'
dest: "{{ item }}"
mode: 0755
loop:
- /etc/cron.daily/0yum-daily.cron
- /etc/cron.hourly/0yum-hourly.cron
- name: Add custom cronjob for yum-cron
template:
src: etc/cron.d/x-yum.j2
dest: /etc/cron.d/x-yum
owner: root
group: root
mode: 0755
- name: Configure crontab to use custom yum-cron cronjob
cron:
name: "{{ yum_cron_custom_cronjob.name | default('yum-cron') }}"
minute: "{{ yum_cron_custom_cronjob.minute | default(0) }}"
hour: "{{ yum_cron_custom_cronjob.hour | default(4) }}"
day: "{{ yum_cron_custom_cronjob.day | default('*') }}"
weekday: "{{ yum_cron_custom_cronjob.weekday | default('*') }}"
month: "{{ yum_cron_custom_cronjob.month | default('*') }}"
user: root
job: "/bin/sh /etc/cron.d/x-yum"
become: True
become_user: root
when: yum_cron_custom_cronjob.enabled | bool