Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/sh
# Create role directory following in Ansible's best practices
# http://docs.ansible.com/playbooks_best_practices.html#directory-layout
function show_usage() {
echo "usage: $0 [<the name of role>]"
exit 0
}
if [ `uname` = "Darwin" ] ; then
REALPATH_COMMAND="realpath"
elif [ `uname` = "Linux" ] ; then
REALPATH_COMMAND="readlink -f"
else
echo "It doesn't support this OS."
exit 1
fi
EXE_DIR=`${REALPATH_COMMAND} .`
if [ -z $1 ] ; then
show_usage
fi
mkdir $1
if [ $? -gt 0 ] ; then
echo "Couldn't create directory."
exit 1
fi
cd $1
mkdir tasks
touch tasks/main.yml
mkdir handlers
touch handlers/main.yml
mkdir templates
mkdir files
mkdir vars
touch vars/main.yml
mkdir meta
touch meta/main.yml
cd ${EXE_DIR}
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.