Files
ansible/justfile

52 lines
1.5 KiB
Makefile

venv_bin := "venv/bin"
# List available commands
default:
@just --list
# Create the Python virtualenv used to run ansible
venv:
python3 -m venv venv
{{venv_bin}}/pip install --upgrade pip
# Install Python deps (requirements.txt) and Galaxy collections (requirements.yml)
install:
{{venv_bin}}/pip install -r requirements.txt
{{venv_bin}}/ansible-galaxy collection install -r requirements.yml < /dev/null
# Ping all hosts, or a group/host, e.g. `just ping kitchenpi`
ping group="all":
{{venv_bin}}/ansible {{group}} -m ping
# Show the resolved inventory as a tree
inventory:
{{venv_bin}}/ansible-inventory --graph
# Syntax-check a playbook, e.g. `just syntax full.yml`
syntax playbook:
{{venv_bin}}/ansible-playbook {{playbook}} --syntax-check
# Dry-run a playbook against a host/group without making changes
check playbook limit="all":
{{venv_bin}}/ansible-playbook {{playbook}} --limit {{limit}} --check --diff
# Run a playbook against a host/group, e.g. `just run full.yml kitchenpi`
run playbook limit="all":
{{venv_bin}}/ansible-playbook {{playbook}} --limit {{limit}}
# Run full.yml (pi roles) against one host/group, e.g. `just full kitchenpi`
full limit="all":
just run full.yml {{limit}}
# Run server.yml against the server host
server:
just run server.yml server
# List installed Galaxy collections
collections:
{{venv_bin}}/ansible-galaxy collection list
# Lint playbooks and roles
lint:
{{venv_bin}}/ansible-lint