Add custom systemd unit for Zookeeper

We're 100% systemd here, and the lack of control/information that the
old-school ZK initscript provides is frustrating. Replace it with our
own simple unit file.
This commit is contained in:
Joshua Boniface 2023-09-01 15:42:21 -04:00
parent 7e74ce2ede
commit 15a2bf1418
2 changed files with 35 additions and 2 deletions

View File

@ -2,7 +2,7 @@
- name: install zookeeper packages - name: install zookeeper packages
apt: apt:
name: name:
- zookeeperd - zookeeper
- zookeeper-bin - zookeeper-bin
state: latest state: latest
@ -18,7 +18,17 @@
- zoo.cfg - zoo.cfg
notify: restart zookeeper notify: restart zookeeper
- name: start but disable services - name: install systemd unit file
template:
src: zookeeper/zookeeper.service.j2
dest: /etc/systemd/system/zookeeper.service
register: systemd
- name: reload systemd to apply changes
command: systemctl daemon-reload
when: systemd.changed
- name: start but disable services (managed by PVC)
service: service:
name: "{{ item }}" name: "{{ item }}"
state: started state: started

View File

@ -0,0 +1,23 @@
# Zookeeper unit - replaces zookeeperd package/initscript
# {{ ansible_managed }}
[Unit]
Description = Zookeeper centralized coordination service
After = remote-fs.target network.target
AssertPathExists = /var/lib/zookeeper
[Service]
Type = simple
User = zookeeper
Group = zookeeper
EnvironmentFile = -/etc/zookeeper/conf/environment
EnvironmentFile = -/etc/default/zookeeper
ExecStart = /usr/bin/java \
-cp $CLASSPATH \
$JAVA_OPTS \
-Dzookeeper.log.dir=${ZOO_LOG_DIR} \
-Dzookeeper.root.logger=${ZOO_LOG4J_PROP} \
$ZOOMAIN $ZOOCFG
[Install]
WantedBy = multi-user.target