From 8866e756fba07ad28d5c58f69224fc6eda62c4d4 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Sun, 1 Apr 2012 14:22:18 -0600 Subject: [PATCH] Add get_template to cp module --- salt/modules/cp.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/salt/modules/cp.py b/salt/modules/cp.py index cdc0ad0f85..385b98439a 100644 --- a/salt/modules/cp.py +++ b/salt/modules/cp.py @@ -52,6 +52,26 @@ def get_file(path, dest, env='base'): return client.get_file(path, dest, False, env) +def get_template(path, dest, template='jinja', env='base', **kwargs): + ''' + Render a file as a template before settign it down + + CLI Example:: + + salt '*' cp.get_template salt://path/to/template /minion/dest + ''' + client = salt.fileclient.get_file_client(__opts__) + if not 'salt' in kwargs: + kwargs['salt'] = __salt__ + if not 'pillar' in kwargs: + kwargs['pillar'] = __pillar__ + if not 'grains' in kwargs: + kwargs['grains'] = __grains__ + if not 'opts' in kwargs: + kwargs['opts'] = __opts__ + return client.get_template(path, dest, template, False, env, **kwargs) + + def get_dir(path, dest, env='base'): ''' Used to recursively copy a directory from the salt master