# platform = multi_platform_all
# reboot = false
# strategy = configure
# complexity = low
# disruption = medium

- name: "Get nfs and nfs4 mount points, that don't have nodev"
  # 'no' before MOUNTOPTION isn't omission, it means a negation
  ansible.builtin.command: findmnt --fstab --types nfs,nfs4 -O nonodev -n -P
  register: points_register
  check_mode: no
  changed_when: False
  # if no nfs/nfs4 entries are in /etc/fstab, findmnt command returns 1
  failed_when: False

- name: "Add nodev to nfs and nfs4 mount points"
  ansible.posix.mount:
    path: "{{ item | regex_search('TARGET=\"([^\"]+)\"','\\1') | first }}"
    src: "{{ item | regex_search('SOURCE=\"([^\"]+)\"','\\1') | first }}"
    fstype: "{{ item | regex_search('FSTYPE=\"([^\"]+)\"','\\1') | first }}"
    state: present
    opts: "{{ item | regex_search('OPTIONS=\"([^\"]+)\"','\\1') | first }},nodev"
  # ansible doesn't escape correctly the tab character
  when: (points_register.stdout | length > 0) and '\\x09' not in item
  with_items: "{{ points_register.stdout_lines }}"