Hey All I am working with ansible on a fresh ubuntu system and have installed st . . .

MK:
Hey All
I am working with ansible on a fresh ubuntu system and have installed stable system with ansible-core…which is ok. now I’ve created some vms on virtual box but in the current-working-directory…the hosts(inventory from current directory ) file is not picked up by default by the ansible-core that I’m running.

I’ve checked my /etc/ansible/ansible.cfg file for any default params that need tweaking…it was blank first, so I’ve created one with ansible-config init --disabled -t all > /etc/ansible/ansible.cfg

problem is I’ve also tried passing environment variables to prioritize the local inventory (from current working directory) can someone guide/help. Please

Deepak Kumar:
Hi @MK I got this answer & links from my expertbot, let me know if it was helpful

http://Doc-E.ai|Doc-E.ai [9:03 PM]
Based on the description of your problem, it seems that Ansible is not picking up the inventory file from the current directory. This is likely because the inventory file location is not correctly specified in the ansible.cfg file.

In Ansible, the location of the inventory file is specified in the ansible.cfg file under the [defaults] section with the key ‘inventory’. If this key is not set, Ansible will look for the inventory file in /etc/ansible/hosts by default.

To solve your issue, you need to specify the location of your inventory file in the ansible.cfg file. Here is an example of how to do it:

  1. Open the ansible.cfg file in a text editor.

  2. Add the following lines to the file:

[defaults]
inventory = ./hosts

This tells Ansible to look for the inventory file named ‘hosts’ in the current directory.

  1. Save and close the file.

Now, when you run an Ansible command, it should pick up the inventory file from the current directory.

If you still face issues, please provide the error messages or status codes you are getting for further assistance.

Reference: https://stackoverflow.com/q/70959667

A*<https://stackoverflow.com/q/74932636|nsible Playbook skipping: no hosts matched>*
<https://stackoverflow.com/q/65748195|Ansible SSH and Playbook>
<https://stackoverflow.com/q/66199229|Failed to connect to sever while pinging with ansible>

MK:
Thanks @Deepak Kumar the first SO link itself answered my all questions/concerns. Appreciate your help :+1:

MK: