Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
contents_newline in file.managed is effectively ignored #54177
Description of Issue
Namely this logic block:
for part in validated_contents: for line in part.splitlines(): contents += line.rstrip('\n').rstrip('\r') + os.linesep if contents_newline and not contents.endswith(os.linesep): contents += os.linesep
The problem is that
manage-rabbitmq-erlang-cookie: file.managed: - name: /var/lib/rabbitmq/.erlang.cookie - contents: - SOME_EXAMPLE_COOKIE - contents_newline: False - user: rabbitmq - group: rabbitmq - mode: 0400 - watch_in: - service: rabbitmq-server
Steps to Reproduce Issue
Apply the above state - the managed file should not have a newline at the end... but it will.
The bug also seems to be present in
@dmurphy18 , with all due respect I am quite certain this is not a duplicate of that issue. I was looking at the code in the
Here is the line number in the
More specifically, that issue seems to address the issue with the user wanting to retain newlines, while this issue deals with the user not wanting to add in a trailing newline if one is not already present. Some services require that there be no newline at the end of the config, cookie, etc. file.