Closed truescotw closed 6 years ago
@truescotw, thanks for reporting. I have tried a simplified case, which works for me. I am also not using windows, so that may be relevant.
jmoney-main ~ master # tree /srv
/srv
├── pillar
└── salt
├── envs
│ ├── master_syndic_minion
│ │ └── init.sls
│ └── programmatic_tests
├── master
├── minion
├── motd.jinja
├── repo
└── test.sls
5 directories, 6 files
jmoney-main ~ master # cat /srv/salt/test.sls
/tmp/motd.xml:
file.managed:
- source: salt://motd.jinja
- template: jinja
jmoney-main ~ master # cat /srv/salt/motd.jinja
------------------------------------------------------------------------------
Welcome to {{ grains['fqdn'] }}
Server Stats at a Glance:
------------------------
OS: {{ grains['osfullname'] }}
Kernel: {{ grains['kernelrelease'] }}
Memory: {{ grains['mem_total'] }} MB
This server is managed using a configuration management system (saltstack.org).
Changes made to this box directly will likely be over-written by SALT. Instead
modify server configuration via the configuration management git repository.
------------------------------------------------------------------------------
jmoney-main ~ master # salt jmoney-main state.apply test
jmoney-main:
----------
ID: /tmp/motd.xml
Function: file.managed
Result: True
Comment: File /tmp/motd.xml updated
Started: 10:56:51.270322
Duration: 24.413 ms
Changes:
----------
diff:
New file
mode:
0644
Summary for jmoney-main
------------
Succeeded: 1 (changed=1)
Failed: 0
------------
Total states run: 1
jmoney-main ~ master # cat /tmp/motd.xml
------------------------------------------------------------------------------
Welcome to jmoney-main
Server Stats at a Glance:
------------------------
OS: Debian
Kernel: 3.16.0-4-amd64
Memory: 2004 MB
This server is managed using a configuration management system (saltstack.org).
Changes made to this box directly will likely be over-written by SALT. Instead
modify server configuration via the configuration management git repository.
------------------------------------------------------------------------------
jmoney-main ~ master # salt jmoney-main test.versions
jmoney-main:
Salt Version:
Salt: 2015.8.7
Dependency Versions:
Jinja2: 2.7.3
M2Crypto: 0.21.1
Mako: 1.0.0
PyYAML: 3.11
PyZMQ: 14.4.0
Python: 2.7.9 (default, Mar 1 2015, 12:57:24)
RAET: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.5
cffi: 0.8.6
cherrypy: Not Installed
dateutil: Not Installed
gitdb: 0.5.4
gitpython: 0.3.2 RC1
ioflo: Not Installed
libgit2: Not Installed
libnacl: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.2
mysql-python: Not Installed
pycparser: 2.10
pycrypto: 2.6.1
pygit2: Not Installed
python-gnupg: Not Installed
smmap: 0.8.2
timelib: Not Installed
System Versions:
dist: debian 8.4
machine: x86_64
release: 3.16.0-4-amd64
system: debian 8.4
Hi jfindlay, i actually managed to get this working bit i am a little bit unsure how it happened. I recreated the template file this time in Linux as appoased to in notepad++ on windows and then it started to work again, i suspect that this may have been caused because of something like line endings or text formatting, if it helps at all i have attached the actual file that i was using (providing of course the upload doesnt change it :) ) but from my side i have a solution and will know to create the file on the salt master in the future if i come across this issue
i have another update, the xml file that i need to generate must be in "UCS-2 Little endian encoding" but saltstack does not seam to support this encoding in a jinja template, is there any way around this?
@truescotw, I am glad you figured it out, but salt should be able to work with windows encodings and line endings, etc. if necessary, so let's keep this open so we can track down what may be happening with that. I suspect there may be a jinja error somewhere that is getting ignored.
we read in one of the .py files that currently the jinja templates only support utf-8 and theres a #to be fixed comment in the file about it. I have a pretty ugly workaround in place for the minute which works but is not ideal. (i will find the py file i am talking about and add it to this ticket)
D:\myjinjatest.xml:
file.managed:
- source: salt://win/repo_ng/configs/mytest.jinja
- template: jinja
- saltenv: 'base'
change-encoding:
cmd.run:
- name: 'start powershell "(Get-Content -Encoding UTF8 D:\myjinjatest.xml ) | Out-File -Encoding Unicode D:\myjinjatest.xml"'
- order: last
@truescotw, what might be done here is to add an encoding
argument to file.managed
and other functions in that module that would also be sensible.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
Hi, I was hoping someone could help me out, I have been struggling with getting a jinja template to work in my environment. I started off with a config file with some jinja variables in it which didnt work so pared it all back to the simplest configuration that i could but still no luck, I have tried restarting minion and master, re-installing the minion and everything else that i can think of , i am using 2015.8.3 on both the master(centos 7) and minion (windows 2012), the config and logs are below
salt master centos 7 salt 2015.8.3 (Beryllium) salt minion windows 2012 salt 2015.8.3 (Beryllium)
/srv/salt/base/trayport/jinjatest.sls
/srv/salt/base/top.sls
/salt-repositories/base/win/repo_ng/configs/mytest.jinja
d:\myjinjatest.xml
Minion Log File