The inventory file

We do not need Ansible if we have no remote target to manage, right? Everything starts with the fact that we need to perform some task on a remote host. In Ansible, the way we specify the potential remote target is with an inventory file. We can have this inventory file as the /etc/ansible/hosts file or use the -i option to specify the file during playbook runtime. Personally, I prefer to have this file in the same directory where my playbook is and use the -i option.

Technically, this file can be named anything you like as long as it is in a valid format. However, the convention is to name this file hosts. You can potentially save yourself and your colleagues some headaches in the future by following this convention.

Get Mastering Python Networking - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.