Create script dir and add new role templater
This commit is contained in:
parent
d89e1221fd
commit
ef1c412012
3 changed files with 22 additions and 1 deletions
4
Makefile
4
Makefile
|
@ -62,5 +62,7 @@ all:
|
||||||
$(MAKE) visualize
|
$(MAKE) visualize
|
||||||
|
|
||||||
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
19
scripts/new_role.sh
Executable 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
|
Loading…
Add table
Add a link
Reference in a new issue