From ef1c412012dab0cb6df2a6e3ff198bb85cd5cd4f Mon Sep 17 00:00:00 2001 From: Tobias Reisinger <tobias@msrg.cc> Date: Wed, 16 Apr 2025 01:57:07 +0200 Subject: [PATCH] Create script dir and add new role templater --- Makefile | 4 +++- scripts/new_role.sh | 19 +++++++++++++++++++ visualize.py => scripts/visualize.py | 0 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100755 scripts/new_role.sh rename visualize.py => scripts/visualize.py (100%) diff --git a/Makefile b/Makefile index 79a5ac5..493533d 100644 --- a/Makefile +++ b/Makefile @@ -62,5 +62,7 @@ all: $(MAKE) visualize visualize: - ./visualize.py | d2 - infrastructure.svg + ./scripts/visualize.py | d2 - infrastructure.svg +new_role: + ./scripts/new_role.sh diff --git a/scripts/new_role.sh b/scripts/new_role.sh new file mode 100755 index 0000000..bad2558 --- /dev/null +++ b/scripts/new_role.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +roles_dir="./playbooks/roles" + +read -p "Enter the new role name: " new_role + +if [ -z "$new_role" ]; then + echo "Usage: $0 <role_name>" + exit 1 +fi + +if [ -d "$roles_dir/$new_role" ]; then + echo "Role $new_role already exists." + exit 1 +fi + +cp -r "$roles_dir/_TEMPLATE" "$roles_dir/$new_role" + +sed -i "s/NAME_/${new_role}_/g" "$roles_dir/$new_role"/**/*.yml diff --git a/visualize.py b/scripts/visualize.py similarity index 100% rename from visualize.py rename to scripts/visualize.py