This commit is contained in:
Gavin Hamill 2015-01-23 13:51:18 +00:00
Родитель 2ee1a06add
Коммит 6523b743ed
12 изменённых файлов: 116 добавлений и 252 удалений

Просмотреть файл

@ -1,12 +0,0 @@
version '0.0.1'
source 'https://github.com/gdhbashton/puppet-consul-template'
author 'Gavin Hamill <gdh@bashton.com>'
license 'Apache License, Version 2.0'
summary 'Configures Consul Template by Hashicorp'
description 'Configures Consul Template by Hashicorp'
project_page 'https://github.com/solarkennedy/puppet-consul'
dependency 'puppetlabs/stdlib', '>= 0.1.6'
dependency 'nanliu/staging', '>=0.4.0'
dependency 'puppetlabs/concat', '>=1.1.0'

Просмотреть файл

@ -90,14 +90,6 @@ class consul_template::install {
content => template('consul_template/consul-template.sles.erb')
}
}
'launchd' : {
file { '/Library/LaunchDaemons/io.consul-template.daemon.plist':
mode => '0644',
owner => 'root',
group => 'wheel',
content => template('consul_template/consul-template.launchd.erb')
}
}
default : {
fail("I don't know how to create an init script for style ${consul_template::init_style}")
}

Просмотреть файл

@ -33,8 +33,6 @@ class consul_template::params {
default => 'systemd',
},
'Debian' => 'debian',
'SLES' => 'sles',
'Darwin' => 'launchd',
default => undef
}
}

Просмотреть файл

@ -6,12 +6,9 @@
class consul_template::run_service {
service { 'consul-template':
name => $consul_template::init_style ? {
'launchd' => 'io.consul-template.daemon',
default => 'consul-template'
},
ensure => $consul_template::service_ensure,
enable => $consul_template::service_enable,
name => 'consul-template',
}
}

21
metadata.json Normal file
Просмотреть файл

@ -0,0 +1,21 @@
{
"name": "gdhbashton-consul_template",
"version": "0.1.0",
"author": "Gavin Hamill <gdh@bashton.com>",
"license": "Apache-2.0",
"summary": "Install and manage Consul Template and its jobs",
"source": "https://github.com/gdhbashton/puppet-consul_template",
"project_page": "https://github.com/gdhbashton/puppet-consul_template",
"issues_url": "https://github.com/gdhbashton/puppet-consul_template/issues",
"operatingsystem_support": [
{
"operatingsystem":"RedHat",
"operatingsystemrelease":[ "5.0", "6.0", "7.0" ]
}
],
"dependencies": [
{ "name": "puppetlabs/stdlib", "version_requirement": ">=1.0.0" },
{ "name": "puppetlabs/concat", "version_requirement": ">= 1.0.0" },
{ "name": "nanliu/staging", "version_requirement": ">= 0.4.0" }
]
}

Просмотреть файл

@ -1,24 +1,24 @@
#! /bin/sh
### BEGIN INIT INFO
# Provides: consul
# Provides: consul-template
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: Consul service discovery framework
# Short-Description: consul-template service discovery framework
# Description: Healthchecks local services and registers
# them in a central consul database.
# them in a central consul-template database.
### END INIT INFO
# Do NOT "set -e"
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/usr/sbin:/usr/bin:/sbin:/bin:<%= scope.lookupvar('consul::bin_dir') %>
DESC="Consul service discovery framework"
NAME=consul
DAEMON=<%= scope.lookupvar('consul::bin_dir') %>/$NAME
DAEMON_ARGS="agent -config-dir <%= scope.lookupvar('consul::config_dir') %> <%= scope.lookupvar('consul::extra_options') %>"
USER=<%= scope.lookupvar('consul::user') %>
PATH=/usr/sbin:/usr/bin:/sbin:/bin:<%= scope.lookupvar('consul_template::bin_dir') %>
DESC="Consul Template KV file populater"
NAME=consul-template
DAEMON=<%= scope.lookupvar('consul_template::bin_dir') %>/$NAME
DAEMON_ARGS="-config <%= scope.lookupvar('consul_template::config_dir') %>/config.json <%= scope.lookupvar('consul_template::extra_options') %>"
USER=<%= scope.lookupvar('consul_template::user') %>
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
@ -51,10 +51,10 @@ do_start()
$DAEMON_ARGS \
|| return 2
echo -n "Waiting for consul daemon to be listening..."
echo -n "Waiting for consul-template daemon to be listening..."
for i in `seq 1 30`; do
if ! start-stop-daemon --quiet --stop --test --pidfile $PIDFILE --exec $DAEMON --user $USER; then
echo " FAIL: consul process died"
echo " FAIL: consul-template process died"
return 2
fi
if "$DAEMON" info >/dev/null; then
@ -64,7 +64,7 @@ do_start()
echo -n .
sleep 1
done
echo " FAIL: consul process is alive, but is not listening."
echo " FAIL: consul-template process is alive, but is not listening."
return 2
}

Просмотреть файл

@ -0,0 +1,66 @@
#!/bin/bash
#
# /etc/rc.d/init.d/consul-template
#
# Daemonize the consul-template agent.
#
# chkconfig: 2345 95 95
# description: Populate config files with the values in Consul's KV store
# processname: consul-template
# pidfile: /var/run/consul-template/pidfile
# Source function library.
. /etc/init.d/functions
CONSUL=<%= scope.lookupvar('consul_template::bin_dir') %>/consul-template
CONFIG=<%= scope.lookupvar('consul_template::config_dir') %>
PID_FILE=/var/run/consul-template/pidfile
LOG_FILE=/var/log/consul-template
[ -e /etc/sysconfig/consul-template ] && . /etc/sysconfig/consul-template
start() {
echo -n "Starting consul-template: "
daemon --user=<%= scope.lookupvar('consul_template::user') %> \
--pidfile="$PID_FILE" \
"$CONSUL" -config "$CONFIG"/config.json <%= scope.lookupvar('consul_template::extra_options') %> >> "$LOG_FILE" &
retcode=$?
touch /var/lock/subsys/consul-template
return $retcode
}
stop() {
echo -n "Shutting down consul-template: "
"$CONSUL" leave
retcode=$?
rm -f /var/lock/subsys/consul-template
return $retcode
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
"$CONSUL" info
;;
restart)
stop
start
;;
reload)
kill -HUP `cat $PID_FILE`
;;
condrestart)
[ -f /var/lock/subsys/consul-template ] && restart || :
;;
*)
echo "Usage: consul-template {start|stop|status|reload|restart}"
exit 1
;;
esac
exit $?

Просмотреть файл

@ -0,0 +1,16 @@
# Consul Agent (Upstart unit)
description "Consul Agent"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [06]
env CONSUL=<%= scope.lookupvar('consul_template::bin_dir') %>/consul-template
env CONFIG=<%= scope.lookupvar('consul_template::config_dir') %>
script
exec sudo -u <%= scope.lookupvar('consul_template::user') %> -g <%= scope.lookupvar('consul_template::group') %> $CONSUL -config $CONFIG/config.json <%= scope.lookupvar('consul::extra_options') %>
end script
respawn
respawn limit 10 10
kill timeout 10

Просмотреть файл

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key> <string>io.consul.daemon</string>
<% if scope.lookupvar('consul::service_enable') %>
<key>Disabled</key> <false/>
<% else %>
<key>Disabled></key> <true/>
<% end %>
<key>RunAtLoad</key> <true/>
<key>KeepAlive</key> <true/>
<key>ProgramArguments</key>
<array>
<string><%= scope.lookupvar('consul::bin_dir') %>/consul</string>
<string>agent</string>
<string>-config-dir</string>
<string><%= scope.lookupvar('consul::config_dir') %></string>
<% require 'shellwords' %>
<% for extra_option in Shellwords.split(scope.lookupvar('consul::extra_options')) %>
<string><%= extra_option %></string>
<% end %>
</array>
</dict>
</plist>

Просмотреть файл

@ -1,100 +0,0 @@
#!/bin/bash
#
# /etc/rc.d/init.d/consul
#
# Daemonize the consul agent.
#
### BEGIN INIT INFO
# Provides: consul
# Required-Start: network
# Should-Start: $null
# Required-Stop: $null
# Should-Stop: $null
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Service discovery and configuration made easy.
# Description: Service discovery and configuration made easy.
### END INIT INFO
. /etc/rc.status
rc_reset
CONSUL_BIN=<%= scope.lookupvar('consul::bin_dir') %>/consul
CONFIG_DIR=<%= scope.lookupvar('consul::config_dir') %>
LOG_FILE=/var/log/consul
# read settings like GOMAXPROCS from "/etc/sysconfig/consul"
[ -e /etc/sysconfig/consul ] && . /etc/sysconfig/consul
export GOMAXPROCS=${GOMAXPROCS:-2}
case "$1" in
start)
echo -n "Starting consul "
## Start daemon with startproc(8). If this fails
## the return value is set appropriately by startproc.
startproc $CONSUL_BIN agent -config-dir "$CONFIG_DIR" <%= scope.lookupvar('consul::extra_options') %> >> "$LOG_FILE"
# Remember status and be verbose
rc_status -v
;;
stop)
echo -n "Shutting down consul "
## Stop daemon with killproc(8) and if this fails
## killproc sets the return value according to LSB.
killproc -TERM $CONSUL_BIN
# Remember status and be verbose
rc_status -v
;;
restart)
## Stop the service and regardless of whether it was
## running or not, start it again.
$0 stop
$0 start
# Remember status and be quiet
rc_status
;;
reload)
# If it supports signaling:
echo -n "Reload service consul "
killproc -HUP $CONSUL_BIN
#touch /var/run/consul.pid
rc_status -v
## Otherwise if it does not support reload:
#rc_failed 3
#rc_status -v
;;
status)
echo -n "Checking for service consul "
## Check status with checkproc(8), if process is running
## checkproc will return with exit status 0.
# Return value is slightly different for the status command:
# 0 - service up and running
# 1 - service dead, but /var/run/ pid file exists
# 2 - service dead, but /var/lock/ lock file exists
# 3 - service not running (unused)
# 4 - service status unknown :-(
# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
# NOTE: checkproc returns LSB compliant status values.
checkproc $CONSUL_BIN
# NOTE: rc_status knows that we called this init script with
# "status" option and adapts its messages accordingly.
rc_status -v
;;
*)
## If no parameters are given, print which are avaiable.
echo "Usage: $0 {start|stop|status|restart|reload}"
exit 1
;;
esac
rc_exit

Просмотреть файл

@ -1,69 +0,0 @@
#!/bin/bash
#
# /etc/rc.d/init.d/consul
#
# Daemonize the consul agent.
#
# chkconfig: 2345 95 95
# description: Service discovery and configuration made easy. \
# Distributed, highly available, and datacenter-aware.
# processname: consul
# pidfile: /var/run/consul/pidfile
# Source function library.
. /etc/init.d/functions
CONSUL=<%= scope.lookupvar('consul::bin_dir') %>/consul
CONFIG=<%= scope.lookupvar('consul::config_dir') %>
PID_FILE=/var/run/consul/pidfile
LOG_FILE=/var/log/consul
[ -e /etc/sysconfig/consul ] && . /etc/sysconfig/consul
export GOMAXPROCS=${GOMAXPROCS:-2}
start() {
echo -n "Starting consul: "
daemon --user=<%= scope.lookupvar('consul::user') %> \
--pidfile="$PID_FILE" \
"$CONSUL" agent -config-dir "$CONFIG" <%= scope.lookupvar('consul::extra_options') %> >> "$LOG_FILE" &
retcode=$?
touch /var/lock/subsys/consul
return $retcode
}
stop() {
echo -n "Shutting down consul: "
"$CONSUL" leave
retcode=$?
rm -f /var/lock/subsys/consul
return $retcode
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
"$CONSUL" info
;;
restart)
stop
start
;;
reload)
kill -HUP `cat $PID_FILE`
;;
condrestart)
[ -f /var/lock/subsys/consul ] && restart || :
;;
*)
echo "Usage: consul {start|stop|status|reload|restart}"
exit 1
;;
esac
exit $?

Просмотреть файл

@ -1,20 +0,0 @@
# Consul Agent (Upstart unit)
description "Consul Agent"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [06]
env CONSUL=<%= scope.lookupvar('consul::bin_dir') %>/consul
env CONFIG=<%= scope.lookupvar('consul::config_dir') %>
script
# read settings like GOMAXPROCS from "/etc/default/consul", if available.
[ -e /etc/default/consul ] && . /etc/default/consul
export GOMAXPROCS=${GOMAXPROCS:-2}
exec sudo -u <%= scope.lookupvar('consul::user') %> -g <%= scope.lookupvar('consul::group') %> $CONSUL agent -config-dir $CONFIG <%= scope.lookupvar('consul::extra_options') %>
end script
respawn
respawn limit 10 10
kill timeout 10