# lineinfile quoting issues

**URL:** <https://forum.ansible.com/t/lineinfile-quoting-issues/16587>\
**Category:** Ansible Project\
**Created:** [October 23, 2014, 9:01am UTC](https://forum.ansible.com/t/lineinfile-quoting-issues/16587 "2014-10-23T09:01:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edgars](https://avatars.discourse-cdn.com/v4/letter/e/f17d59/32.png) [@Edgars](https://forum.ansible.com/u/Edgars)\
**Post date:** [October 23, 2014, 9:01am UTC](https://forum.ansible.com/t/lineinfile-quoting-issues/16587/1 "2014-10-23T09:01:54Z")

</div>

Hi

I have this task:

`

- name: Edit DHCP Client settings  
lineinfile: dest=/etc/dhcp/dhclient.conf line={{ item }} state=present  
with\_items:
- supersede domain-search “[example.com](http://example.com)”,“[local.example.com](http://local.example.com)”;
- default domain-name “[example.com](http://example.com)”;  
`

And I always get this error:

> failed: [127.0.0.1] =\> (item=supersede domain-search “[example.com](http://example.com)”,“[local.example.com](http://local.example.com)”😉 =\> {“failed”: true, “item”: “supersede domain-search "example.com","local.example.com";”}  
> msg: this module requires key=value arguments ([‘dest=/etc/dhcp/dhclient.conf’, ‘line=supersede’, ‘domain-search’, ‘[example.com](http://example.com),[local.example.com](http://local.example.com);’, ‘state=present’])  
> failed: [127.0.0.1] =\> (item=default domain-name “[example.com](http://example.com)”😉 =\> {“failed”: true, “item”: “default domain-name "example.com";”}  
> msg: this module requires key=value arguments ([‘dest=/etc/dhcp/dhclient.conf’, ‘line=default’, ‘domain-name’, ‘[example.com](http://example.com);’, ‘state=present’])

I have tried to put whole line in quotes like this:

`lineinfile: "dest=/etc/dhcp/dhclient.conf line={{ item }} state=present"`

Also tried nested quotes like this:

`  
with\_items:

- “supersede domain-search ‘[example.com](http://example.com)’,‘[local.example.com](http://local.example.com)’;”
- “default domain-name ‘[example.com](http://example.com)’;”  
`

Also tried to escape double-quotes and single-quotes.

But still getting the same error. What is the correct way to put quotes here?

Thanks in advance  
Edgars

---

<div class="post-metadata">

**Author:** ![Michael\_Hoglan](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@Michael\_Hoglan](https://forum.ansible.com/u/Michael_Hoglan)\
**Post date:** [October 23, 2014, 1:45pm UTC](https://forum.ansible.com/t/lineinfile-quoting-issues/16587/2 "2014-10-23T13:45:32Z")

</div>

Specify it this way

- name: Edit DHCP Client settings  
lineinfile:  
dest: /etc/dhcp/dhclient.conf  
line: “{{ item }}”  
state: present  
with\_items:
- supersede domain-search “[example.com](http://example.com)”,“[local.example.com](http://local.example.com)”;
- default domain-name “[example.com](http://example.com)”;

Thanks!  
Michael
