If you are using RHEL 8 then you can use the subscription manager to get Ansible with the host and config file pre-built.
Also, you will need to create an account on https://developers.redhat.com before you can do this:
subscription-manager register --auto-attach
subscription-manager repos --enable ansible-2.8-for-rhel-8-x86_64-rpms
yum -y install ansible
ansible --version
Answer from Aryan Srivastava on Stack OverflowVideos
If you are using RHEL 8 then you can use the subscription manager to get Ansible with the host and config file pre-built.
Also, you will need to create an account on https://developers.redhat.com before you can do this:
subscription-manager register --auto-attach
subscription-manager repos --enable ansible-2.8-for-rhel-8-x86_64-rpms
yum -y install ansible
ansible --version
EPEL8 is not released yet. There are some packages available, but a lot are still being worked on and the repo is not considered "generally available".
For now, you can install Ansible from the Python Package Index (PyPI):
yum install python3-pip
pip3 install ansible
Ansible loop can solve like below.
ignore_errors: false
become: yes
become_method: sudo
yum:
name: "{{ item }}"
state: present
update_cache: yes
loop:
- "epel-release"
- "clamav"
Although using a loop as proposed by @Haldum should effectively solve your issue, its use is discouraged in yum module documentation. Since you definitely need to add the epel repo prior to using it, I would create two tasks where you can eventually install several packages in the second.
- name: install my things
hosts: my_hostgroup
become: true
vars:
my_packages:
- clamav
# - some other package maybe
tasks:
- name: Install prerequisite epel repo
yum:
name: epel-release
state: present
- name: Install required packages
yum:
name: "{{ my_packages }}"
state: present