Salt: file.line in python3 on windows 2012 r2 is adding extra CR line endings.

Created on 12 Jul 2018  路  6Comments  路  Source: saltstack/salt

Description of Issue/Question

Using file.line to insert a line. The resulting file is transformed to have <CR><CRLF> inserted on all lines, not just the lines edited.

Setup

c:\conf\vars.xml with dos line endings

test1<crlf>
test2<crlf>
test3<crlf>

test3.sls

{% if salt.match.grain('os:windows') %}
{% set conffile = 'C:/conf/vars.xml' %}
{% else %}
{% set conffile = '/tmp/vars.xml' %}
{% endif%}
{% set confline_regex = 'test2' %}
{% set confline_new = 'test_test' %}

# Add line IPv4 configuration line
remove_conf_line:
 file.line:
  - name: '{{ conffile }}'
  - after: test2
  - mode: insert
  - content: test4

resulting file

test1<cr>
<crlf>
test2<cr>
<crlf>
test4<cr>
<crlf>
test3<cr>
<crlf>

Steps to Reproduce Issue

Use the above states and files on windows 2012 r2 with python3 2018.3.2
Also tried the line ending fix in https://github.com/saltstack/salt/pull/48503 which did not change the issue.

Versions Report

winion-0:
    Salt Version:
               Salt: 2018.3.2

    Dependency Versions:
               cffi: 1.10.0
           cherrypy: 10.2.1
           dateutil: 2.6.1
          docker-py: Not Installed
              gitdb: 2.0.3
          gitpython: 2.1.3
              ioflo: Not Installed
             Jinja2: 2.9.6
            libgit2: Not Installed
            libnacl: Not Installed
           M2Crypto: Not Installed
               Mako: 1.0.6
       msgpack-pure: Not Installed
     msgpack-python: 0.4.8
       mysql-python: Not Installed
          pycparser: 2.17
           pycrypto: 2.6.1
       pycryptodome: Not Installed
             pygit2: Not Installed
             Python: 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 16:02:32) [MSC v.1900 64 bit (AMD64)]
       python-gnupg: 0.4.1
             PyYAML: 3.12
              PyZMQ: 16.0.3
               RAET: Not Installed
              smmap: 2.0.3
            timelib: 0.2.4
            Tornado: 4.5.1
                ZMQ: 4.1.6

    System Versions:
               dist:
             locale: cp1252
            machine: AMD64
            release: 2012ServerR2
             system: Windows
            version: 2012ServerR2 6.3.9600 SP0 Multiprocessor Free
Bug P3 ZD ZRELEASED - 2018.3.3 fixed-pending-your-verification severity-medium team-windows

Most helpful comment

@Ch3LL @whytewolf this should be easy enough to reproduce. I've assigned it to myself.

All 6 comments

ZD-2682

ping @saltstack/team-windows any ideas here?

@Ch3LL @whytewolf this should be easy enough to reproduce. I've assigned it to myself.

@dwoz Let's get this fixed for 2018.3.3

Fixed with #49026

Was this page helpful?
0 / 5 - 0 ratings