May I suggest the following way of doing it:

- name: mounting shares
  mount: name={{ item.name }} src={{ item.src }} fstype=nfs opts={{ 
item.opts }} state=mounted
  with_items:
    - { name: '/root/nfs',    src: 'hostname:/ExportName',    opts: 
'defaults' }
    [...]
  tags: nfs

The mount module works like a charm and the documentation is really clear 
on the various states it supports.

On Tuesday, 26 August 2014 15:57:30 UTC+2, Matteo Ceccarello wrote:
>
> Hi all!
>
> I'm trying to use the lineinfile module to configure NFS exports and I 
> need to put parentheses in my line argument. 
>
> If I do something like this
>
> - name: Export the NFS directory for root
>   lineinfile: dest=/etc/exports 
>               regexp='/root/nfs'
>               line='/root/nfs 
> 192.168.1.0/255.255.255.0(rw,no_root_squash,subtree_check)'
>
> I get a line in my /etc/exports that looks like
>
> '/root/nfs 192.168.1.0/255.255.255.0(rw,no_root_squash,subtree_check)'
>
> That is, surrounded by quotes. The problem is that this format is invalid, 
> so I have to remove the quotes.
> I made a few tests, and I found out that removing the parentheses works
>
> - name: Test
>   lineinfile: dest=/etc/exports
>               line="/root/nfs 192.168.1.0/255.255.255.0"
>
> yields the following line (without quotes)
>
> /root/nfs 192.168.1.0/255.255.255.0
>
> whereas reintroducing the parentheses reintroduces also quotes
>
> - name: Test
>   lineinfile: dest=/etc/exports
>               line="/root/nfs 192.168.1.0/255.255.255.0()"
>
> '/root/nfs 192.168.1.0/255.255.255.0()'
>
> I tried to escape the parentheses and this removes the quotes, but escape 
> chars remain!
>
> - name: Test
>   lineinfile: dest=/etc/exports
>               line="/root/nfs 192.168.1.0/255.255.255.0\(\) 
> <http://192.168.1.0/255.255.255.0%5C(%5C)>"
>
> /root/nfs 192.168.1.0/255.255.255.0\(\) 
> <http://192.168.1.0/255.255.255.0%5C(%5C)>
>
> Is this a bug? Am I missing something?
>
> Thank you very much :-)
>
> Matteo
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/0f2391a7-1dd3-4d74-b09e-a7e71ea9b978%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to