The best way to install ansible is through pip.
Using pip
Follow the steps given below to install pip if it is not already installed.
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
sudo python get-pip.py
Form EPEL repo
Setup EPEL repo first. You can follow the steps from here for setting up EPEL repo on ec2 server.
Once EPEL is setup, execute the following command to install Ansible.
sudo yum install ansible