From ebe3ca12967844f0d348fd952b35c98af704919c Mon Sep 17 00:00:00 2001 From: Vlad Glagolev Date: Fri, 2 Jul 2021 03:56:56 +0000 Subject: consul-template-bin: new spell, template rendering and notifications with Consul --- ChangeLog | 5 +++- accounts | 1 + bin-utils/consul-template-bin/BUILD | 1 + bin-utils/consul-template-bin/DEPENDS | 1 + bin-utils/consul-template-bin/DETAILS | 28 +++++++++++++++++ bin-utils/consul-template-bin/FINAL | 4 +++ bin-utils/consul-template-bin/HISTORY | 3 ++ bin-utils/consul-template-bin/INSTALL | 14 +++++++++ bin-utils/consul-template-bin/PRE_BUILD | 4 +++ bin-utils/consul-template-bin/files/default.conf | 13 ++++++++ .../consul-template-bin/init.d/consul-template | 35 ++++++++++++++++++++++ .../init.d/consul-template.conf | 3 ++ groups | 1 + 13 files changed, 112 insertions(+), 1 deletion(-) create mode 100755 bin-utils/consul-template-bin/BUILD create mode 100755 bin-utils/consul-template-bin/DEPENDS create mode 100755 bin-utils/consul-template-bin/DETAILS create mode 100755 bin-utils/consul-template-bin/FINAL create mode 100644 bin-utils/consul-template-bin/HISTORY create mode 100755 bin-utils/consul-template-bin/INSTALL create mode 100755 bin-utils/consul-template-bin/PRE_BUILD create mode 100644 bin-utils/consul-template-bin/files/default.conf create mode 100755 bin-utils/consul-template-bin/init.d/consul-template create mode 100644 bin-utils/consul-template-bin/init.d/consul-template.conf diff --git a/ChangeLog b/ChangeLog index 72b5e87..e8072ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ 2021-07-01 Vlad Glagolev * bin-net/consul-bin: new spell, service discovery and configuration tool - * accounts, groups: added account data for consul-bin spell + * bin-utils/consul-template-bin: new spell, template rendering and + notifications with Consul + * accounts, groups: added account data for consul-bin and + consul-template-bin spells 2021-06-04 Treeve Jelbert * bin-devel/nodejs-bin: Nodejs diff --git a/accounts b/accounts index 89f8164..c013d98 100755 --- a/accounts +++ b/accounts @@ -6,3 +6,4 @@ tomcat6:38:35 ontopia:39:36 tomcat7:40:35 consul:217:217 +consul-template:218:218 diff --git a/bin-utils/consul-template-bin/BUILD b/bin-utils/consul-template-bin/BUILD new file mode 100755 index 0000000..ec83160 --- /dev/null +++ b/bin-utils/consul-template-bin/BUILD @@ -0,0 +1 @@ +create_account consul-template diff --git a/bin-utils/consul-template-bin/DEPENDS b/bin-utils/consul-template-bin/DEPENDS new file mode 100755 index 0000000..f7c362b --- /dev/null +++ b/bin-utils/consul-template-bin/DEPENDS @@ -0,0 +1 @@ +depends unzip diff --git a/bin-utils/consul-template-bin/DETAILS b/bin-utils/consul-template-bin/DETAILS new file mode 100755 index 0000000..7c3365b --- /dev/null +++ b/bin-utils/consul-template-bin/DETAILS @@ -0,0 +1,28 @@ + SPELL=consul-template-bin + SPELLX=${SPELL/-bin/} + VERSION=0.26.0 +if [[ "${SMGL_COMPAT_ARCHS[1]}" == "x86_64" || "${SMGL_COMPAT_ARCHS[1]}" == "em64t" ]]; then + ARCH=amd64 + SOURCE_HASH=sha256:d4b1d8dc46289a4bdbb73301cd1dbdd9b41eddcab4103f006c5bf9637f7e4381:UPSTREAM_HASH +else + ARCH=386 + SOURCE_HASH=sha256:5e82abd3e1516970d86e81d4acc4c929183c7a1fc55b0b6b01ef3b56a3b5d183:UPSTREAM_HASH +fi + SOURCE=${SPELLX}_${VERSION}_linux_${ARCH}.zip + SOURCE_URL[0]=https://releases.hashicorp.com/${SPELLX}/${VERSION}/${SOURCE} +SOURCE_DIRECTORY="${BUILD_DIRECTORY}/${SPELL}-${VERSION}" + GATHER_DOCS=off + WEB_SITE=https://github.com/hashicorp/consul-template + ENTERED=20210701 + LICENSE[0]=MPL + SHORT="template rendering and notifications with Consul" +cat << EOF +This is a binary version of consul-template. + +This project provides a convenient way to populate values from Consul into the +file system using the consul-template daemon. + +The daemon consul-template queries a Consul or Vault cluster and updates any +number of specified templates on the file system. As an added bonus, it can +optionally run arbitrary commands when the update process completes. +EOF diff --git a/bin-utils/consul-template-bin/FINAL b/bin-utils/consul-template-bin/FINAL new file mode 100755 index 0000000..1571059 --- /dev/null +++ b/bin-utils/consul-template-bin/FINAL @@ -0,0 +1,4 @@ +# binaries require /lib64 +if [ ! -d "${INSTALL_ROOT}/lib64" ]; then + ln -vsf "${TRACK_ROOT}/lib" "${INSTALL_ROOT}/lib64" +fi diff --git a/bin-utils/consul-template-bin/HISTORY b/bin-utils/consul-template-bin/HISTORY new file mode 100644 index 0000000..8615c93 --- /dev/null +++ b/bin-utils/consul-template-bin/HISTORY @@ -0,0 +1,3 @@ +2021-07-01 Vlad Glagolev + * DETAILS, DEPENDS, {PRE_,}BUILD, INSTALL, init.d, files: created + spell, version 0.26.0 diff --git a/bin-utils/consul-template-bin/INSTALL b/bin-utils/consul-template-bin/INSTALL new file mode 100755 index 0000000..371d6e4 --- /dev/null +++ b/bin-utils/consul-template-bin/INSTALL @@ -0,0 +1,14 @@ +# /usr/bin is handled by smgl-fhs +install -vm 755 consul-template "${INSTALL_ROOT}/usr/bin" && + +local config_dir="${INSTALL_ROOT}/etc/${SPELLX}.d" && + +if [ ! -d "${config_dir}" ]; then + install -vm 750 -o root -g consul-template -d "${config_dir}" +fi && + +install_config_file "${SPELL_DIRECTORY}/files/default.conf" \ + "${config_dir}/default.conf" && + +chown root:consul-template "${config_dir}/default.conf" && +chmod 0640 "${config_dir}/default.conf" diff --git a/bin-utils/consul-template-bin/PRE_BUILD b/bin-utils/consul-template-bin/PRE_BUILD new file mode 100755 index 0000000..5416781 --- /dev/null +++ b/bin-utils/consul-template-bin/PRE_BUILD @@ -0,0 +1,4 @@ +mk_source_dir "${SOURCE_DIRECTORY}" && +cd "${SOURCE_DIRECTORY}" && + +unpack_file '' diff --git a/bin-utils/consul-template-bin/files/default.conf b/bin-utils/consul-template-bin/files/default.conf new file mode 100644 index 0000000..4c6d82f --- /dev/null +++ b/bin-utils/consul-template-bin/files/default.conf @@ -0,0 +1,13 @@ +# Minimal configuration file for consul-template. + +consul = "127.0.0.1:8500" + +syslog { + enabled = true + facility = "DAEMON" +} + +template { + source = "/path/to/template.ctmpl" + destination = "/path/to/destination" +} diff --git a/bin-utils/consul-template-bin/init.d/consul-template b/bin-utils/consul-template-bin/init.d/consul-template new file mode 100755 index 0000000..a188860 --- /dev/null +++ b/bin-utils/consul-template-bin/init.d/consul-template @@ -0,0 +1,35 @@ +#!/bin/bash + +. /etc/sysconfig/consul-template + +PROGRAM=/usr/bin/consul-template +PIDFILE=/var/run/consul-template/consul-template.pid +ARGS="-config=/etc/consul-template.d -pid-file=$PIDFILE $CONSUL_TEMPLATE_ARGS" +RUNLEVEL=3 +NEEDS="+network" + +start() { + echo "Starting $NAME..." + + TIMEOUT=3 + PIDFILE_DIR=$(dirname $PIDFILE) + + [ -d $PIDFILE_DIR ] || mkdir $PIDFILE_DIR && chown consul-template:consul-template $PIDFILE_DIR + + su consul-template -s /bin/sh -c "$PROGRAM $ARGS &> /dev/null" & + ppid=$! + + sleep $TIMEOUT && pgrep -P $ppid > /dev/null || wait $ppid + + evaluate_retval +} + +stop() { + echo "Stopping $NAME..." + + kill -INT $(cat ${PIDFILE} 2> /dev/null) &> /dev/null + + evaluate_retval +} + +. /etc/init.d/smgl_init diff --git a/bin-utils/consul-template-bin/init.d/consul-template.conf b/bin-utils/consul-template-bin/init.d/consul-template.conf new file mode 100644 index 0000000..6a8131d --- /dev/null +++ b/bin-utils/consul-template-bin/init.d/consul-template.conf @@ -0,0 +1,3 @@ +# For the arguments and description see ``consul-template --help'' + +CONSUL_TEMPLATE_ARGS="" diff --git a/groups b/groups index 5a03a38..acb0e4b 100755 --- a/groups +++ b/groups @@ -3,3 +3,4 @@ tomcat:35: ontopia:36: consul:217: +consul-template:218: -- cgit v1.2.3