Skip to content

Commit

Permalink
Merge pull request #839 from dcolish/develop
Browse files Browse the repository at this point in the history
Issue #832, check source state files exist before rendering.
  • Loading branch information
thatch45 committed Mar 5, 2012
2 parents 98a482e + 9f97cd1 commit 85365da
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions salt/states/file.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -306,6 +306,13 @@ def _py(sfn, name, source, user, group, mode, env, context=None):
'data': trb} 'data': trb}




template_registry = {
'jinja': _jinja,
'mako': _mako,
'py': _py,
}


def symlink(name, target, force=False, makedirs=False): def symlink(name, target, force=False, makedirs=False):
''' '''
Create a symlink Create a symlink
Expand Down Expand Up @@ -530,11 +537,15 @@ def managed(name,
# then make sure to cpy it down and templatize things. # then make sure to cpy it down and templatize things.
if template and source: if template and source:
sfn = __salt__['cp.cache_file'](source, __env__) sfn = __salt__['cp.cache_file'](source, __env__)
t_key = '_{0}'.format(template) if not os.path.exists(sfn):
if t_key in globals(): ret['result'] = False
ret['comment'] = (
'File "{sfn}" could not be found').format(sfn=sfn)
if template in template_registry:
context_dict = defaults if defaults else {} context_dict = defaults if defaults else {}
if context: context_dict.update(context) if context:
data = globals()[t_key]( context_dict.update(context)
data = template_registry[template](
sfn, sfn,
name, name,
source, source,
Expand Down

0 comments on commit 85365da

Please sign in to comment.