SHELL := /bin/bash INVENTORY ?= inventory.ini PLAYBOOK ?= site.yml EXTRA_VARS ?= ANSIBLE ?= ansible-playbook .PHONY: help ping check run dry-run diff vars tree clean help: @echo "Targets:" @echo " make ping - ping hosts (Ansible)" @echo " make check - syntax-check playbook" @echo " make run - apply playbook" @echo " make dry-run - check mode with diff (no changes)" @echo " make diff - show diff of changes (implies --check)" @echo " make vars - show vars for a host (requires host=...)" @echo " make tree - show repository tree" @echo "" @echo "Examples:" @echo " make run EXTRA_VARS='-e ssh_allow_cidrs_v4=[\"1.2.3.4/32\"]'" @echo " make vars host=bbb" ping: ansible -i $(INVENTORY) vps -m ping check: $(ANSIBLE) -i $(INVENTORY) $(PLAYBOOK) --syntax-check run: $(ANSIBLE) -i $(INVENTORY) $(PLAYBOOK) --become $(EXTRA_VARS) dry-run: $(ANSIBLE) -i $(INVENTORY) $(PLAYBOOK) --become --check --diff $(EXTRA_VARS) diff: $(ANSIBLE) -i $(INVENTORY) $(PLAYBOOK) --become --check --diff $(EXTRA_VARS) vars: @if [[ -z "$(host)" ]]; then echo "ERROR: host is required, e.g. make vars host=bbb"; exit 2; fi ansible -i $(INVENTORY) $(host) -m debug -a "var=hostvars[inventory_hostname]" | sed -n '1,200p' tree: @python3 -c $'import os\nfor root, dirs, files in os.walk("."):\n dirs[:] = [d for d in dirs if d not in {".git","__pycache__",".venv",".cache"}]\n level = root.count(os.sep)\n indent = " " * level\n print(f"{indent}{os.path.basename(root)}/")\n subindent = " " * (level + 1)\n for f in sorted(files):\n print(f"{subindent}{f}")' clean: @find . -name "*.retry" -delete