Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix service settings when installing from archive #92

Merged
merged 1 commit into from
Mar 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@

it do
is_expected.to contain_file('/etc/zookeeper/conf/environment').with_content(/ERROR/)
is_expected.to contain_file('/etc/zookeeper/conf/environment').with_content(/CLASSPATH/)
end

it do
Expand All @@ -84,6 +85,18 @@
end
end

context 'install from archive' do
let :pre_condition do
'class {"zookeeper":
install_method: "archive",
archive_version: "3.4.9",
}'

it {is_expected.to contain_file('/etc/zookeeper/conf/environment').without_content(/CLASSPATH/)}

end
end

context 'extra environment_file parameter' do
# set custom params
let :pre_condition do
Expand Down
24 changes: 24 additions & 0 deletions spec/classes/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@
})
end

it do
should contain_file(
'/usr/lib/systemd/system/zookeeper-server.service'
).with_content(/zookeeper\.jar/)
end

it do
should contain_service('zookeeper-server').with(
:ensure => 'running',
Expand Down Expand Up @@ -92,6 +98,24 @@
end
end

context 'install from archive' do
let :pre_condition do
'class {"zookeeper":
manage_service_file => true,
service_provider => "systemd",
install_method => "archive",
archive_version => "3.4.9"
}'
end

it do
should contain_file(
'/usr/lib/systemd/system/zookeeper-server.service'
).with_content(/zookeeper-3\.4\.9\.jar/)
end

end

context 'do not manage systemd' do
let :pre_condition do
'class {"zookeeper":
Expand Down
2 changes: 2 additions & 0 deletions templates/conf/environment.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
NAME=zookeeper
ZOOCFGDIR=<%= scope.lookupvar("zookeeper::cfg_dir") %>

<% if scope.lookupvar('zookeeper::install_method') != 'archive' -%>
# TODO this is really ugly
# How to find out, which jars are needed?
# seems, that log4j requires the log4j.properties file to be in the classpath
CLASSPATH="$ZOOCFGDIR:/usr/share/java/jline.jar:/usr/share/java/log4j-1.2.jar:/usr/share/java/xercesImpl.jar:/usr/share/java/xmlParserAPIs.jar:/usr/share/java/netty.jar:/usr/share/java/slf4j-api.jar:/usr/share/java/slf4j-log4j12.jar:/usr/share/java/zookeeper.jar"
<% end -%>

#ZOOCFG="zoo.cfg"
# necessary on Debian
Expand Down
7 changes: 6 additions & 1 deletion templates/zookeeper.service.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ After=<%= scope.lookupvar("zookeeper::systemd_unit_after") %>
<% end -%>

[Service]
ExecStart=/bin/sh -c 'set -x; . <%= scope.lookupvar("zookeeper::cfg_dir") %>/<%= scope.lookupvar("zookeeper::environment_file") %>; CLASSPATH="<%= @_zoo_dir %>/zookeeper.jar:<%= @_zoo_dir %>/lib/*:$CLASSPATH"; CLASSPATH="$(. <%= scope.lookupvar("zookeeper::service::_zoo_dir") %>/bin/zkEnv.sh ; echo $CLASSPATH)"; mkdir -p <%= scope.lookupvar("zookeeper::log_dir") %>; $JAVA "-Dzookeeper.log.dir=<%= scope.lookupvar("zookeeper::log_dir") %>" "-Dzookeeper.root.logger=$ZOO_LOG4J_PROP" -cp "$CLASSPATH" $JAVA_OPTS "$ZOOMAIN" "$ZOOCFG"'
ExecStart=/bin/sh -c 'set -x; \
. <%= scope.lookupvar("zookeeper::cfg_dir") %>/<%= scope.lookupvar("zookeeper::environment_file") %>; \
CLASSPATH="<%= @_zoo_dir %>/zookeeper<% if scope.lookupvar('zookeeper::install_method') == 'archive' -%>-<%= scope.lookupvar("zookeeper::archive_version") %><% end -%>.jar:<%= @_zoo_dir %>/lib/*:$CLASSPATH"; \
CLASSPATH="$(. <%= scope.lookupvar("zookeeper::service::_zoo_dir") %>/bin/zkEnv.sh ; echo $CLASSPATH)"; \
mkdir -p <%= scope.lookupvar("zookeeper::log_dir") %>; \
$JAVA "-Dzookeeper.log.dir=<%= scope.lookupvar("zookeeper::log_dir") %>" "-Dzookeeper.root.logger=$ZOO_LOG4J_PROP" -cp "$CLASSPATH" $JAVA_OPTS "$ZOOMAIN" "$ZOOCFG"'
Restart=always
RemainAfterExit=no
SyslogIdentifier=zookeeper
Expand Down