# lineinfile inserts dos style new line character

**URL:** <https://forum.ansible.com/t/lineinfile-inserts-dos-style-new-line-character/15472>\
**Category:** Ansible Project\
**Created:** [June 16, 2014, 12:12pm UTC](https://forum.ansible.com/t/lineinfile-inserts-dos-style-new-line-character/15472 "2014-06-16T12:12:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jepper](https://avatars.discourse-cdn.com/v4/letter/j/49beb7/32.png) [@jepper](https://forum.ansible.com/u/jepper)\
**Post date:** [June 16, 2014, 12:12pm UTC](https://forum.ansible.com/t/lineinfile-inserts-dos-style-new-line-character/15472/1 "2014-06-16T12:12:21Z")

</div>

I’m setting up tomcat, and change a parameter in a config file as follows:

- name: set max-request-size

lineinfile: dest={{ tomcat\_home }}/webapps/manager/WEB-INF/web.xml regexp=“max-request-size” line=“1000000000”

Post processing, lines in the target file web.xml now end with a ^M. The lines that were replaced are fine, e.g.

^M  
1000000000 \<— OK!  
0^M

This is as seen vi, on a RHEL64 system.

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [June 16, 2014, 4:02pm UTC](https://forum.ansible.com/t/lineinfile-inserts-dos-style-new-line-character/15472/2 "2014-06-16T16:02:05Z")

</div>

The lineinfile module uses the os.linesep variable to insert newlines, so this should not be happening unless the file had either been edited on a Windows system or had the ^M’s before the edit occurred. Can you verify the original file did not have the incorrect newlines, and that you are not running the playbook from a Windows machine (ie. via cygwin)?
