Building a templating renderer
Building a renderer that handles templating files is not that different from one that does serialization. In fact, the renderer itself is pretty much the same, outside of the library-specific code. This time, we'll use a Python library called tenjin
. You may need to install it using pip:
# pip install tenjin
Templating with Tenjin
This module makes use of a third-party library, so there will be a __virtual__()
function to make sure it's installed:
''' Conver a file using the Tenjin templating engine This file should be saved as salt/renderers/tenjin.py ''' from __future__ import absolute_import try: import tenjin from tenjin.helpers import * HAS_LIBS = True except ImportError: HAS_LIBS = False from salt.ext.six import string_types def __virtual__(): ''' Only load if Tenjin is installed ''' return HAS_LIBS def render(tenjin_data, saltenv='base', sls='', **kwargs): ''' Accepts a tenjin, and renders said data back to...