salt icon indicating copy to clipboard operation
salt copied to clipboard

cp.get_file doesn't template properly

Open Lomexian opened this issue 10 years ago • 2 comments

Description of Issue/Question

cp.get_file called with template=jinja doesn't parse the file through the template engine.

This is not a major issue since the command cp.get_template can be used in place however documentation suggests cp.get_file should work.

Setup

Test file on master in a file path: test.txt {% set myvar = grains['id'] %} {{ myvar }}

Steps to Reproduce Issue

salt 'minion' cp.get_file salt://test.txt "c:\test.txt" template=jinja Incorrectly shows original un-templated contents of file on minion

salt 'minion' cp.get_template salt://test.txt "c:\test.txt" template=jinja Correctly shows templated contents of file on minion (minion name)

Versions Report

Salt Version: Salt: 2016.3.1

Dependency Versions: cffi: Not Installed cherrypy: 3.2.2 dateutil: Not Installed gitdb: 0.5.4 gitpython: 0.3.2 RC1 ioflo: Not Installed Jinja2: 2.7.2 libgit2: Not Installed libnacl: Not Installed M2Crypto: 0.21.1 Mako: Not Installed msgpack-pure: Not Installed msgpack-python: 0.4.7 mysql-python: Not Installed pycparser: Not Installed pycrypto: 2.6.1 pygit2: Not Installed Python: 2.7.5 (default, Nov 20 2015, 02:00:19) python-gnupg: Not Installed PyYAML: 3.11 PyZMQ: 14.7.0 RAET: Not Installed smmap: 0.9.0 timelib: Not Installed Tornado: 4.2.1 ZMQ: 4.0.5

System Versions: dist: centos 7.2.1511 Core machine: x86_64 release: 3.10.0-327.18.2.el7.x86_64 system: Linux version: CentOS Linux 7.2.1511 Core

Lomexian avatar Nov 24 '16 09:11 Lomexian

From the documentation, the template on cp.get_file is used to specify a template for the filename string, not for the file.

So, like this salt '*' cp.get_file "salt://{{grains.os}}/vimrc" /etc/vimrc template=jinja

If you want to template the file as well, you should use cp.get_template as you said above.

gtmanfred avatar Nov 29 '16 15:11 gtmanfred

My mistake, thanks for the clarification.

Lomexian avatar Nov 30 '16 08:11 Lomexian