# ansible 1.9.4 ignoring escaped double quotes with lineinfile?

**URL:** <https://forum.ansible.com/t/ansible-1-9-4-ignoring-escaped-double-quotes-with-lineinfile/20167>\
**Category:** Ansible Project\
**Created:** [January 11, 2016, 6:45am UTC](https://forum.ansible.com/t/ansible-1-9-4-ignoring-escaped-double-quotes-with-lineinfile/20167 "2016-01-11T06:45:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joel\_Parker](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@Joel\_Parker](https://forum.ansible.com/u/Joel_Parker)\
**Post date:** [January 11, 2016, 6:45am UTC](https://forum.ansible.com/t/ansible-1-9-4-ignoring-escaped-double-quotes-with-lineinfile/20167/1 "2016-01-11T06:45:16Z")

</div>

I know this has been a bug in the recent past, but I’m running into this with Ansible 1.9.4 on FreeBSD.

- name: update loader.conf  
lineinfile: dest={{ item.dest }} regexp={{ item.regexp }} line={{ item.line}} state={{ item.state }} backup={{ item.backup }} create={{ item.create }}  
with\_items:
- { dest: “/boot/loader.conf”, regexp: “^vmm\_load”, line: “vmm\_load="YES"”, state: “present”, backup: “no”, create: “yes” }

Obviously I’m wanting the result to be:  
vmm\_load=“YES”

However the actual result is:  
vmm\_load=YES

I do see that the following _does_ work as expected (note removed quotes):

- name: update loader.conf  
lineinfile: dest={{ item.dest }} regexp={{ item.regexp }} line={{ item.line}} state={{ item.state }} backup={{ item.backup }} create={{ item.create }}  
with\_items:
- { dest: “/boot/loader.conf”, regexp: “^vmm\_load”, line: vmm\_load="YES", state: “present”, backup: “no”, create: “yes” }

Am I incorrectly placing double quotes around everything in my dict, or is ansible failing to handle yaml like it should?

---

<div class="post-metadata">

**Author:** ![Joel\_Parker](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@Joel\_Parker](https://forum.ansible.com/u/Joel_Parker)\
**Post date:** [January 12, 2016, 8:51pm UTC](https://forum.ansible.com/t/ansible-1-9-4-ignoring-escaped-double-quotes-with-lineinfile/20167/2 "2016-01-12T20:51:41Z")

</div>

Any thoughts?

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [January 13, 2016, 5:38pm UTC](https://forum.ansible.com/t/ansible-1-9-4-ignoring-escaped-double-quotes-with-lineinfile/20167/3 "2016-01-13T17:38:33Z")

</div>

In 1.9.4, you'll need to use  
- { dest: "/boot/loader.conf", regexp: "^vmm\_load", line:  
vmm\_load=\\\"YES\\\", state: "present", backup: "no", create: "yes" }

(three backslashes).

In 2.0 we fixed this so that \" will work correctly there.

Quoting and escaping is tricky inside of the ansible code because we  
use yaml to parse the playbook and then jinja2 to substitute  
variables. We try to abstract that away but sometimes it leaks out  
and you end up having to escape for both of the parsers. Hopefully we  
fixed most of those in 2.0.

-Toshio

---

<div class="post-metadata">

**Author:** ![Joel\_Parker](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@Joel\_Parker](https://forum.ansible.com/u/Joel_Parker)\
**Post date:** [January 14, 2016, 2:00am UTC](https://forum.ansible.com/t/ansible-1-9-4-ignoring-escaped-double-quotes-with-lineinfile/20167/4 "2016-01-14T02:00:38Z")

</div>

thank you for the explanation
