Skip to content

Instantly share code, notes, and snippets.

@morgajel
Created May 8, 2015 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morgajel/a88ff6c08559e4dcc4c5 to your computer and use it in GitHub Desktop.
Save morgajel/a88ff6c08559e4dcc4c5 to your computer and use it in GitHub Desktop.
[global]
blah blah blah
more stuff
[serverA]
host = 192.168.2.59
port = 1433
dump file = /tmp/freetds.log
[serverB]
host = 192.168.2.33
port = 1599
dump file = /tmp/freetds.log
[serverSee]
host = 192.168.6.99
port = 20019
dump file = /tmp/freetds.log
@morgajel
Copy link
Author

morgajel commented May 8, 2015

I'd like to put the hostname, ip and port in the vault and generate this file from a jinja template. I suspect a list and loop are required, but I don't know the best way to store the variables to do that.

@morgajel
Copy link
Author

morgajel commented May 8, 2015

presuming my host_vars hostfile has the following datastructures:

freetds:
servers:
- {name: serverA, host: 192.168.2.59, port: 1433}
- {name: serverB, host: 192.168.2.33, port: 1599}

could I do something like:

{% for server in freetds.servers %}
[{{server.name}}]
host = {{server.host}}
port = {{server.port}}
dump file = /tmp/freetds.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment