About a year ago, I switched my Django development workflow to include justfiles which are "recipes" of tasks to be used with the just task runner.
Since then, I find myself dropping little justfiles all over the place. Here's one I created for an Ansible repository:
# Show all available commands
default:
@just --list
# Run playbook in check mode (dry-run)
check ENV="dev" PLAYBOOK="site":
ansible-playbook --diff -i ./inventory/{{ENV}}/hosts.yml --check playbooks/{{PLAYBOOK}}.yml
# Run the main site playbook
run ENV="dev" PLAYBOOK="site":
ansible-playbook --diff -i ./inventory/{{ENV}}/hosts.yml playbooks/{{PLAYBOOK}}.yml
Super simple 🚀, and it lets me run a bunch of Ansible playbooks like this:
> just check
ansible-playbook --diff -i ./inventory/dev/hosts.yml --check playbooks/site.yml
just check prod
ansible-playbook --diff -i ./inventory/prod/hosts.yml --check playbooks/site.yml
just run prod common
ansible-playbook --diff -i ./inventory/prod/hosts.yml playbooks/common.yml
Sometimes I'll drop one in the root of a remote server with a bunch of common tasks like installing updates, running various maintenance tasks, or monitoring the system. I used to do this with Bash aliases, but I prefer the just syntax, and it feels easier to copy the files around.
😍