How to remove the line breaker character ‘\n’ from the result of lookup() module in Ansible?


I am using [file lookup] which reads the whole file and stores the content in a variable. My play looks something like this:

So the above code reads the foo.xml file and stores it in the variable, but the problem is when the foo.xml has line breaks in it, it also includes the line break in the variable.

My foo.xml is this file:

The output removes line break \n but also incudes the tabs \r & \t

I need to got rid of the \n , need to get rid of extra formatting too (\r & \t), Moreover after the replace filter I get the error while firing a DB Update query as


Use the Jinja trim filter:

Leave a Reply