Use UUID for mounted SwiftRawDisks

When SwiftRawDisks is set, try to mount the disks using uuids instead of
paths. This makes mounts more stable, eg. if a kernel gets updates and
device orders are changed.

This patch will also update existing entries in /etc/fstab and replaces
the device path with the corresponding UUID.

Change-Id: I275b962447015e804638ccf85c63a22d1bb6e3d6
(cherry picked from commit 6206d19592)
This commit is contained in:
Christian Schwede 2020-08-21 06:57:01 +02:00 committed by Giulio Fidente
parent 8474feba63
commit ea0cd3c37e
2 changed files with 13 additions and 1 deletions

View File

@ -633,10 +633,16 @@ outputs:
opts: -f -i size=1024
with_items: "{{ swift_raw_disks }}"
when: swift_raw_disks
- name: Refresh facts if SwiftRawDisks is set to get uuids if newly created partitions
setup:
gather_subset:
- '!all'
- 'hardware'
when: swift_raw_disks
- name: Mount devices defined in SwiftRawDisks
mount:
name: /srv/node/{{ item }}
src: "{{ swift_raw_disks[item]['base_dir']|default('/dev') }}/{{ item }}"
src: "{% if lsblk.results['uuids'][item] is defined %}UUID={{ ansible_device_links['uuids'][item][0] }}{% else %}{{ swift_raw_disks[item]['base_dir']|default('/dev') }}/{{ item }}{% endif %}"
fstype: xfs
opts: noatime
state: mounted

View File

@ -0,0 +1,6 @@
---
features:
- |
When SwiftRawDisks is set, try to mount the disks using uuids instead of
paths. This makes mounts more stable, eg. if a kernel gets updates and
device orders are changed.