I'm trying to get ansible to add lines to /etc/exports for each value in the {{ips}} variable and not have them all on the same line.
I have tried a few different ways including lineinfile, blockinfile and replace seems to get me closer than the others, but I am still not able to get the results I want.
For certain servers I have them being added in this format
/foo/bar server1.com (rw,sync,no_root_squash)
/foo/bar server2.com (rw,sync,no_root_squash)
/foo/bar server3.com (rw,sync,no_root_squash)
using this code.
- name: Add New server to /etc/exports
lineinfile:
path: /etc/exports
insertafter: "# This Line"
line: "/foo/bar {{ item }}(rw,sync,no_root_squash)"
loop: "{{ ips.split(',') }}"
For other servers I need to have them in this format and I cannot seem to get it working.
/foo/bar server1(rw,sync,no_root_squash) server2(rw,sync,no_root_squash) server3(rw,sync,no_root_squash)