lineinfile quoting issues

96 views
Skip to first unread message

Edgars

unread,
Oct 23, 2014, 5:01:54 AM10/23/14
to ansible...@googlegroups.com
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","local.example.com";
     
- default domain-name "example.com";

And I always get this error:

failed: [127.0.0.1] => (item=supersede domain-search "example.com","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,local.example.com;', 'state=present'])
failed: [127.0.0.1] => (item=default domain-name "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;', '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','local.example.com';"
     
- "default domain-name '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

Michael Hoglan

unread,
Oct 23, 2014, 9:45:32 AM10/23/14
to ansible...@googlegroups.com
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","local.example.com";
      - default domain-name "example.com";

Thanks!
Michael
Reply all
Reply to author
Forward
0 new messages