目标:
分别定义 parameter template 文件
利用 shell 直接一次性替换 template 中变量
parameter 文件
cephuuid=c45b752d-5d4d-4d3a-a3b2-04e73eff4ccd
cephmonhost=hh-ceph-128040,hh-ceph-128214,hh-ceph-128215
cephmonipaddr=10.199.128.40,10.199.128.214,10.199.128.215
cephmonnetwork=10.199.128.0/22
cephdatanetwork=240.30.128.0/21
cephpgnum=1024
cephpgpnum=1024
template 文件
[global]
fsid = $cephuuid
mon initial members = $cephmonhost
mon host = $cephmonipaddr
public network = $cephmonnetwork
cluster network = $cephdatanetwork
auth cluster required = cephx
auth service required = cephx
auth client required = cephx
osd journal size = 2048
filestore xattr use omap = true
osd pool default size = 3
osd pool default min size = 1
osd pool default pg num = $cephpgnum
osd pool default pgp num = $cephpgpnum
osd crush chooseleaf type = 1
执行方法
#!/bin/bash
source parameter
eval "cat <<EOF
$(<ceph.conf.template)
EOF
" 2> /dev/null
结果
[root@hh-ceph-128040 ceph]# . gen_ceph_conf.sh
[global]
fsid = c45b752d-5d4d-4d3a-a3b2-04e73eff4ccd
mon initial members = hh-ceph-128040,hh-ceph-128214,hh-ceph-128215
mon host = 10.199.128.40,10.199.128.214,10.199.128.215
public network = 10.199.128.0/22
cluster network = 240.30.128.0/21
auth cluster required = cephx
auth service required = cephx
auth client required = cephx
osd journal size = 2048
filestore xattr use omap = true
osd pool default size = 3
osd pool default min size = 1
osd pool default pg num = 1024
osd pool default pgp num = 1024
osd crush chooseleaf type = 1