mkansibleroledirs.sh (757B)
1 #!/bin/sh 2 3 echo "Make sure you stand in your Ansible roles directory before running" 4 5 dir=$(pwd) 6 7 echo "Is this the correct directory?" "$dir" "[Y/n]" 8 read -r ans 9 10 [ "$ans" = n ] || [ "$ans" = N ] && exit 11 12 echo "What should the new role be called?" 13 read -r rolename 14 15 DIRS="tasks handlers templates files vars defaults meta" 16 17 for i in ${DIRS}; do 18 echo "$dir/$rolename/$i"; 19 done 20 21 [ -e "$dir/$rolename" ] && echo "This directory already exist, OVERWRITE? [y/N]" && read -r ans 22 23 [ -e "$dir/$rolename" ] && [ "$ans" != y ] && [ "$ans" != Y ] && exit 24 25 for i in ${DIRS}; do 26 mkdir -p "$dir/$rolename/$i"; 27 done 28 29 YMLDIRS="tasks handlers vars defaults meta" 30 mainymlcontent="---\n" 31 32 for i in ${YMLDIRS}; do 33 echo $mainymlcontent >> "$dir/$rolename/$i/main.yml"; 34 done