-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsite.pp
58 lines (54 loc) · 1.04 KB
/
site.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Linux required -i'', not "-i ''" for inplace
os=$( uname -s )
case "${os}" in
Linux)
# Linux require -i'', not -i ' '
sed_delimer=
;;
FreeBSD)
sed_delimer=" "
;;
esac
generate_manifest()
{
cat <<EOF
class { 'timezone': }
class { 'loginconf': }
class { 'mailalias': }
class { 'redmine': }
EOF
}
generate_hieradata()
{
local my_common_yaml="${my_module_dir}/common.yaml"
local _val _tpl
if [ -f "${my_common_yaml}" ]; then
local tmp_common_yaml=$( mktemp )
trap "/bin/rm -f ${tmp_common_yaml}" HUP INT ABRT BUS TERM EXIT
/bin/cp ${my_common_yaml} ${tmp_common_yaml}
for i in ${param}; do
case "${i}" in
-*)
# delimier params
continue
;;
Expand)
# delimier params
continue
;;
esac
eval _val=\${${i}}
_tpl="#${i}#"
# Note that on Linux systems, a space after -i might cause an error
sed -i${sed_delimer}'' -Ees:"${_tpl}":"${_val}":g ${tmp_common_yaml}
done
cat ${tmp_common_yaml}
else
for i in ${param}; do
eval _val=\${${i}}
cat <<EOF
$i: "${_val}"
EOF
done
fi
}