Don't render template files if they already exist

This enables overriding of snap template files by users or
deployment tools.

Change-Id: Ia130f6e7af947a77e415be5847df54142b5f6781
This commit is contained in:
Corey Bryant 2017-05-01 14:52:47 +00:00
parent 8b1f6581fa
commit d4dad15941

@ -71,10 +71,12 @@ class OpenStackSnap(object):
target = setup['templates'][template]
target_file = target.format(**utils.snap_env)
utils.ensure_dir(target_file, is_file=True)
LOG.debug('Rendering {} to {}'.format(template, target_file))
with open(target_file, 'w') as tf:
os.fchmod(tf.fileno(), 0o640)
tf.write(renderer.render(template, utils.snap_env))
if not os.path.isfile(target_file):
LOG.debug('Rendering {} to {}'.format(template,
target_file))
with open(target_file, 'w') as tf:
os.fchmod(tf.fileno(), 0o640)
tf.write(renderer.render(template, utils.snap_env))
if 'copyfiles' in setup.keys():
for source, target in setup['copyfiles'].items():