# lineinfile error.

**URL:** <https://forum.ansible.com/t/lineinfile-error/13224>\
**Category:** Ansible Project\
**Created:** [July 30, 2013, 8:39pm UTC](https://forum.ansible.com/t/lineinfile-error/13224 "2013-07-30T20:39:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_Montuori](https://avatars.discourse-cdn.com/v4/letter/k/bbce88/32.png) [@Kevin\_Montuori](https://forum.ansible.com/u/Kevin_Montuori)\
**Post date:** [July 30, 2013, 8:39pm UTC](https://forum.ansible.com/t/lineinfile-error/13224/1 "2013-07-30T20:39:36Z")

</div>

Hi --

There's a bug either in the YAML parser or the lineinfile module (or the  
documentation), I'm not sure exactly what the problem is. This example  
from the docs:

&nbsp;&nbsp;- lineinfile: dest=/etc/sudoers state=present regexp='^%wheel'  
&nbsp;&nbsp;line='%wheel ALL=(ALL) NOPASSWD: ALL'

fails with:

ERROR: Syntax Error while loading YAML script,  
/export/tools/ops/ansible/roles/common/tasks/main.yml  
Note: The error may actually appear before this position: line 34,  
column 95

The line 34, column 95 is the colon after NOPASSWD:

If this isn't a known issue, I'm happy to file a github issue. In the  
meantime, any ideas for a workaround? Single quotes, loading the value  
from a variable, and \: don't fix the problem. Interestingly (well, to  
me), a colon in the regexp statement does not cause an error.

Thanks.  
k.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [July 30, 2013, 8:48pm UTC](https://forum.ansible.com/t/lineinfile-error/13224/2 "2013-07-30T20:48:57Z")

</div>

quote everything from “dest … ALL’” , the : is a yaml special character and the whole module param string needs to be quoted.

---

<div class="post-metadata">

**Author:** ![Kevin\_Montuori](https://avatars.discourse-cdn.com/v4/letter/k/bbce88/32.png) [@Kevin\_Montuori](https://forum.ansible.com/u/Kevin_Montuori)\
**Post date:** [July 30, 2013, 8:56pm UTC](https://forum.ansible.com/t/lineinfile-error/13224/3 "2013-07-30T20:56:40Z")

</div>

Ah. There it is ... the quoting permutation I didn't try. Thanks a ton  
for your help. It'd be great to see the bug in the documentation fixed.

k.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [July 30, 2013, 9:05pm UTC](https://forum.ansible.com/t/lineinfile-error/13224/4 "2013-07-30T21:05:12Z")

</div>

it is documented that ANY module, not just lineinfile needs to be careful with YAML characters. It is just appears more commonly in lineinfile cause of obvious reasons.
