From 66b69f1502d2b5f16dbee789b0f6ec1b061c5fa3 Mon Sep 17 00:00:00 2001 From: William Hirigoyen Date: Fri, 8 Dec 2023 10:11:45 +0100 Subject: [PATCH] remount-usr: do not try to remount /usr RW if /usr is not a mounted partition --- CHANGELOG.md | 1 + remount-usr/tasks/main.yml | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56b05cd2..cfd177ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ The **patch** part changes is incremented if multiple releases happen the same m * etc-git: add /var/chroot-bind/etc/bind repo * webapps/nextcloud: Set ownership and permissions of data directory * webapps/nextcloud: Add condition for config tasks +* remount-usr: do not try to remount /usr RW if /usr is not a mounted partition ### Changed diff --git a/remount-usr/tasks/main.yml b/remount-usr/tasks/main.yml index eb5c0109..18dfe6ce 100644 --- a/remount-usr/tasks/main.yml +++ b/remount-usr/tasks/main.yml @@ -1,17 +1,28 @@ --- # findmnt returns 0 on hit, 1 on miss # If the return code is higher than 1, it's a blocking failure + +- name: "check if /usr is a mountpoint" + ansible.builtin.shell: "findmnt -n /usr &> /dev/null" + register: usr_mount_exists + failed_when: False + check_mode: False + changed_when: False + - name: "check if /usr is a read-only partition" ansible.builtin.command: cmd: 'findmnt /usr --noheadings --options ro' + register: usr_partition + when: usr_mount_exists.rc == 0 changed_when: False failed_when: usr_partition.rc > 1 - check_mode: no - register: usr_partition + check_mode: False - name: "mount /usr in rw" ansible.builtin.command: cmd: 'mount -o remount,rw /usr' - changed_when: False - when: usr_partition.rc == 0 + when: + - usr_mount_exists.rc == 0 + - usr_partition.rc == 0 notify: remount usr + changed_when: False