If you are using Ubuntu EC2 instance, follow this: http://docs.ansible.com/ansible/intro_installation.html#latest-releases-via-apt-ubuntu
If you are using Amazon Linux EC2 instance, follow this: http://docs.ansible.com/ansible/intro_installation.html#latest-release-via-yum
Installing via these package managers will create the /etc/ansible/hosts file for you.
Answer from RaviTezu on Stack OverflowIf you are using Ubuntu EC2 instance, follow this: http://docs.ansible.com/ansible/intro_installation.html#latest-releases-via-apt-ubuntu
If you are using Amazon Linux EC2 instance, follow this: http://docs.ansible.com/ansible/intro_installation.html#latest-release-via-yum
Installing via these package managers will create the /etc/ansible/hosts file for you.
Steps to install Ansible on EC2 instance [RHEL-8]:
sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpmsudo dnf config-manager --set-enabled codeready-builder-for-rhel-8-rhui-rpmsdnf install ansibleansible --version
Use dnf for faster dependency resolution.
It appears that python library files do not have correct permissions by default. Running this fixed it for me.
[root@ip-10-0-0-11 ansible]# pip install ansible
Using pip (alone, not in conjunction with yum) is probably the best option right now on Amazon Linux. I'd suggest getting rid of the yum-installed copy if it's still there.
The RPM specs in epel and epel-testing (as of 1.9.2) currently handle only RHEL, Fedora, and SuSE, and the defaults are installing everything under Python 2.6, where the latest Amazon Linux has default Python 2.7. A bit of work will be required to get the RPM install working under Amazon Linux...