Hey all,
Interesting question here. I want to remove the string noexec out of a line in my /etc/fstab. In this instance, I only want it to be in the /tmp line.
I was thinking a replace module, but not sure about a regexp that would work. Any thoughts?
Try this:
tasks:
- slurp:
src: /etc/fstab
register: fstab64
- set_fact:
tmp_parts: "{{ (fstab64.content|b64decode |
regex_search('.*\\S+\\s+\/tmp\\s+\\S+\\s+.*')).split() }}"
- mount:
fstab: /etc/fstab
state: present
path: "{{ tmp_parts[1] }}"
src: "{{ tmp_parts[0] }}"
opts: "{{ tmp_parts[3].split(',')|difference(['noexec'])|join(',') }}"
fstype: "{{ tmp_parts[2] }}"
Hey,
You could use the lineinfile-module.
With something like:
lineinfile:
regexp: “^/dev/mapper/vg_rhel-var_tmp”
line: “/dev/mapper/vg_rhel-var_tmp /var/tmp xfs defaults,noexec,nosuid,nodev 0 0”
Take into account that the regexp definition has to match before and after replacement
Cheers
Lars
Of course I made a copy&paste error:
the line definition must be without the noexec then