-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Complete and flexible approach to line endings (LF, CRLF, ... newlines) in file.*
functions
#14135
Comments
Thanks for the thorough report and test results! We should definitely find a way to get this all consistent and as-expected. |
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. |
Is there any chance to fix this bug? We are deploying haproxy configs via salt and are forced to use |
Thank you for updating this issue. It is no longer marked as stale. |
Should this be closed? |
@damon-atkins is this bug resolved? |
That's the question? Hence I stop this from being closed. |
I just ran into this issue. A managed configuration file restarts a service which alters the line endings after reading (not in my control). This causes the next highstate to update the configuration file... Does anyone know of a workaround?
|
I also need this fixed. Zabbix agent for Windows must have Unix line endings in the configuration file or it won't start. As such I cannot template the file to make it work. |
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. |
Thank you for updating this issue. It is no longer marked as stale. |
The Core team won't be able to get to this in Aluminium, moving it back into planning for another release. |
@uvsmtid Closing this due to age, the old version of Salt and Python 2. |
This is intentionally elaborated as both feature request and related bug report to have a systematic approach for line endings issues.
Proposal
There should be
newline
argument to allfile.*
function which update file content.For example, the values could be:
native
= use line endings of the target system (Linux: LF, Windows: CRLF, ...);LF
= force LF line endings;CRLF
= force CRLF line endings;source
= detect and preserve source line endings.Motivation
Text files deployed by Salt may be used by multiple target OSes. Using only assumed default (native) line endings is not flexible enough.
For example:
dos2unix
/unix2dos
utilities) unnecessarily complicates SLS files.Attention to details is important in this matter because managing (configuration) text files is the bulk of complex automation expected from Salt. And the expectation is that for heterogeneous environments it should be simplified on Salt side.
Existing problems
There are few existing problems (see table in "Test results" below).
If
jinja
template is used, functionfile.managed
modifies source line endings (salt://
) to that of the target's system. There are two conflicting requirements:Both are valid (and only the 2nd one is currently possible).
If
file.replace
is used on Windows and original file already hasCRLF
line endings, the function appends additionalCR
making line ending look likeCRLFCR
. This is an obvious bug.I believe that similar problems exists for other
file.*
functions likeblockreplace
,comment
/uncomment
,append
/prepend
, ..Cross references to existing bugs: #12284, #14002.
Test setup
NOTE: Cygwin is installed on Windows minion to simplify SLS and use the same command lines for tests (commands like
rm
,file
, ...).Two SRC files deployed on Linux with Salt master in
/srv/salt
:Single SLS file
/srv/salt/deleteme.sls
:Test results
The table below was filled based on results after executing:
NOTE: Even in the cases when the result is expected, based on the points listed in "Motivation" section, there are still cases when default native line endings have to be changed.
Versions
Linux master:
Linux minion:
Windows minion:
The text was updated successfully, but these errors were encountered: