here is an example of what I am trying to do. In reality I have 86 different mount points across all the servers.
- hosts: vm_8
become: true
gather_facts: false
tasks:- name: add nodev to mount points
lineinfile:
path: /etc/fstab
regexp: ‘^(\S+\s+{{ item }}\s+\S+\s+)(?!(?:\S*,)?nodev(?:,\S*)?\s+)(\S+)(\s+.+)$’
line: ‘\1nodev,\2\3’
with_items:- /var/mount1
- /usr/mount2
- /var/mount3
register: mounts
- name: add nodev to mount points
- name: remount filesystems that have been changed.
shell: mount -o remount,rw {{ item }}
when: mounts.changed