Create script dir and add new role templater

This commit is contained in:
Tobias Reisinger 2025-04-16 01:57:07 +02:00
parent d89e1221fd
commit ef1c412012
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
3 changed files with 22 additions and 1 deletions

View file

@ -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

19
scripts/new_role.sh Executable file
View file

@ -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