xoxys.yum/tasks/yum_cron.yml
Robert Kaussow d904433e0a
Some checks failed
continuous-integration/drone/push Build is failing
chore: dont remove default yum-cron cronjob
2021-05-25 18:30:32 +02: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 }}"
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
cron_file: /etc/crontab
job: "/bin/sh /etc/cron.d/x-yum"
become: True
become_user: root
when: yum_cron_custom_cronjob.enabled | bool