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
[servers]
devtest ansible_host=99.9.99.99 ansible_user=ec2-user
$ ansible all --list-hosts
[WARNING]: Unable to parse /home/ec2-user/ansible_work/inventory.txt as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
hosts (0):
=======================================================================
$ ansible-inventory --graph -vvv
ansible-inventory 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-inventory
python version = 2.7.18 (default, Jun 10 2021, 00:11:02) [GCC 7.3.1 20180712 (Red Hat 7.3.1-13)]
Using /etc/ansible/ansible.cfg as config file
aws_ec2 declined parsing /home/ec2-user/ansible_work/inventory.txt as it did not pass its verify_file() method
[WARNING]: Unable to parse /home/ec2-user/ansible_work/inventory.txt as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
@all:
|--@ungrouped:
====================================================================
$ ansible -m ping devtest -vvv
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)]
Using /etc/ansible/ansible.cfg as config file
aws_ec2 declined parsing /home/ec2-user/ansible_work/inventory.txt as it did not pass its verify_file() method
[WARNING]: Unable to parse /home/ec2-user/ansible_work/inventory.txt as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
[WARNING]: Could not match supplied host pattern, ignoring: devtest
Skipping callback 'actionable', as we already have a stdout callback.
Skipping callback 'counter_enabled', as we already have a stdout callback.
Skipping callback 'debug', as we already have a stdout callback.
Skipping callback 'dense', as we already have a stdout callback.
Skipping callback 'dense', as we already have a stdout callback.
Skipping callback 'full_skip', as we already have a stdout callback.
Skipping callback 'json', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'null', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.
Skipping callback 'selective', as we already have a stdout callback.
Skipping callback 'skippy', as we already have a stdout callback.
Skipping callback 'stderr', as we already have a stdout callback.
Skipping callback 'unixy', as we already have a stdout callback.
Skipping callback 'yaml', as we already have a stdout callback.
=================
shouldn't i see the hostname there in the output?
this is the documentation I followed:
https://devopscube.com/setup-ansible-aws-dynamic-inventory/
and even tried this:
https://devopsmyway.com/how-to-install-ansible-on-amazon-linuxec2/
Will really appreciate your response. thank you!
-Huda
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