Zookeeper salt formula first version.
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..bacd7c7
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+tests/build/
+*.swp
+*.pyc
+.ropeproject
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
new file mode 100644
index 0000000..5bd0726
--- /dev/null
+++ b/CHANGELOG.rst
@@ -0,0 +1,6 @@
+zookeeper formula
+=========================================
+
+0.1 (2015-08-22)
+
+- Initial formula setup
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..6f2b42f
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,13 @@
+Copyright (c) 2014-2015 tcp cloud a.s.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
\ No newline at end of file
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..c6a75af
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,26 @@
+DESTDIR=/
+SALTENVDIR=/usr/share/salt-formulas/env
+RECLASSDIR=/usr/share/salt-formulas/reclass
+FORMULANAME=$(shell grep name: metadata.yml|head -1|cut -d : -f 2|grep -Eo '[a-z0-9\-\_]*')
+
+all:
+ @echo "make install - Install into DESTDIR"
+ @echo "make test - Run tests"
+ @echo "make clean - Cleanup after tests run"
+
+install:
+ # Formula
+ [ -d $(DESTDIR)/$(SALTENVDIR) ] || mkdir -p $(DESTDIR)/$(SALTENVDIR)
+ cp -a $(FORMULANAME) $(DESTDIR)/$(SALTENVDIR)/
+ [ ! -d _modules ] || cp -a _modules $(DESTDIR)/$(SALTENVDIR)/
+ [ ! -d _states ] || cp -a _states $(DESTDIR)/$(SALTENVDIR)/ || true
+ # Metadata
+ [ -d $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME) ] || mkdir -p $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME)
+ cp -a metadata/service/* $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME)
+
+test:
+ [ ! -d tests ] || (cd tests; ./run_tests.sh)
+
+clean:
+ [ ! -d tests/build ] || rm -rf tests/build
+ [ ! -d build ] || rm -rf build
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..0ad9faf
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,40 @@
+
+==================================
+zookeeper
+==================================
+
+Service zookeeper description
+
+Sample pillars
+==============
+
+Single zookeeper service
+
+.. code-block:: yaml
+
+ zookeeper:
+ server:
+ enabled: true
+ members:
+ - host: ${_param:single_address}
+ id: 1
+
+Cluster zookeeper service
+
+.. code-block:: yaml
+
+ zookeeper:
+ server:
+ enabled: true
+ members:
+ - host: ${_param:cluster_node01_address}
+ id: 1
+ - host: ${_param:cluster_node02_address}
+ id: 2
+ - host: ${_param:cluster_node03_address}
+ id: 3
+
+Read more
+=========
+
+* links
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..49d5957
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+0.1
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..af9daf4
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,5 @@
+salt-formula-zookeeper (0.1) trusty; urgency=medium
+
+ * Initial release
+
+ -- marco <marek.celoud@tcpcloud.eu> Thu, 13 Aug 2015 23:23:41 +0200
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..ec63514
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+9
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..58b1bb4
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,15 @@
+Source: salt-formula-zookeeper
+Maintainer: marco <marek.celoud@tcpcloud.eu>
+Section: admin
+Priority: optional
+Build-Depends: debhelper (>= 9), salt-master, python, python-yaml
+Standards-Version: 3.9.6
+Homepage: http://www.tcpcloud.eu
+Vcs-Browser: https://github.com/tcpcloud/salt-formula-zookeeper
+Vcs-Git: https://github.com/tcpcloud/salt-formula-zookeeper.git
+
+Package: salt-formula-zookeeper
+Architecture: all
+Depends: ${misc:Depends}, salt-master, reclass
+Description: zookeeper salt formula
+ Install and configure zookeeper system.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..619963a
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,15 @@
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: salt-formula-zookeeper
+Upstream-Contact:
+Source: https://github.com/tcpcloud/salt-formula-zookeeper
+
+Files: *
+Copyright: 2014-2015 tcp cloud a.s.
+License: Apache-2.0
+ Copyright (C) 2014-2015 tcp cloud a.s.
+ .
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ .
+ On a Debian system you can find a copy of this license in
+ /usr/share/common-licenses/Apache-2.0.
diff --git a/debian/docs b/debian/docs
new file mode 100644
index 0000000..d585829
--- /dev/null
+++ b/debian/docs
@@ -0,0 +1,3 @@
+README.rst
+CHANGELOG.rst
+VERSION
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..abde6ef
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,5 @@
+#!/usr/bin/make -f
+
+%:
+ dh $@
+
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000..89ae9db
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (native)
diff --git a/doc/source/conf.py b/doc/source/conf.py
new file mode 100644
index 0000000..a42f205
--- /dev/null
+++ b/doc/source/conf.py
@@ -0,0 +1,73 @@
+# -*- coding: utf-8 -*-
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import os
+import sys
+
+sys.path.insert(0, os.path.abspath('../..'))
+# -- General configuration ----------------------------------------------------
+
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = [
+ 'sphinx.ext.autodoc',
+]
+
+# autodoc generation is a bit aggressive and a nuisance when doing heavy
+# text edit cycles.
+# execute "export SPHINX_DEBUG=1" in your terminal to disable
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'salt-formula-zookeeper'
+copyright = u'2016, tcp cloud a.s.'
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+add_module_names = True
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# -- Options for HTML output --------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. Major themes that come with
+# Sphinx are currently 'default' and 'sphinxdoc'.
+# html_theme_path = ["."]
+# html_theme = '_theme'
+# html_static_path = ['static']
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = '%sdoc' % project
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass
+# [howto/manual]).
+latex_documents = [
+ ('index',
+ '%s.tex' % project,
+ u'%s Documentation' % project,
+ u'OpenStack Foundation', 'manual'),
+]
+
+# Example configuration for intersphinx: refer to the Python standard library.
+# intersphinx_mapping = {'http://docs.python.org/': None}
diff --git a/doc/source/index.rst b/doc/source/index.rst
new file mode 100644
index 0000000..a6210d3
--- /dev/null
+++ b/doc/source/index.rst
@@ -0,0 +1 @@
+.. include:: ../../README.rst
diff --git a/metadata.yml b/metadata.yml
new file mode 100644
index 0000000..47c9cf2
--- /dev/null
+++ b/metadata.yml
@@ -0,0 +1,3 @@
+name: "zookeeper"
+version: "0.1"
+source: "https://github.com/tcpcloud/salt-formula-zookeeper"
diff --git a/metadata/service/server/cluster.yml b/metadata/service/server/cluster.yml
new file mode 100644
index 0000000..f6b7c70
--- /dev/null
+++ b/metadata/service/server/cluster.yml
@@ -0,0 +1,16 @@
+applications:
+- zookeeper
+classes:
+- service.zookeeper.support
+parameters:
+ zookeeper:
+ server:
+ enabled: true
+ id: ${_param:midonet_database_id}
+ members:
+ - host: ${_param:cluster_node01_address}
+ id: 1
+ - host: ${_param:cluster_node02_address}
+ id: 2
+ - host: ${_param:cluster_node03_address}
+ id: 3
diff --git a/metadata/service/server/single.yml b/metadata/service/server/single.yml
new file mode 100644
index 0000000..75d1680
--- /dev/null
+++ b/metadata/service/server/single.yml
@@ -0,0 +1,12 @@
+applications:
+- zookeeper
+classes:
+- service.zookeeper.support
+parameters:
+ zookeeper:
+ server:
+ enabled: true
+ id: 1
+ members:
+ - host: ${_param:single_address}
+ id: 1
\ No newline at end of file
diff --git a/metadata/service/support.yml b/metadata/service/support.yml
new file mode 100644
index 0000000..d44fa80
--- /dev/null
+++ b/metadata/service/support.yml
@@ -0,0 +1,11 @@
+parameters:
+ zookeeper:
+ _support:
+ collectd:
+ enabled: false
+ heka:
+ enabled: false
+ sensu:
+ enabled: false
+ sphinx:
+ enabled: true
diff --git a/tests/pillar/cluster.sls b/tests/pillar/cluster.sls
new file mode 100644
index 0000000..b1ce26b
--- /dev/null
+++ b/tests/pillar/cluster.sls
@@ -0,0 +1,7 @@
+zookeeper:
+ server:
+ enabled: true
+ id: 1
+ members:
+ - host: 127.0.0.1
+ id: 1
\ No newline at end of file
diff --git a/tests/pillar/single.sls b/tests/pillar/single.sls
new file mode 100644
index 0000000..6d36800
--- /dev/null
+++ b/tests/pillar/single.sls
@@ -0,0 +1,11 @@
+zookeeper:
+ server:
+ enabled: true
+ id: 1
+ members:
+ - host: 127.0.0.1
+ id: 1
+ - host: 127.0.1.1
+ id: 2
+ - host: 127.0.2.1
+ id: 3
\ No newline at end of file
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
new file mode 100755
index 0000000..3f42101
--- /dev/null
+++ b/tests/run_tests.sh
@@ -0,0 +1,162 @@
+#!/usr/bin/env bash
+
+set -e
+[ -n "$DEBUG" ] && set -x
+
+CURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+METADATA=${CURDIR}/../metadata.yml
+FORMULA_NAME=$(cat $METADATA | python -c "import sys,yaml; print yaml.load(sys.stdin)['name']")
+
+## Overrideable parameters
+PILLARDIR=${PILLARDIR:-${CURDIR}/pillar}
+BUILDDIR=${BUILDDIR:-${CURDIR}/build}
+VENV_DIR=${VENV_DIR:-${BUILDDIR}/virtualenv}
+DEPSDIR=${BUILDDIR}/deps
+
+SALT_FILE_DIR=${SALT_FILE_DIR:-${BUILDDIR}/file_root}
+SALT_PILLAR_DIR=${SALT_PILLAR_DIR:-${BUILDDIR}/pillar_root}
+SALT_CONFIG_DIR=${SALT_CONFIG_DIR:-${BUILDDIR}/salt}
+SALT_CACHE_DIR=${SALT_CACHE_DIR:-${SALT_CONFIG_DIR}/cache}
+
+SALT_OPTS="${SALT_OPTS} --retcode-passthrough --local -c ${SALT_CONFIG_DIR}"
+
+if [ "x${SALT_VERSION}" != "x" ]; then
+ PIP_SALT_VERSION="==${SALT_VERSION}"
+fi
+
+## Functions
+log_info() {
+ echo "[INFO] $*"
+}
+
+log_err() {
+ echo "[ERROR] $*" >&2
+}
+
+setup_virtualenv() {
+ log_info "Setting up Python virtualenv"
+ virtualenv $VENV_DIR
+ source ${VENV_DIR}/bin/activate
+ pip install salt${PIP_SALT_VERSION}
+}
+
+setup_pillar() {
+ [ ! -d ${SALT_PILLAR_DIR} ] && mkdir -p ${SALT_PILLAR_DIR}
+ echo "base:" > ${SALT_PILLAR_DIR}/top.sls
+ for pillar in ${PILLARDIR}/*; do
+ state_name=$(basename ${pillar%.sls})
+ echo -e " ${state_name}:\n - ${state_name}" >> ${SALT_PILLAR_DIR}/top.sls
+ done
+}
+
+setup_salt() {
+ [ ! -d ${SALT_FILE_DIR} ] && mkdir -p ${SALT_FILE_DIR}
+ [ ! -d ${SALT_CONFIG_DIR} ] && mkdir -p ${SALT_CONFIG_DIR}
+ [ ! -d ${SALT_CACHE_DIR} ] && mkdir -p ${SALT_CACHE_DIR}
+
+ echo "base:" > ${SALT_FILE_DIR}/top.sls
+ for pillar in ${PILLARDIR}/*.sls; do
+ state_name=$(basename ${pillar%.sls})
+ echo -e " ${state_name}:\n - ${FORMULA_NAME}" >> ${SALT_FILE_DIR}/top.sls
+ done
+
+ cat << EOF > ${SALT_CONFIG_DIR}/minion
+file_client: local
+cachedir: ${SALT_CACHE_DIR}
+verify_env: False
+
+file_roots:
+ base:
+ - ${SALT_FILE_DIR}
+ - ${CURDIR}/..
+ - /usr/share/salt-formulas/env
+
+pillar_roots:
+ base:
+ - ${SALT_PILLAR_DIR}
+ - ${PILLARDIR}
+EOF
+}
+
+fetch_dependency() {
+ dep_name="$(echo $1|cut -d : -f 1)"
+ dep_source="$(echo $1|cut -d : -f 2-)"
+ dep_root="${DEPSDIR}/$(basename $dep_source .git)"
+ dep_metadata="${dep_root}/metadata.yml"
+
+ [ -d /usr/share/salt-formulas/env/${dep_name} ] && log_info "Dependency $dep_name already present in system-wide salt env" && return 0
+ [ -d $dep_root ] && log_info "Dependency $dep_name already fetched" && return 0
+
+ log_info "Fetching dependency $dep_name"
+ [ ! -d ${DEPSDIR} ] && mkdir -p ${DEPSDIR}
+ git clone $dep_source ${DEPSDIR}/$(basename $dep_source .git)
+ ln -s ${dep_root}/${dep_name} ${SALT_FILE_DIR}/${dep_name}
+
+ METADATA="${dep_metadata}" install_dependencies
+}
+
+install_dependencies() {
+ grep -E "^dependencies:" ${METADATA} >/dev/null || return 0
+ (python - | while read dep; do fetch_dependency "$dep"; done) << EOF
+import sys,yaml
+for dep in yaml.load(open('${METADATA}', 'ro'))['dependencies']:
+ print '%s:%s' % (dep["name"], dep["source"])
+EOF
+}
+
+clean() {
+ log_info "Cleaning up ${BUILDDIR}"
+ [ -d ${BUILDDIR} ] && rm -rf ${BUILDDIR} || exit 0
+}
+
+salt_run() {
+ [ -e ${VEN_DIR}/bin/activate ] && source ${VENV_DIR}/bin/activate
+ salt-call ${SALT_OPTS} $*
+}
+
+prepare() {
+ [ -d ${BUILDDIR} ] && mkdir -p ${BUILDDIR}
+
+ which salt-call || setup_virtualenv
+ setup_pillar
+ setup_salt
+ install_dependencies
+}
+
+run() {
+ for pillar in ${PILLARDIR}/*.sls; do
+ state_name=$(basename ${pillar%.sls})
+ salt_run --id=${state_name} state.show_sls ${FORMULA_NAME} || (log_err "Execution of ${FORMULA_NAME}.${state_name} failed"; exit 1)
+ done
+}
+
+_atexit() {
+ RETVAL=$?
+ trap true INT TERM EXIT
+
+ if [ $RETVAL -ne 0 ]; then
+ log_err "Execution failed"
+ else
+ log_info "Execution successful"
+ fi
+ return $RETVAL
+}
+
+## Main
+trap _atexit INT TERM EXIT
+
+case $1 in
+ clean)
+ clean
+ ;;
+ prepare)
+ prepare
+ ;;
+ run)
+ run
+ ;;
+ *)
+ prepare
+ run
+ ;;
+esac
diff --git a/zookeeper/files/entrypoint.sh b/zookeeper/files/entrypoint.sh
new file mode 100644
index 0000000..06a31f1
--- /dev/null
+++ b/zookeeper/files/entrypoint.sh
@@ -0,0 +1,17 @@
+{%- from "zookeeper/map.jinja" import server with context %}
+#!/bin/bash -e
+
+cat /srv/salt/pillar/server.sls | envsubst > /tmp/server.sls
+mv /tmp/server.sls /srv/salt/pillar/server.sls
+
+salt-call --local --retcode-passthrough state.highstate
+
+{% for service in control.services %}
+service {{ service }} stop || true
+{% endfor %}
+
+/usr/bin/java -cp /etc/zookeeper/conf:/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 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false -Dzookeeper.log.dir=/var/log/zookeeper -Dzookeeper.root.logger=INFO,ROLLINGFILE org.apache.zookeeper.server.quorum.QuorumPeerMain /etc/zookeeper/conf/zoo.cfg
+
+{#-
+vim: syntax=jinja
+-#}
\ No newline at end of file
diff --git a/zookeeper/files/zoo.cfg b/zookeeper/files/zoo.cfg
new file mode 100644
index 0000000..7218c09
--- /dev/null
+++ b/zookeeper/files/zoo.cfg
@@ -0,0 +1,61 @@
+{%- from "zookeeper/map.jinja" import server with context %}
+# http://hadoop.apache.org/zookeeper/docs/current/zookeeperAdmin.html
+
+# The number of milliseconds of each tick
+tickTime=2000
+# The number of ticks that the initial
+# synchronization phase can take
+initLimit=10
+# The number of ticks that can pass between
+# sending a request and getting an acknowledgement
+syncLimit=5
+# the directory where the snapshot is stored.
+dataDir=/var/lib/zookeeper
+# Place the dataLogDir to a separate physical disc for better performance
+# dataLogDir=/disk2/zookeeper
+
+# the port at which the clients will connect
+clientPort=2181
+
+# specify all zookeeper servers
+# The fist port is used by followers to connect to the leader
+# The second one is used for leader election
+#server.1=zookeeper1:2888:3888
+#server.2=zookeeper2:2888:3888
+#server.3=zookeeper3:2888:3888
+
+
+# To avoid seeks ZooKeeper allocates space in the transaction log file in
+# blocks of preAllocSize kilobytes. The default block size is 64M. One reason
+# for changing the size of the blocks is to reduce the block size if snapshots
+# are taken more often. (Also, see snapCount).
+#preAllocSize=65536
+
+# Clients can submit requests faster than ZooKeeper can process them,
+# especially if there are a lot of clients. To prevent ZooKeeper from running
+# out of memory due to queued requests, ZooKeeper will throttle clients so that
+# there is no more than globalOutstandingLimit outstanding requests in the
+# system. The default limit is 1,000.ZooKeeper logs transactions to a
+# transaction log. After snapCount transactions are written to a log file a
+# snapshot is started and a new transaction log file is started. The default
+# snapCount is 10,000.
+#snapCount=1000
+
+# If this option is defined, requests will be will logged to a trace file named
+# traceFile.year.month.day.
+#traceFile=
+
+# Leader accepts client connections. Default value is "yes". The leader machine
+# coordinates updates. For higher update throughput at thes slight expense of
+# read throughput the leader can be configured to not accept clients and focus
+# on coordination.
+#leaderServes=yes
+
+maxSessionTimeout=120000
+autopurge.purgeInterval=3
+{%- for member in server.members %}
+server.{{ member.id }}={{ member.host }}:2888:3888
+{%- endfor %}
+#server.1=10.0.222.2:2888:3888
+#server.2=10.0.222.3:2888:3888
+#server.3=10.0.222.4:2888:3888
\ No newline at end of file
diff --git a/zookeeper/init.sls b/zookeeper/init.sls
new file mode 100644
index 0000000..9f86cdc
--- /dev/null
+++ b/zookeeper/init.sls
@@ -0,0 +1,6 @@
+{%- if pillar.zookeeper is defined %}
+include:
+{%- if pillar.zookeeper.server is defined %}
+- zookeeper.server
+{%- endif %}
+{%- endif %}
diff --git a/zookeeper/map.jinja b/zookeeper/map.jinja
new file mode 100644
index 0000000..f34745c
--- /dev/null
+++ b/zookeeper/map.jinja
@@ -0,0 +1,23 @@
+
+{%- set source_engine = salt['pillar.get']('zookeeper:server:source:engine') %}
+
+{%- load_yaml as base_defaults %}
+Debian:
+ pkgs:
+ - zookeeper
+ - zookeeperd
+ dir:
+ base: /usr/lib/zookeeper
+ services:
+ - zookeeper
+RedHat:
+ pkgs:
+ - zookeeper
+ - zookeeperd
+ dir:
+ base: /usr/lib/zookeeper
+ services:
+ - zookeeper
+{%- endload %}
+
+{%- set server = salt['grains.filter_by'](base_defaults, merge=salt['pillar.get']('zookeeper:server')) %}
\ No newline at end of file
diff --git a/zookeeper/meta/sensu.yml b/zookeeper/meta/sensu.yml
new file mode 100644
index 0000000..adef7d6
--- /dev/null
+++ b/zookeeper/meta/sensu.yml
@@ -0,0 +1,8 @@
+# Sample check
+check:
+ local_zookeeper_proc:
+ command: "PATH=$PATH:/usr/lib64/nagios/plugins:/usr/lib/nagios/plugins check_procs -C zookeeper -u zookeeper -c 1:1"
+ interval: 60
+ occurrences: 1
+ subscribers:
+ - local-zookeeper-server
diff --git a/zookeeper/meta/sphinx.yml b/zookeeper/meta/sphinx.yml
new file mode 100644
index 0000000..6b3ae37
--- /dev/null
+++ b/zookeeper/meta/sphinx.yml
@@ -0,0 +1,12 @@
+{%- from "zookeeper/map.jinja" import server with context %}
+# Fill in documentation details
+doc:
+ name: zookeeper
+ description: Some service info
+ role:
+ server:
+ name: server
+ param:
+ some_param:
+ name: "Some name"
+ value: "some value"
diff --git a/zookeeper/server.sls b/zookeeper/server.sls
new file mode 100644
index 0000000..1e858f8
--- /dev/null
+++ b/zookeeper/server.sls
@@ -0,0 +1,37 @@
+{%- from "zookeeper/map.jinja" import server with context %}
+{%- if server.enabled %}
+
+zookeeper_server_packages:
+ pkg.installed:
+ - names: {{ server.pkgs }}
+
+/etc/zookeeper/conf/zoo.cfg:
+ file.managed:
+ - source: salt://zookeeper/files/zoo.cfg
+ - template: jinja
+ - require:
+ - pkg: zookeeper_server_packages
+
+/var/lib/zookeeper/myid:
+ file.managed:
+ - contents: '{{ database.id }}'
+
+zookeeper_server_services:
+ service.running:
+ - names: {{ server.services }}
+ - enable: true
+ - watch:
+ - file: /etc/zookeeper/conf/zoo.cfg
+
+{%- if grains.get('virtual_subtype', None) == "Docker" %}
+
+zookeeper_entrypoint:
+ file.managed:
+ - name: /entrypoint.sh
+ - template: jinja
+ - source: salt://zookeeper/files/entrypoint.sh
+ - mode: 755
+
+{%- endif %}
+
+{%- endif %}