From a7b96d9f676285c7d325e34f0266f0de2808ad34 Mon Sep 17 00:00:00 2001 From: Jeremy Dubois Date: Thu, 15 Oct 2020 09:57:02 +0200 Subject: [PATCH] Fstab : we now also add noatime to each partitions --- roles/base/handlers/main.yml | 27 +++++++++++++++- roles/base/tasks/fstab.yml | 62 +++++++++++++++++++++++++++++++++++- 2 files changed, 87 insertions(+), 2 deletions(-) diff --git a/roles/base/handlers/main.yml b/roles/base/handlers/main.yml index 7d18f17..13c34bc 100644 --- a/roles/base/handlers/main.yml +++ b/roles/base/handlers/main.yml @@ -2,7 +2,32 @@ - name: newaliases shell: smtpctl update table aliases -- name: remount /tmp +- name: remount / noatime + command: mount -u -o noatime / + args: + warn: false + +- name: remount /var noatime + command: mount -u -o noatime /var + args: + warn: false + +- name: remount /usr noatime + command: mount -u -o noatime /usr + args: + warn: false + +- name: remount /tmp noexec command: mount -u -o noexec /tmp args: warn: false + +- name: remount /tmp noatime + command: mount -u -o noatime /tmp + args: + warn: false + +- name: remount /home noatime + command: mount -u -o noatime /home + args: + warn: false diff --git a/roles/base/tasks/fstab.yml b/roles/base/tasks/fstab.yml index 64bf644..23a9af9 100644 --- a/roles/base/tasks/fstab.yml +++ b/roles/base/tasks/fstab.yml @@ -19,6 +19,18 @@ tags: - fstab +- name: / partition is customized - noatime + replace: + dest: /etc/fstab + regexp: '([^#]\s+/\s+ffs\s+rw)(\S*)(\s+.*)' + replace: '\1\2,noatime\3' + notify: remount / noatime + when: + - fstab_content.stdout | regex_search('\s/\s') + - not (fstab_content.stdout | regex_search('\s+/\s+ffs\s+rw\S*noatime')) + tags: + - fstab + - name: /var partition is customized - softdep replace: dest: /etc/fstab @@ -30,6 +42,18 @@ tags: - fstab +- name: /var partition is customized - noatime + replace: + dest: /etc/fstab + regexp: '([^#]\s+/var\s+ffs\s+rw)(\S*)(\s+.*)' + replace: '\1\2,noatime\3' + notify: remount /var noatime + when: + - fstab_content.stdout | regex_search('\s/var\s') + - not (fstab_content.stdout | regex_search('\s+/var\s+ffs\s+rw\S*noatime')) + tags: + - fstab + - name: /usr partition is customized - softdep replace: dest: /etc/fstab @@ -41,11 +65,24 @@ tags: - fstab +- name: /usr partition is customized - noatime + replace: + dest: /etc/fstab + regexp: '([^#]\s+/usr\s+ffs\s+rw)(\S*)(\s+.*)' + replace: '\1\2,noatime\3' + notify: remount /usr noatime + when: + - fstab_content.stdout | regex_search('\s/usr\s') + - not (fstab_content.stdout | regex_search('\s+/usr\s+ffs\s+rw\S*noatime')) + tags: + - fstab + - name: /tmp partition is customized - noexec replace: dest: /etc/fstab regexp: '([^#]\s+/tmp\s+ffs\s+rw(,softdep)*)(.*)' replace: '\1,noexec\3' + notify: remount /tmp noexec when: - fstab_content.stdout | regex_search('\s/tmp\s') - not (fstab_content.stdout @@ -58,7 +95,6 @@ dest: /etc/fstab regexp: '([^#]\s+/tmp\s+ffs\s+rw)(.*)' replace: '\1,softdep\2' - notify: remount /tmp when: - fstab_content.stdout | regex_search('\s/tmp\s') - not (fstab_content.stdout @@ -66,6 +102,18 @@ tags: - fstab +- name: /tmp partition is customized - noatime + replace: + dest: /etc/fstab + regexp: '([^#]\s+/tmp\s+ffs\s+rw)(\S*)(\s+.*)' + replace: '\1\2,noatime\3' + notify: remount /tmp noatime + when: + - fstab_content.stdout | regex_search('\s/tmp\s') + - not (fstab_content.stdout | regex_search('\s+/tmp\s+ffs\s+rw\S*noatime')) + tags: + - fstab + - name: /home partition is customized - softdep replace: dest: /etc/fstab @@ -76,3 +124,15 @@ - not (fstab_content.stdout | regex_search('\s+/home\s+ffs\s+rw,softdep')) tags: - fstab + +- name: /home partition is customized - noatime + replace: + dest: /etc/fstab + regexp: '([^#]\s+/home\s+ffs\s+rw)(\S*)(\s+.*)' + replace: '\1\2,noatime\3' + notify: remount /home noatime + when: + - fstab_content.stdout | regex_search('\s/home\s') + - not (fstab_content.stdout | regex_search('\s+/home\s+ffs\s+rw\S*noatime')) + tags: + - fstab