使い方はこんな感じ
ansible-add-role myrole
ansible-add-role
#!/bin/bash
role_name=$1
main_yml_dirs="tasks handlers vars meta defaults"
dirs="${main_yml_dirs} templates files"
if [ -z $role_name ] ; then
echo "Usage: $0 role_name"
exit 1
fi
for dir in ${dirs}
do
if [ ! -d roles/${role_name}/${dir} ] ; then
mkdir -p roles/${role_name}/${dir}
touch roles/${role_name}/${dir}/.gitkeep
echo "+roles/${role_name}/${dir}"
fi
done
for dir in ${main_yml_dirs}
do
if [ ! -f roles/${role_name}/${dir}/main.yml ] ;then
cat >roles/${role_name}/${dir}/main.yml <<EOF
---
EOF
echo "+roles/${role_name}/${dir}/main.yml"
fi
done