This is a new version of our templating engine!
Originally developed by @KristianLyng, later slightly rewritten by @Foxboron.
Old source can still be found here: gondul/templating
There's one weird thing. To be a bit backwards compatible the last two items of a path will be used as the objects name.
This however opens up for possible name collisions from files and http api data.
Example:
---
get:
- file:///root/templating/data/read/networks.yaml
- file:///root/templating/data/read/networks.json
- https://<USER:PW>@gondul.tg23.gathering.org/api/read/networks
- http://<USER:PW>@gondul.tg23.gathering.org/api/read/networks
All of these would be added as read/networks
in the python dicts. Aka, the last one is going to win.
Therefor, think twice when naming things :)
This is inteded behaviour to support as of now. Helps us run templating offline.
- Fully async
- Loads data from local files
- yaml
- json
- Loads data from API's
- Run a template once with HTTP options
file://
- Can be both a file, or a folder
- We will attempt to load all files found recursively
- Can be relative path
https://
andhttp://
- Gets data from API endpoint
- Supports adding header options (tbh, i just **kwargs this directly to aiohttp..)
---
get:
- file:///root/templating/data
# Relative Path is also supported
- file://./templating/data
- https://<USER:PW>@gondul.tg23.gathering.org/api/read/networks
- http://gondul.tg23.gathering.org/api/public/switches
- 'https://netbox.tg23.gathering.org/api/ipam/ip-addresses?exclude=config_context&format=json&limit=0':
headers:
Authorization: 'Token <TOKEN>'
python3 templating.py -t ../tech-templates/ -c config.yaml
python3 ../templating/templating.py --once magic.conf -c templating/config.yml -t . -i switch=e7-4
This service exposes a api endpoit where you can POST a template and have it rendered. To mitigate the obvious SSTI this creates, please but the endpoint behind authentication.