ansible-roles/remount-usr/tasks/main.yml
William Hirigoyen 66b69f1502
All checks were successful
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2655|22|2633|15|:-1: Reference build: <a href="https://jenkins.evolix.org/job/gitea/job/ansible-roles/job/unstable/427//ansiblelint">Evolix » ansible-roles » unstable #427</a>
gitea/ansible-roles/pipeline/head This commit looks good
remount-usr: do not try to remount /usr RW if /usr is not a mounted partition
2023-12-11 10:46:04 +01:00

29 lines
760 B
YAML

---
# 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: False
- name: "mount /usr in rw"
ansible.builtin.command:
cmd: 'mount -o remount,rw /usr'
when:
- usr_mount_exists.rc == 0
- usr_partition.rc == 0
notify: remount usr
changed_when: False