mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Restructured service und web role naming in inventor
This commit is contained in:
65
Makefile
65
Makefile
@@ -1,43 +1,56 @@
|
||||
ROLES_DIR := ./roles
|
||||
APPLICATIONS_OUT := ./group_vars/all/04_applications.yml
|
||||
ROLES_DIR := ./roles
|
||||
APPLICATIONS_OUT := ./group_vars/all/04_applications.yml
|
||||
APPLICATIONS_SCRIPT := ./cli/generate_applications.py
|
||||
USERS_OUT := ./group_vars/all/03_users.yml
|
||||
USERS_SCRIPT := ./cli/generate_users.py
|
||||
INCLUDES_OUT := ./tasks/utils/server-roles.yml
|
||||
INCLUDES_SCRIPT := ./cli/generate_playbook.py
|
||||
USERS_OUT := ./group_vars/all/03_users.yml
|
||||
USERS_SCRIPT := ./cli/generate_users.py
|
||||
INCLUDES_SCRIPT := ./cli/generate_playbook.py
|
||||
|
||||
# Define the prefixes for which we want individual role-include files
|
||||
INCLUDE_GROUPS := "web-" "svc-"
|
||||
|
||||
# Directory where these include-files will be written
|
||||
INCLUDES_OUT_DIR := ./tasks/groups
|
||||
|
||||
# Compute extra users as before
|
||||
EXTRA_USERS := $(shell \
|
||||
find $(ROLES_DIR) -maxdepth 1 -type d -name '*' -printf '%f\n' \
|
||||
| sed -E 's/.*-//' \
|
||||
| grep -E -x '[a-z0-9]+' \
|
||||
| sort -u \
|
||||
| paste -sd, - \
|
||||
find $(ROLES_DIR) -maxdepth 1 -type d -printf '%f\n' \
|
||||
| sed -E 's/.*-//' \
|
||||
| grep -E -x '[a-z0-9]+' \
|
||||
| sort -u \
|
||||
| paste -sd, - \
|
||||
)
|
||||
|
||||
.PHONY: build install test
|
||||
|
||||
build:
|
||||
@echo "🔧 Generating applications defaults → $(APPLICATIONS_OUT) from roles in $(ROLES_DIR)…"
|
||||
python3 $(USERS_SCRIPT) --roles-dir $(ROLES_DIR) --output $(USERS_OUT) --extra-users "$(EXTRA_USERS)"
|
||||
@echo "🔧 Generating users defaults → $(USERS_OUT)…"
|
||||
python3 $(USERS_SCRIPT) \
|
||||
--roles-dir $(ROLES_DIR) \
|
||||
--output $(USERS_OUT) \
|
||||
--extra-users "$(EXTRA_USERS)"
|
||||
@echo "✅ Users defaults written to $(USERS_OUT)\n"
|
||||
python3 $(APPLICATIONS_SCRIPT) --roles-dir $(ROLES_DIR) --output-file $(APPLICATIONS_OUT)
|
||||
|
||||
@echo "🔧 Generating applications defaults → $(APPLICATIONS_OUT)…"
|
||||
python3 $(APPLICATIONS_SCRIPT) \
|
||||
--roles-dir $(ROLES_DIR) \
|
||||
--output-file $(APPLICATIONS_OUT)
|
||||
@echo "✅ Applications defaults written to $(APPLICATIONS_OUT)\n"
|
||||
@echo "🔧 Generating users defaults → $(USERS_OUT) from roles in $(ROLES_DIR)…"
|
||||
@echo "🔧 Generating Docker role includes → $(INCLUDES_OUT)…"
|
||||
@mkdir -p $(dir $(INCLUDES_OUT))
|
||||
python3 $(INCLUDES_SCRIPT) $(ROLES_DIR) -o $(INCLUDES_OUT) \
|
||||
-p web-app \
|
||||
-p web-svc \
|
||||
-p svc-openldap \
|
||||
-p svc-rdbms-postgres \
|
||||
-p svc-rdbms-mariadb
|
||||
@echo "✅ Docker role includes written to $(INCLUDES_OUT)"
|
||||
|
||||
@echo "🔧 Generating role-include files for each group…"
|
||||
@mkdir -p $(INCLUDES_OUT_DIR)
|
||||
@$(foreach grp,$(INCLUDE_GROUPS), \
|
||||
out=$(INCLUDES_OUT_DIR)/$(grp)roles.yml; \
|
||||
echo "→ Building $$out (pattern: '$(grp)')…"; \
|
||||
python3 $(INCLUDES_SCRIPT) $(ROLES_DIR) \
|
||||
-p $(grp) -o $$out; \
|
||||
echo " ✅ $$out"; \
|
||||
)
|
||||
|
||||
install: build
|
||||
@echo "⚙️ Install complete."
|
||||
|
||||
test:
|
||||
@echo "🧪 Running Python Tests..."
|
||||
@echo "🧪 Running Python tests…"
|
||||
python -m unittest discover -s tests
|
||||
@echo "📑 Syntax Checking Ansible Playbook..."
|
||||
@echo "📑 Checking Ansible syntax…"
|
||||
ansible-playbook playbook.yml --syntax-check
|
||||
|
Reference in New Issue
Block a user