65 lines
2.3 KiB
Makefile
65 lines
2.3 KiB
Makefile
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 prep bbb bbb-dry-run greenlight greenlight-dry-run
|
|
|
|
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"
|
|
@echo " make greenlight - installer/mettre à niveau Greenlight v3 (bbb-install -g)"
|
|
@echo " make greenlight-dry-run - check mode pour Greenlight"
|
|
|
|
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
|
|
|
|
prep:
|
|
$(ANSIBLE) -i $(INVENTORY) $(PLAYBOOK) --become --tags prep $(EXTRA_VARS)
|
|
|
|
bbb:
|
|
$(ANSIBLE) -i $(INVENTORY) $(PLAYBOOK) --become --tags bbb $(EXTRA_VARS)
|
|
|
|
bbb-dry-run:
|
|
$(ANSIBLE) -i $(INVENTORY) $(PLAYBOOK) --become --tags bbb --check --diff $(EXTRA_VARS)
|
|
|
|
|
|
greenlight:
|
|
$(ANSIBLE) -i $(INVENTORY) $(PLAYBOOK) --become --tags bbb $(EXTRA_VARS) -e bbb_install_greenlight=true
|
|
|
|
greenlight-dry-run:
|
|
$(ANSIBLE) -i $(INVENTORY) $(PLAYBOOK) --become --tags bbb --check --diff $(EXTRA_VARS) -e bbb_install_greenlight=true
|