2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AnsibleのRoleテンプレート作成スクリプト

Last updated at Posted at 2014-09-18

使い方はこんな感じ

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

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?