Merge pull request #392 from telmich/type_consul_agent_debian

Debian Support for __consul_agent
remotes/origin/3.1
Steven Armstrong 10 years ago
commit c2aa601424
  1. 76
      cdist/conf/type/__consul_agent/files/consul.sysv-debian
  2. 0
      cdist/conf/type/__consul_agent/files/consul.sysv-redhat
  3. 72
      cdist/conf/type/__consul_agent/manifest
  4. 1
      docs/changelog

@ -0,0 +1,76 @@
#!/bin/sh
#
# 2015 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
# cdist is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cdist is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
if [ -f "/etc/default/consul" ]; then
. /etc/default/consul
fi
. /lib/lsb/init-functions
NAME=consul
CONSUL=/usr/local/bin/consul
CONFIG=/etc/$NAME/conf.d
PID_FILE=/var/run/$NAME/pidfile
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
case "$1" in
start)
log_daemon_msg "Starting consul agent" "consul" || true
if start-stop-daemon --start --quiet --oknodo \
--pidfile "$PID_FILE" --background \
--exec $CONSUL -- agent -pid-file="$PID_FILE" -config-dir "$CONFIG"; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
stop)
log_daemon_msg "Stopping consul agent" "consul" || true
if start-stop-daemon --stop --quiet --oknodo --pidfile $PID_FILE; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
reload)
log_daemon_msg "Reloading consul agent" "consul" || true
if start-stop-daemon --stop --signal HUP --quiet --oknodo --pidfile $PID_FILE --exec $CONSUL; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
restart)
$0 stop && $0 start
;;
status)
status_of_proc -p $PID_FILE $CONSUL consul && exit 0 || exit $?
;;
*)
log_action_msg "Usage: /etc/init.d/consul {start|stop|reload|restart|status}"
exit 1
;;
esac

@ -1,6 +1,7 @@
#!/bin/sh
#
# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
# 2015 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@ -22,7 +23,7 @@
os=$(cat "$__global/explorer/os")
case "$os" in
centos|redhat|ubuntu)
centos|debian|redhat|ubuntu)
# whitelist safeguard
:
;;
@ -139,6 +140,32 @@ require="__directory${conf_dir}" \
--onchange 'service consul status >/dev/null && service consul reload || true' \
--source -
init_sysvinit()
{
__file /etc/init.d/consul \
--owner root --group root --mode 0755 \
--state "$state" \
--source "$__type/files/consul.sysv-$1"
require="__file/etc/init.d/consul" __start_on_boot consul
}
init_systemd()
{
__file /lib/systemd/system/consul.service \
--owner root --group root --mode 0644 \
--state "$state" \
--source "$__type/files/consul.systemd"
require="__file/lib/systemd/system/consul.service" __start_on_boot consul
}
init_upstart()
{
__file /etc/init/consul.conf \
--owner root --group root --mode 0644 \
--state "$state" \
--source "$__type/files/consul.upstart"
require="__file/etc/init/consul.conf" __start_on_boot consul
}
# Install init script to start on boot
case "$os" in
@ -146,29 +173,38 @@ case "$os" in
os_version="$(sed 's/[^0-9.]//g' "$__global/explorer/os_version")"
major_version="${os_version%%.*}"
case "$major_version" in
[456])
init_sysvinit redhat
;;
7)
__file /lib/systemd/system/consul.service \
--owner root --group root --mode 0555 \
--state "$state" \
--source "$__type/files/consul.systemd"
export require="__file/lib/systemd/system/consul.service"
init_systemd
;;
*)
__file /etc/init.d/consul \
--owner root --group root --mode 0555 \
--state "$state" \
--source "$__type/files/consul.sysv"
export require="__file/etc/init.d/consul"
echo "Unsupported CentOS/Redhat version: $os_version" >&2
exit 1
;;
esac
__start_on_boot consul --state "$state"
;;
debian)
os_version=$(cat "$__global/explorer/os_version")
major_version="${os_version%%.*}"
case "$major_version" in
[567])
init_sysvinit debian
;;
8)
init_sysvinit
;;
*)
echo "Unsupported Debian version $os_version" >&2
exit 1
;;
esac
;;
ubuntu)
__file /etc/init/consul.conf \
--owner root --group root --mode 0644 \
--state "$state" \
--source "$__type/files/consul.upstart"
export require="__file/etc/init/consul.conf"
__start_on_boot consul --state "$state"
init_upstart
;;
esac

@ -4,6 +4,7 @@ Changelog
next:
* New type: __firewalld_rule (Nico Schottelius)
* Type __consul_agent: add support for acl options (Steven Armstrong)
* Core: Support object ids '.cdist' (Nico Schottelius)
3.1.11: 2015-02-27
* New type: __staged_file: Manage staged files (Steven Armstrong)

Loading…
Cancel
Save