Usage
Overview
After creating an inventory, you can install the my collection and use it in Playbooks to run automations against the infrastructure defined in your inventory.
Relationship between collections, roles, playbooks, and inventories
- Roles are defined in a collection (or separately in a
roles/path, but this repository uses collections to encapsulate roles). - Playbooks import roles/role tasks from a collection using dot notation (i.e.
my.homelab.debugwith optional scoping to thedebug-cpu.ymltask) - Inventories define your infrastructure and pass variables to playbooks to alter the way a role runs.
Read more in-depth documentation on each of the tools used in this repository.
Running playbooks
After finishing the setup steps, you can run playbooks using the following syntax:
| Ansible playbook syntax | |
|---|---|
The [-i <inventory-name>] is optional; if you do not specify an inventory, the default inventories/homelab/inventory.yml. The ANSIBLE_INVENTORY environment variable defined in the direnv .envrc also sets the default inventory. You can override it with a .envrc.local file.
Finally, if you want to override the environment variable, you can use the -i arg for the ansible-playbook command. For example, to use an inventory defined in inventories/example/inventory.yml: