2016-03-02 17:52:19 +08:00
|
|
|
#!/usr/bin/env bash
|
2016-02-29 23:35:07 +08:00
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
basedir=$(dirname "$0")
|
|
|
|
|
|
|
|
for role in "$basedir"/roles/ceph-*; do
|
2016-03-02 17:52:19 +08:00
|
|
|
rolename=$(basename "$role")
|
|
|
|
if [[ $rolename == "ceph-common" ]]; then
|
2016-11-23 18:14:32 +08:00
|
|
|
output="all.yml.sample"
|
2016-03-02 17:52:19 +08:00
|
|
|
elif [[ $rolename == "ceph-agent" ]]; then
|
2016-11-23 18:14:32 +08:00
|
|
|
output="agent.yml.sample"
|
2016-03-02 17:52:19 +08:00
|
|
|
elif [[ $rolename == "ceph-fetch-keys" ]]; then
|
2016-11-23 18:14:32 +08:00
|
|
|
output="ceph-fetch-keys.yml.sample"
|
2016-03-02 17:52:19 +08:00
|
|
|
else
|
2016-11-23 18:14:32 +08:00
|
|
|
output="${rolename:5}s.yml.sample"
|
2016-03-02 17:52:19 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
cat <<EOF > "$basedir"/group_vars/"$output"
|
2016-02-29 23:35:07 +08:00
|
|
|
---
|
|
|
|
# Variables here are applicable to all host groups NOT roles
|
|
|
|
|
|
|
|
# This sample file generated by $(basename "$0")
|
|
|
|
|
|
|
|
# Dummy variable to avoid error because ansible does not recognize the
|
|
|
|
# file as a good configuration file when no variable in it.
|
|
|
|
dummy:
|
|
|
|
|
|
|
|
EOF
|
2016-03-02 17:52:19 +08:00
|
|
|
defaults="$role"/defaults/main.yml
|
|
|
|
if [[ ! -f $defaults ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
2016-02-29 23:35:07 +08:00
|
|
|
|
2016-03-02 17:52:19 +08:00
|
|
|
if [ "$(uname)" == "Darwin" ]; then
|
|
|
|
sed '/^---/d; s/^\([A-Za-z[:space:]]\)/#\1/' \
|
|
|
|
"$defaults" >> "$basedir"/group_vars/"$output"
|
|
|
|
echo >> "$basedir"/group_vars/"$output"
|
|
|
|
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
|
2016-02-29 23:35:07 +08:00
|
|
|
sed '/^---/d; s/^\([A-Za-z[:space:]].\+\)/#\1/' \
|
|
|
|
"$defaults" >> "$basedir"/group_vars/"$output"
|
|
|
|
echo >> "$basedir"/group_vars/"$output"
|
2016-03-02 17:52:19 +08:00
|
|
|
else
|
|
|
|
echo "Unsupported platform"
|
|
|
|
exit 1
|
|
|
|
fi
|
2016-02-29 23:35:07 +08:00
|
|
|
done
|