1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
# platform = multi_platform_all
# reboot = false
# strategy = configure
# complexity = low
# disruption = medium
- name: "Get nfs and nfs4 mount points, that don't have {{{ MOUNTOPTION }}}"
# 'no' before MOUNTOPTION isn't omission, it means a negation
command: findmnt --fstab --types nfs,nfs4 -O no{{{ MOUNTOPTION }}} -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 {{{ MOUNTOPTION }}} to nfs and nfs4 mount points"
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 }},{{{ MOUNTOPTION }}}"
# 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 }}"
|