My Homelab using Ansible to deploy Docker containers
- Install
uv: uv docs - Install
pre-commit:
uv tool install pre-commit --with pre-commit-uv- Install
ansible:
uv tool install ansible-core --with ansible- Install pre-commit hooks:
pre-commit install| Playbook File | Inventory | Description |
|---|---|---|
deploy.yml |
inventory.yaml |
The master playbook that imports other roles to configure the entire infrastructure. |
maintenance.yml |
inventory.yaml |
Performs server maintenance activities such as package update. |
reset-network.yml |
sos-inventory.yaml |
Resets network for entire infrastructure. |
- Test connectivity:
ansible all -m ping- Select hosts to run (Single/Multiple):
ansible-playbook deploy.yaml --limit test
ansible-playbook deploy.yaml --limit test,prod- Dry run:
ansible-playbook deploy.yaml --check --diff- Filter roles by tags:
ansible-playbook deploy.yaml --skip-tags "initial-setup"- Check target host variables:
ansible-inventory -i inventory.yaml --host experiment- Stop and remove all containers:
docker stop $(docker ps -q) && docker rm $(docker ps -aq)