> For the complete documentation index, see [llms.txt](https://til.devjugal.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.devjugal.com/ansible/ansible-configure-default-inventory-file.md).

# Ansible Configure Default Inventory File

By default, Ansible would attempt to read the default configuration file at `/etc/ansible/hosts`, we can specify the default configuration file to use by creating an Ansible configuration file.

## Procedure

1. Create `ansible.cfg` file in home directory, or project directory.
2. Configure the `ansible.cfg` file in home directory, & add `[defaults]` section:

```ini
[defaults]
inventory = ~/.ansible/hosts
```

***Source:*** [***StackOverFlow***](https://stackoverflow.com/a/63413958)

***Reference(s):***

* [Working with Inventory - Ansible Documentation](https://docs.ansible.com/ansible/2.7/user_guide/intro_inventory.html)
* [Ansible Configuration Settings - Ansible Documentation](https://docs.ansible.com/ansible/latest/reference_appendices/config.html)
