55 lines
1.5 KiB
YAML
55 lines
1.5 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: Remove default cronjobs for yum-cron
|
|
file:
|
|
path: "{{ item }}"
|
|
state: absent
|
|
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
|