Fix changelog.

This commit is contained in:
Darko Poljak 2016-07-10 21:29:47 +02:00
commit f0f0ddbafb
13 changed files with 90 additions and 33 deletions

View file

@ -21,18 +21,17 @@ None.
OPTIONAL PARAMETERS OPTIONAL PARAMETERS
------------------- -------------------
interval docker-container-id
the interval in which the script given with --script should be run the id of the docker container to run
script http
the shell command to run every --interval the url to check
ttl
how long a check is considered healthy without being updated through the
HTTP interfave
id id
Defaults to --name The id of this check.
interval
the interval in which the check should run
name name
The name of this check. Defaults to __object_id The name of this check. Defaults to __object_id
@ -40,9 +39,34 @@ name
notes notes
human readable description human readable description
script
the shell command to run
service-id
the id of the service this check is bound to
shell
the shell to run inside the docker container
state state
if this check is 'present' or 'absent'. Defaults to 'present'. if this check is 'present' or 'absent'. Defaults to 'present'.
status
specify the initial state of this health check
tcp
the host and port to check
timeout
after how long to timeout checks which take to long
token
ACL token to use for interacting with the catalog
ttl
how long a TTL check is considered healthy without being updated through the
HTTP interface
EXAMPLES EXAMPLES
-------- --------
@ -72,5 +96,5 @@ Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2015 Steven Armstrong. Free use of this software is Copyright \(C) 2015-2016 Steven Armstrong. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3). granted under the terms of the GNU General Public License version 3 (GPLv3).

View file

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# 2015 Steven Armstrong (steven-cdist at armstrong.cc) # 2015-2016 Steven Armstrong (steven-cdist at armstrong.cc)
# #
# This file is part of cdist. # This file is part of cdist.
# #
@ -24,12 +24,24 @@ conf_file="check_${name}.json"
state="$(cat "$__object/parameter/state")" state="$(cat "$__object/parameter/state")"
# Sanity checks # Sanity checks
if [ -f "$__object/parameter/script" -a -f "$__object/parameter/ttl" ]; then if [ -f "$__object/parameter/ttl" ]; then
echo "Use either --script together with --interval OR --ttl, but not both" >&2 for conflicts_ttl in 'docker-container-id' 'http' 'script' 'tcp' 'timeout'; do
if [ -f "$__object/parameter/${conflicts_ttl}" ]; then
echo "Can not use --ttl together with --${conflicts_ttl}." >&2
exit 1 exit 1
fi
done
fi fi
if [ -f "$__object/parameter/script" -a ! -f "$__object/parameter/interval" ]; then if [ ! -f "$__object/parameter/interval" ]; then
echo "When using --script you must also define --interval" >&2 for requires_interval in 'docker-id' 'http' 'script' 'tcp'; do
if [ -f "$__object/parameter/${requires_interval}" ]; then
echo "When using --${requires_interval} you must also define --interval." >&2
exit 1
fi
done
fi
if [ -f "$__object/parameter/docker-container-id" -a ! -f "$__object/parameter/script" ]; then
echo "When using --docker-container-id you must also define --script." >&2
exit 1 exit 1
fi fi
@ -40,11 +52,7 @@ printf ' "check": {\n'
printf ' "name": "%s"\n' "$name" printf ' "name": "%s"\n' "$name"
for param in $(ls "$__object/parameter/"); do for param in $(ls "$__object/parameter/"); do
case "$param" in case "$param" in
state|name|interval) continue ;; state|name) continue ;;
script)
printf ' ,"script": "%s"\n' "$(cat "$__object/parameter/script")"
printf ' ,"interval": "%s"\n' "$(cat "$__object/parameter/interval")"
;;
*) *)
key="$(echo "$param" | tr '-' '_')" key="$(echo "$param" | tr '-' '_')"
printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")" printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")"

View file

@ -1,7 +1,15 @@
docker-container-id
http
id id
interval interval
name name
notes notes
script script
service-id
shell
state state
status
tcp
timeout
token
ttl ttl

View file

@ -1 +1 @@
https://github.com/hashicorp/consul-template/releases/download/v0.10.0/consul-template_0.10.0_linux_amd64.tar.gz https://releases.hashicorp.com/consul-template/0.10.0/consul-template_0.10.0_linux_amd64.zip

View file

@ -0,0 +1 @@
2643547924 12487232 consul-template

View file

@ -0,0 +1 @@
https://releases.hashicorp.com/consul-template/0.15.0/consul-template_0.15.0_linux_amd64.zip

View file

@ -52,7 +52,7 @@ __staged_file /usr/local/bin/consul-template \
--source "$(cat "$version_dir/source")" \ --source "$(cat "$version_dir/source")" \
--cksum "$(cat "$version_dir/cksum")" \ --cksum "$(cat "$version_dir/cksum")" \
--fetch-command 'curl -s -L "%s"' \ --fetch-command 'curl -s -L "%s"' \
--prepare-command 'tar -xzf "%s"; cat consul-template_*/consul-template' \ --prepare-command 'unzip -p "%s"' \
--state "$state" \ --state "$state" \
--group root \ --group root \
--owner root \ --owner root \

View file

@ -1 +1 @@
0.10.0 0.15.0

View file

@ -37,6 +37,14 @@ source-file
state state
if this template is 'present' or 'absent'. Defaults to 'present'. if this template is 'present' or 'absent'. Defaults to 'present'.
wait
The `minimum(:maximum)` time to wait before rendering a new template to
disk and triggering a command, separated by a colon (`:`). If the optional
maximum value is omitted, it is assumed to be 4x the required minimum value.
This is a numeric time with a unit suffix ("5s"). There is no default value.
The wait value for a template takes precedence over any globally-configured
wait.
EXAMPLES EXAMPLES
-------- --------
@ -52,6 +60,7 @@ EXAMPLES
# upload a local file to the target and configure it # upload a local file to the target and configure it
__consul_template_template nginx \ __consul_template_template nginx \
--wait '2s:6s' \
--source-file "$__manifest/files/nginx.ctmpl" \ --source-file "$__manifest/files/nginx.ctmpl" \
--destination /etc/nginx/nginx.conf \ --destination /etc/nginx/nginx.conf \
--command 'service nginx restart' --command 'service nginx restart'
@ -69,5 +78,5 @@ Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2015 Steven Armstrong. Free use of this software is Copyright \(C) 2015-2016 Steven Armstrong. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3). granted under the terms of the GNU General Public License version 3 (GPLv3).

View file

@ -55,7 +55,7 @@ for param in $(ls "$__object/parameter/"); do
printf ' source = "%s"\n' "$destination" printf ' source = "%s"\n' "$destination"
;; ;;
source|destination|command) source|destination|command|wait)
printf ' %s = "%s"\n' "$param" "$(cat "$__object/parameter/$param")" printf ' %s = "%s"\n' "$param" "$(cat "$__object/parameter/$param")"
;; ;;
*) *)

View file

@ -2,3 +2,4 @@ command
source source
source-file source-file
state state
wait

View file

@ -29,6 +29,7 @@ import subprocess
import shutil import shutil
import logging import logging
import tempfile import tempfile
import hashlib
import cdist import cdist
import cdist.message import cdist.message
@ -59,9 +60,13 @@ class Local(object):
base_path_parent = base_path base_path_parent = base_path
else: else:
base_path_parent = tempfile.mkdtemp() base_path_parent = tempfile.mkdtemp()
import atexit # TODO: the below atexit hook nukes any debug info we would have
atexit.register(lambda: shutil.rmtree(base_path_parent)) # if cdist exits with error.
# import atexit
# atexit.register(lambda: shutil.rmtree(base_path_parent))
self.hostdir = self._hostdir() self.hostdir = self._hostdir()
self.log.debug("Calculated temp dir for target \"{}\" is "
"\"{}\"".format(self.target_host, self.hostdir))
self.base_path = os.path.join(base_path_parent, self.hostdir) self.base_path = os.path.join(base_path_parent, self.hostdir)
self._init_log() self._init_log()
@ -94,11 +99,10 @@ class Local(object):
return None return None
def _hostdir(self): def _hostdir(self):
if os.path.isabs(self.target_host): # Do not assume target_host is anything that can be used as a
hostdir = self.target_host[1:] # directory name.
else: # Instead use a hash, which is known to work as directory name.
hostdir = self.target_host return hashlib.md5(self.target_host.encode('utf-8')).hexdigest()
return hostdir
def _init_log(self): def _init_log(self):
self.log = logging.getLogger(self.target_host) self.log = logging.getLogger(self.target_host)

View file

@ -3,6 +3,7 @@ Changelog
next: next:
* Build: Make github signed release (Darko Poljak) * Build: Make github signed release (Darko Poljak)
* Core: Fix hostdir: use hash instead of target host (Steven Armstrong)
* Core: pep8 (Darko Poljak) * Core: pep8 (Darko Poljak)
* Documentation: Restructure and fix and improve docs and manpages (Darko Poljak) * Documentation: Restructure and fix and improve docs and manpages (Darko Poljak)
* Core: Add files directory for static files (Darko Poljak) * Core: Add files directory for static files (Darko Poljak)