with_items: “{{ nfs_exports }}” notify: restart nfs |
|
May I know what is " item.strip().split()[0] " mean in below code? I'm thining, first value in a space seperated line. Ref: https://github.com/geerlingguy/ansible-role-nfs/blob/master/tasks/main.yml - name: Ensure directories to export exist
file:'path="{{ item.strip().split()[0] }}" state=directory'
Almost. It’s the first value in a whitespace separated line, which means ‘foo bar’ and ‘foo\n \tbar’ would both be splitted to [‘foo’, ‘bar’] and element 0 is ‘foo’ for both.
On a side note, split() without arguments has extra logic that make the call to strip() redundant.
Lastly, nfs_exports is a list defined as empty by default in https://github.com/geerlingguy/ansible-role-nfs/blob/master/defaults/main.yml. You may want to populate it by other means when running the playbook.
You can check the readme file of the role and take the example from there and create small playbook like this:
`