Skip to content

Instantly share code, notes, and snippets.

@udondan
Last active June 25, 2018 14:39
Show Gist options
  • Save udondan/58195fe5801287e6e5ed1a9505b0baa2 to your computer and use it in GitHub Desktop.
Save udondan/58195fe5801287e6e5ed1a9505b0baa2 to your computer and use it in GitHub Desktop.
#!/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