Skip to content

Instantly share code, notes, and snippets.

@jacoelho
Created November 4, 2015 17:21
Show Gist options
  • Save jacoelho/ca94d061ff49fa87cb02 to your computer and use it in GitHub Desktop.
Save jacoelho/ca94d061ff49fa87cb02 to your computer and use it in GitHub Desktop.
generate ansible jinja2 keys
import sys
data = sys.stdin.readlines()
for line in data:
key = line.split(":")[0]
key = key.replace("#", "")
value = key.replace("redis_", "", 1)
value = key.replace("_", "-")
print "{{% if {0} is defined and {0}|length > 0 %}}".format(key)
print "{0} {{{{ {1} }}}}".format(value, key)
print "{% endif %}\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment