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 Overflow
🌐
AnsiblePilot
ansiblepilot.com › home › articles › how to install ansible in amazon linux 2 (aws ec2) - ansible install
How to install Ansible in Amazon Linux 2 (AWS EC2)
November 17, 2024 - [root@ip-172-31-36-49 ec2-user]# ansible --version ansible 2.9.25 config file = /etc/ansible/ansible.cfg configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /bin/ansible python version = 2.7.18 (default, Jun 10 2021, 00:11:02) [GCC 7.3.1 20180712 (Red Hat 7.3.1-13)] [root@ip-172-31-36-49 ec2-user]# rpm -qa | grep ansible ansible-2.9.25-1.el7.noarch [root@ip-172-31-36-49 ec2-user]# # rpm -qa | grep ansible ansible-2.9.25-1.el7.noarch ... Now you know how to install the latest version of Ansible in Amazon Linux using the Amazon Extras Library and EPEL repositories. • orchestrating containers via Ansible • Nginx config templating with Ansible • IAM management via Ansible on AWS ·
🌐
AWS
aws.amazon.com › blogs › mt › running-ansible-playbooks-using-ec2-systems-manager-run-command-and-state-manager
Running Ansible Playbooks using EC2 Systems Manager Run Command and State Manager | AWS Cloud Operations Blog
January 16, 2021 - You can use the following command. ... Ubuntu For Ubuntu you can install Ansible using the default package manager. Use this command. ... RedHat 7 For RedHat 7 you can install Ansible by enabling the epel repo.
🌐
Medium
devops4solutions.medium.com › ansible-setup-on-aws-ec2-instance-d83fac41fcc8
Ansible Setup on AWS EC2 Linux Instance | by Nidhi | Medium
June 28, 2020 - Install Ansible on Redhat · wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpmrpm -ivh epel-release-latest-7.noarch.rpmyum repolistyum --enablerepo=epel… · 1.96K followers · ·11 following · Devops Automation Enginneer · See all responses ·
🌐
Ansible
docs.ansible.com › projects › ansible › latest › installation_guide › intro_installation.html
Installing Ansible — Ansible Community Documentation
The ansible or ansible-core packages may be available in your operating systems package manager, and you are free to install these packages with your preferred method. For more information, see the Installing Ansible on specific operating systems guide.
🌐
Medium
medium.com › @sumitnair89 › how-to-install-ansible-on-rhel-8-f2c9d7c5dc8a
How to Install Ansible on AWS EC2 Instance RHEL 8 | by Sumit | Medium
March 12, 2020 - How to Install Ansible on AWS EC2 Instance RHEL 8 Originally posted on https://blog.cloudthat.com/how-to-install-ansible-on-rhel-8/ This is a simple blog stating the steps involved in installing …
Find elsewhere
🌐
Red Hat
access.redhat.com › solutions › 4564511
Why I Cannot Install Ansible Tower On AWS EC2? - Red Hat Customer Portal
June 14, 2024 - setup.sh fails with Cannot find a valid baseurl for repo: rhui-REGION-rhel-server-extras on AWS EC2. Ansible Tower <= 3.5.3 AWS EC2 · A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more. Log in for full access Log In ·
🌐
Red Hat
developers.redhat.com › articles › 2023 › 06 › 05 › how-create-ec2-instance-aws-using-ansible-automation
How to create an EC2 instance in AWS using Ansible automation | Red Hat Developer
January 11, 2024 - Learn how to use Ansible Automation Platform to automate the process of creating an EC2 instance in AWS, making it more efficient. (Part 2 of 3)
🌐
Stack Overflow
stackoverflow.com › questions › 72389710 › how-to-install-ansible-in-red-hat-enterprise-linux-8-2
python - How to install ansible in Red Hat Enterprise Linux 8.2 - Stack Overflow
You need to install ansible using pip3 first install python3-pip then you can easily install ansible. I have created a video on this check it out to understand the process
🌐
Red Hat
developers.redhat.com › articles › 2023 › 06 › 05 › how-create-ec2-instance-aws-using-ansible-cli
How to create an EC2 instance in AWS using Ansible CLI | Red Hat Developer
January 11, 2024 - Learn how to streamline your infrastructure management workflows by creating an EC2 instance in AWS using the Ansible Automation Platform CLI. (Part 1 of 3)
🌐
Red Hat
docs.redhat.com › en › documentation › red_hat_ansible_automation_platform › 2.0-ea › html-single › red_hat_ansible_automation_platform_installation_guide › index
Red Hat Ansible Automation Platform Installation Guide | Red Hat Ansible Automation Platform | 2.0-ea | Red Hat Documentation
You can use this section to help plan your Red Hat Ansible Automation Platform installation. Before installation, review information on the setup installer, system requirements, and supported installation scenarios.
🌐
Medium
medium.com › @dassandeep0001 › install-ansible-on-ec2-instance-bbfa7e4481ec
Install Ansible on ec2 instance - Sandeep Das - Medium
January 11, 2023 - Install Ansible on ec2 instance To install Ansible on an Amazon Elastic Compute Cloud (EC2) instance, you can use the command-line interface (CLI) provided by the Amazon Elastic Compute Cloud (EC2)
🌐
GitHub
gist.github.com › diegopacheco › 3af46c13c5a709bf642d
How to Install Ansible on Amazon Linux / CentOS? · GitHub
sudo su yum update yum install -y git cd /usr/local/src yum -y install git python-jinja2 python-paramiko PyYAML make MySQL-python git clone git://github.com/ansible/ansible.git cd ansible git submodule update --init --recursive make install CTRL + D
🌐
DEV Community
dev.to › aws-builders › installing-ansible-on-aws-ec2-instance-fj9
Installing Ansible on AWS EC2 Instance - DEV Community
December 25, 2022 - Spin and EC2 instance and connect to it via ssh or directly from your aws console . For the purpose of this post I created an aws ubuntu instance. After connecting to your instance run the commands bellow.
🌐
GeeksforGeeks
geeksforgeeks.org › cloud computing › install-ansible-in-aws-ec2-server
Ansible Installation on AWS EC2 Server - GeeksforGeeks
August 11, 2025 - sudo apt update sudo apt install software-properties-common sudo add-apt-repository --yes --update ppa:ansible/ansible sudo apt install ansible · Step 4 : Now copy the private key of worker node into the master node .
🌐
Red Hat
developers.redhat.com › blog › 2016 › 09 › 02 › how-to-install-and-configure-ansible-on-rhel
How to install and configure Ansible on Red Hat Enterprise Linux | Red Hat Developer
September 27, 2024 - No other software is required as Ansible utilizes SSH to interact with remote servers. Now that we’ve added the EPEL repository, we’re ready to install Ansible! This can be done by running yum -y install ansible on the command line.
Top answer
1 of 2
6

why config file = None?

Because at the time of running ansible --version no config file was found.

shouldn't it shows /etc/ansible/ansible.cfg?

No. It should show the ansible.cfg actually being used.

Per documentation, Ansible tries to find the config file in:

  • ANSIBLE_CONFIG (an environment variable)
  • ansible.cfg (in the current directory)
  • .ansible.cfg (in the home directory)
  • /etc/ansible/ansible.cfg

ansible --version will show you the exact path to the one being used.

Strictly speaking the last point is not always true, as package managers and virtual environment managers might cause the /etc directory to be located elsewhere.

did I install correctly

You didn't mention any error or warning during the installation and ansible --version returned a proper response.

There is no reason not to believe it's installed properly.

where is the folder /etc/ansible?

It's not existing on your system. There is no default inventory file, nor configuration file created by the installation package.

Create one.

2 of 2
2

Here I answer the question myself.

There are many ways to install ansible, and then you get difference default settings, depending on the OS. Many tutorials just assume the ansible_hosts and ansible.cfg already in /etc/ansible, which is not correct if you install ansible using pip.

In fact, if you install ansible using pip, then you will not see ansible.cfg and ansible_hosts in /etc/ansible. Even the folder /etc/ansible does not exist. but never mind, you can create these two files yourself as follows:

suppose you want to store ansible_hosts and ansible.cfg in /home/ec2-user, then you can:

echo <remote_host> /home/ec2-user/ansible_hosts
export ANSIBLE_INVENTORY=/home/ec2-user/ansible_hosts
wget https://raw.githubusercontent.com/ansible/ansible/devel/examples/ansible.cfg
mv ansible.cfg /home/ec2-user/
export ANSIBLE_CONFIG=/home/ec2-user/ansible.cfg

then if ansible --version, you will see

ansible 2.4.1.0
  config file = /home/ec2-user/ansible.cfg
....

and if you test ansible ad-hoc command (my remote_host is ubuntu, so I use -u ubuntu, you can change it to be yours):

ansible all -m ping -u ubuntu

then you see ansible ping remote_host successfully.

This shows ansible does work.