Templates: how to handle file encoding and line endings?

30 views
Skip to first unread message

thomas....@adtech.com

unread,
Oct 16, 2017, 3:53:41 AM10/16/17
to Ansible Project
Hi,

I'm looking forward to migrate a large configuration package to Ansible.
With a verification script we check that the finally distributed files are the
same as we have without Ansible. In first phase we moved everything
into the template folder of the role; reducing configuration code with Jinja
templating comes in next phase.

So with first phase (as mentioned) we detected following problems:

a) Line endings: We have files with different line endings (Windows and Linux)
    but the Ansible template module translates all in one (default: Linux).
    We have been able to workaround writing a filter plugin but probably there
    should be an option like "keep" in addition to given ones in field "newline_sequence".
    (feature request)

b) File encoding: Usually we have ASCII files for configuration but a few ones do have
    ISO-8859. We detected that final file is converted to UTF-8. I don't see an option to
    specify encoding. Any ideas how to handle it?

kind regards,
Thomas
Reply all
Reply to author
Forward
0 new messages