Skip to content

Instantly share code, notes, and snippets.

@udondan
Last active June 25, 2018 14:39
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
#!/bin/bash
CONTENT="$1"
# Create a random file name for tmp files
RAND=$(cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9' | head -c 32)
TMPFILE="/tmp/$RAND"
# Render content to tmp file and output content
echo -e "$CONTENT" > "$TMPFILE.in"
consul-template -template "$TMPFILE.in:$TMPFILE.out" -once
cat "$TMPFILE.out"
# Clean up
rm "$TMPFILE.in" "$TMPFILE.out"
template {
contents = "{{ key \"some/key\" | plugin \"consul-render\" }}"
destination = "/some/file"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment