--- - hosts: all gather_facts: True become: true strategy: free tasks: - name: Enable EPEL Repository on CentOS 8 dnf: name: epel-release state: latest when: ansible_facts['os_family'] == 'RedHat' and ansible_facts ['distribution_major_version'] >= '8' - name: Enable EPEL Repository on CentOS 7 yum: name: epel-release state: latest when: ansible_facts['os_family'] == 'RedHat' and ansible_facts ['distribution_major_version'] == '7'