Ansible not recognizing hosts for aws ec2 hosts

Hello,

Could someone please help with the following issue:
when I run any of the ansible list hosts commands, it doesn’t show the host that’s listed in the file. What am I doing wrong? I’m able to ssh passwordless to this host.

I’ve the inventory.txt file:

This is the snippet of /etc/ansible/ansible.cfg

[defaults]

some basic default values…

inventory = /home/ec2-user/ansible_work/inventory.txt

[inventory]

enable_plugins = aws_ec2

Sorry forgot to mention:

I’m on AWS EC2 Red Hat Fedora

Operating System: Amazon Linux 2

Architecture: x86-64

$ ansible --version

ansible 2.9.25

config file = /etc/ansible/ansible.cfg

configured module search path = [u’/home/ec2-user/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]

ansible python module location = /usr/lib/python2.7/site-packages/ansible

executable location = /usr/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)]

Thanks,

Huda