---

- name: Yum | Install yum-cron (CentOS)
  yum:
    name: yum-cron
    state: present
  when: yum_cron_enabled
  become: True

- name: Replace | Enable update applying for yum-cron (CentOS)
  replace:
    dest: /etc/yum/yum-cron.conf
    regexp: "^apply_updates = no"
    replace: "apply_updates = yes"
  when: yum_cron_enabled
  notify:
    - Restart yum-cron
  become: True

- name: Replace | Enable update applying for yum-cron (CentOS)
  replace:
    dest: /etc/yum/yum-cron.conf
    regexp: "^update_cmd = .*$"
    replace: "update_cmd = {{ yum_cron_update_cmd }}"
  when: yum_cron_enabled
  notify:
    - Restart yum-cron
  become: True

- name: Service | Enable yum-cron (CentOS)
  service:
    name: yum-cron
    state: started
    enabled: yes
  when: yum_cron_enabled
  become: True
