Installing from EPEL on Amazon EC2

I am trying to install fail2ban on our Amazon EC2 Linux AMI (CentOS). I know that fail2ban is in the EPEL so I have done the following:

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo rpm -Uvh epel-release*rpm

However, when I do that I get the following message:

package epel-release-6-8.9.amzn1.noarch (which is newer than epel-release-6-8.noarch) is already installed

Which implies to me that EPEL is already available but if I do:

sudo yum install fail2ban

I get:

Loaded plugins: priorities, security, update-motd, upgrade-helper
amzn-main                                                                                   | 2.1 kB     00:00
amzn-updates                                                                                | 2.3 kB     00:00
Setting up Install Process
No package fail2ban available.
Error: Nothing to do

I assume that I am misunderstanding something but how can I install from EPEL?

EDIT: I have just done the following and found that the repo is not enabled:

yum repolist all

SO how do I enable a repo on EC2?


Solution 1:

You should check that epel is enabled using

yum repolist enabled

If it's not then you can edit /etc/yum.repos.d/epel.repo and change the [epel] section

enabled=0

to

enabled=1

or use

 yum-config-manager --enable epel

Solution 2:

The epel repo is on the default Amazon server but in not enabled by default. You can use it to install a package:

sudo yum --enablerepo epel install fail2ban

Solution 3:

Update for Amazon Linux 2:

sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

Or,

sudo amazon-linux-extras install epel -y

Or,

sudo amazon-linux-extras enable epel
sudo yum install -y epel-release