101 lines
2.1 KiB
Puppet
101 lines
2.1 KiB
Puppet
#
|
|
# zookeeper.pp
|
|
#
|
|
|
|
|
|
class plnxtools::zookeeper
|
|
(
|
|
$appname = "zookeeper",
|
|
$zookeeper_logdir = "$::plnxtools::params::logdir/$appname"
|
|
|
|
) inherits plnxtools::params
|
|
{
|
|
plnxtools::install{"zookeeper":
|
|
sourcedir => $zookeeper_sourcedir,
|
|
distfile => $zookeeper_distfile,
|
|
dirname => $zookeeper_dirname,
|
|
} ->
|
|
file {"$zookeeper_instances":
|
|
ensure => directory
|
|
}
|
|
file {"$zookeeper_logdir":
|
|
ensure => directory
|
|
}
|
|
}
|
|
|
|
|
|
define plnxtools::zookeeper::instancedir
|
|
( $dirname,
|
|
$log_file)
|
|
{
|
|
file{"$dirname/$title":
|
|
ensure => directory
|
|
} ->
|
|
file{"$dirname/$title/conf":
|
|
ensure => directory
|
|
} ->
|
|
file{"$dirname/$title/log":
|
|
ensure => directory
|
|
} ->
|
|
file{"$dirname/$title/run":
|
|
ensure => directory
|
|
} ->
|
|
file{"$dirname/$title/data":
|
|
ensure => directory
|
|
}
|
|
file{"$dirname/$title/conf/log4j.properties":
|
|
ensure => file,
|
|
content => template ("plnxtools/log4j.properties.erb"),
|
|
}
|
|
}
|
|
|
|
define plnxtools::zookeeper::instance(
|
|
$ensure = running,
|
|
|
|
$servers = {
|
|
'1' => "localhost:2888:3888"
|
|
},
|
|
|
|
$myid = '1',
|
|
$client_port = '2181'
|
|
|
|
|
|
) {
|
|
$zookeeper_instances = $plnxtools::zookeeper::zookeeper_instances
|
|
if $ensure != purged {
|
|
$log_file = "$plnxtools::zookeeper::zookeeper_logdir/$title.log"
|
|
$conf_dir = "$zookeeper_instances/$title/conf"
|
|
$conf_file = "$conf_dir/zoo.cfg"
|
|
$data_dir = "$zookeeper_instances/$title/data"
|
|
$myid_file = "$data_dir/myid"
|
|
$bin_dir = "${plnxtools::zookeeper::opt_dir}/${plnxtools::zookeeper::appname}/bin"
|
|
|
|
plnxtools::zookeeper::instancedir {"$title":
|
|
dirname => $zookeeper_instances,
|
|
log_file => $log_file,
|
|
|
|
} ->
|
|
file {$conf_file:
|
|
ensure => file,
|
|
content => template("plnxtools/zookeeper/zoo.cfg.erb"),
|
|
}->
|
|
file {$myid_file:
|
|
ensure => file,
|
|
content => $myid
|
|
}
|
|
service {"zookeeper_${title}":
|
|
start => "$bin_dir/zkServer.sh --config $conf_dir start",
|
|
stop => "$bin_dir/zkServer.sh --config $conf_dir stop",
|
|
status => "/bin/kill -0 `cat $data_dir/zookeeper_server.pid`",
|
|
ensure => $ensure,
|
|
subscribe => File[$conf_file],
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|