def load_template(template_name, template_source=None, template_path=None, template_hash=None, template_hash_name=None, template_user='root', template_group='root', template_mode='755', saltenv=None, template_engine='jinja', skip_verify=True, defaults=None, test=False, commit=True, debug=False, replace=False, **template_vars):
 _rendered = ''
 _loaded = {'result': True, 'comment': '', 'out': None}
 loaded_config = None
 if (template_engine not in salt.utils.templates.TEMPLATE_REGISTRY):
  _loaded.update({'result': False, 'comment': 'Invalid templating engine! Choose between: {tpl_eng_opts}'.format(tpl_eng_opts=', '.join(list(salt.utils.templates.TEMPLATE_REGISTRY.keys())))})
  return _loaded
 salt_render_prefixes = ('salt://', 'http://', 'https://', 'ftp://')
 salt_render = False
 for salt_render_prefix in salt_render_prefixes:
  if (not salt_render):
   salt_render = (salt_render or template_name.startswith(salt_render_prefix) or (template_path and template_path.startswith(salt_render_prefix)))
 file_exists = __salt__['file.file_exists'](template_name)
 if (template_source or template_path or file_exists or salt_render):
  if template_source:
   if (not saltenv):
    saltenv = (template_path if template_path else 'base')
   _rendered = __salt__['file.apply_template_on_contents'](contents=template_source, template=template_engine, context=template_vars, defaults=defaults, saltenv=saltenv)
   if (not isinstance(_rendered, six.string_types)):
    if ('result' in _rendered):
     _loaded['result'] = _rendered['result']
    else:
     _loaded['result'] = False
    if ('comment' in _rendered):
     _loaded['comment'] = _rendered['comment']
    else:
     _loaded['comment'] = 'Error while rendering the template.'
    return _loaded
  else:
   if (template_path and (not file_exists)):
    template_name = __salt__['file.join'](template_path, template_name)
    if (not saltenv):
     saltenv = (template_path if (not salt_render) else 'base')
   elif (salt_render and (not saltenv)):
    saltenv = (template_path if template_path else 'base')
   if (not saltenv):
    saltenv = 'base'
   _rand_filename = __salt__['random.hash'](template_name, 'md5')
   _temp_file = __salt__['file.join']('/tmp', _rand_filename)
   _managed = __salt__['file.get_managed'](name=_temp_file, source=template_name, source_hash=template_hash, source_hash_name=template_hash_name, user=template_user, group=template_group, mode=template_mode, template=template_engine, context=template_vars, defaults=defaults, saltenv=saltenv, skip_verify=skip_verify)
   if ((not isinstance(_managed, (list, tuple))) and isinstance(_managed, six.string_types)):
    _loaded['comment'] = _managed
    _loaded['result'] = False
   elif (isinstance(_managed, (list, tuple)) and (not (len(_managed) > 0))):
    _loaded['result'] = False
    _loaded['comment'] = 'Error while rendering the template.'
   elif (isinstance(_managed, (list, tuple)) and (not (len(_managed[0]) > 0))):
    _loaded['result'] = False
    _loaded['comment'] = _managed[(-1)]
   if _loaded['result']:
    _temp_tpl_file = _managed[0]
    _temp_tpl_file_exists = __salt__['file.file_exists'](_temp_tpl_file)
    if (not _temp_tpl_file_exists):
     _loaded['result'] = False
     _loaded['comment'] = 'Error while rendering the template.'
     return _loaded
    _rendered = open(_temp_tpl_file).read()
   else:
    return _loaded
  if debug:
   loaded_config = _rendered
  if _loaded['result']:
   fun = 'load_merge_candidate'
   if replace:
    fun = 'load_replace_candidate'
   _loaded = __proxy__['napalm.call'](fun, **{'config': _rendered})
 else:
  load_templates_params = (defaults if defaults else {})
  load_templates_params.update(template_vars)
  load_templates_params.update({'template_name': template_name, 'template_source': template_source, 'template_path': template_path, 'pillar': __pillar__, 'grains': __grains__, 'opts': __opts__})
  _loaded = __proxy__['napalm.call']('load_template', **load_templates_params)
 return _config_logic(_loaded, test=test, commit_config=commit, loaded_config=loaded_config)

def load_template ( template_name , template_source = None , template_path = None , template_hash = None , template_hash_name = None , template_user = 'root' , template_group = 'root' , template_mode = '755' , saltenv = None , template_engine = 'jinja' , skip_verify = True , defaults = None , test = False , commit = True , debug = False , replace = False , ** template_vars ) : _rendered = '' _loaded = { 'result' : True , 'comment' : '' , 'out' : None } loaded_config = None if ( template_engine not in salt . utils . templates . TEMPLATE_REGISTRY ) : _loaded . update ( { 'result' : False , 'comment' : 'Invalid templating engine! Choose between: {tpl_eng_opts}' . format ( tpl_eng_opts = ', ' . join ( list ( salt . utils . templates . TEMPLATE_REGISTRY . keys ( ) ) ) ) } ) return _loaded salt_render_prefixes = ( 'salt://' , 'http://' , 'https://' , 'ftp://' ) salt_render = False for salt_render_prefix in salt_render_prefixes : if ( not salt_render ) : salt_render = ( salt_render or template_name . startswith ( salt_render_prefix ) or ( template_path and template_path . startswith ( salt_render_prefix ) ) ) file_exists = __salt__ [ 'file.file_exists' ] ( template_name ) if ( template_source or template_path or file_exists or salt_render ) : if template_source : if ( not saltenv ) : saltenv = ( template_path if template_path else 'base' ) _rendered = __salt__ [ 'file.apply_template_on_contents' ] ( contents = template_source , template = template_engine , context = template_vars , defaults = defaults , saltenv = saltenv ) if ( not isinstance ( _rendered , six . string_types ) ) : if ( 'result' in _rendered ) : _loaded [ 'result' ] = _rendered [ 'result' ] else : _loaded [ 'result' ] = False if ( 'comment' in _rendered ) : _loaded [ 'comment' ] = _rendered [ 'comment' ] else : _loaded [ 'comment' ] = 'Error while rendering the template.' return _loaded else : if ( template_path and ( not file_exists ) ) : template_name = __salt__ [ 'file.join' ] ( template_path , template_name ) if ( not saltenv ) : saltenv = ( template_path if ( not salt_render ) else 'base' ) elif ( salt_render and ( not saltenv ) ) : saltenv = ( template_path if template_path else 'base' ) if ( not saltenv ) : saltenv = 'base' _rand_filename = __salt__ [ 'random.hash' ] ( template_name , 'md5' ) _temp_file = __salt__ [ 'file.join' ] ( '/tmp' , _rand_filename ) _managed = __salt__ [ 'file.get_managed' ] ( name = _temp_file , source = template_name , source_hash = template_hash , source_hash_name = template_hash_name , user = template_user , group = template_group , mode = template_mode , template = template_engine , context = template_vars , defaults = defaults , saltenv = saltenv , skip_verify = skip_verify ) if ( ( not isinstance ( _managed , ( list , tuple ) ) ) and isinstance ( _managed , six . string_types ) ) : _loaded [ 'comment' ] = _managed _loaded [ 'result' ] = False elif ( isinstance ( _managed , ( list , tuple ) ) and ( not ( len ( _managed ) > 0 ) ) ) : _loaded [ 'result' ] = False _loaded [ 'comment' ] = 'Error while rendering the template.' elif ( isinstance ( _managed , ( list , tuple ) ) and ( not ( len ( _managed [ 0 ] ) > 0 ) ) ) : _loaded [ 'result' ] = False _loaded [ 'comment' ] = _managed [ ( - 1 ) ] if _loaded [ 'result' ] : _temp_tpl_file = _managed [ 0 ] _temp_tpl_file_exists = __salt__ [ 'file.file_exists' ] ( _temp_tpl_file ) if ( not _temp_tpl_file_exists ) : _loaded [ 'result' ] = False _loaded [ 'comment' ] = 'Error while rendering the template.' return _loaded _rendered = open ( _temp_tpl_file ) . read ( ) else : return _loaded if debug : loaded_config = _rendered if _loaded [ 'result' ] : fun = 'load_merge_candidate' if replace : fun = 'load_replace_candidate' _loaded = __proxy__ [ 'napalm.call' ] ( fun , ** { 'config' : _rendered } ) else : load_templates_params = ( defaults if defaults else { } ) load_templates_params . update ( template_vars ) load_templates_params . update ( { 'template_name' : template_name , 'template_source' : template_source , 'template_path' : template_path , 'pillar' : __pillar__ , 'grains' : __grains__ , 'opts' : __opts__ } ) _loaded = __proxy__ [ 'napalm.call' ] ( 'load_template' , ** load_templates_params ) return _config_logic ( _loaded , test = test , commit_config = commit , loaded_config = loaded_config )
return text of template file specified in config .