---
# tasks file for ansible-role-nfs_mount/

- name: Create directories (if they do not exist) if nfs_mounts is defined
  file: 
     path: "{{ item.name }}"
     state: directory
     mode: "{{ item.dirmode | default ('0755') }}"
     group: "{{ item.group | default(omit) }}"
     owner: "{{ item.owner | default(omit) }}"
     attributes: "{{ item.attributes | default(omit) }}"
  with_items: "{{ nfs_mounts }}"
  when: nfs_mounts is defined

- name: add mountpoints if nfs_mounts is defined and nfs_mount is not
  mount:
        fstype: "{{ item.fstype | default('nfs4') }}"
        name: "{{ item.name }}"  
        src: "{{ item.src }}"  
        state: "{{ item.state | default('mounted') }}"
        opts: "{{ item.opts | default('defaults') }}"
  with_items: "{{ nfs_mounts }}"
  when: nfs_mounts is defined

---
# tasks file for ansible-role-nfs_mount/

- name: Create directories (if they do not exist) if nfs_mounts is defined
  file: 
     path: "{{ item.name }}"
     state: directory
     mode: "{{ item.dirmode | default ('0755') }}"
     group: "{{ item.group | default(omit) }}"
     owner: "{{ item.owner | default(omit) }}"
     attributes: "{{ item.attributes | default(omit) }}"
  with_items: "{{ nfs_mounts }}"
  when:
    - nfs_mounts is defined
    - item.name is defined

- name: add mountpoints if nfs_mounts is defined and nfs_mount is not
  mount:
        fstype: "{{ item.fstype | default('nfs4') }}"
        name: "{{ item.name }}"  
        src: "{{ item.src }}"  
        state: "{{ item.state | default('mounted') }}"
        opts: "{{ item.opts | default('defaults') }}"
  with_items: "{{ nfs_mounts }}"
  when:
    - nfs_mounts is defined
    - item.name is defined
    - item.src is defined

Make sure name and src are defined
Make sure name and src are defined
