---
- name: Install yum-cron.
  yum: name=yum-cron state=present

- name: Ensure yum-cron is running and enabled on boot.
  service: name=yum-cron state=started enabled=yes

- name: Configure autoupdates (RHEL 7).
  lineinfile:
    dest: "/etc/yum/yum-cron.conf"
    regexp: '^apply_updates = .+'
    line: 'apply_updates = yes'
  when: security_autoupdate_enabled and ansible_distribution_major_version | int == 7
