Initial commit
This commit is contained in:
68
roles/extroot/tasks/fstab.yml
Normal file
68
roles/extroot/tasks/fstab.yml
Normal file
@@ -0,0 +1,68 @@
|
||||
---
|
||||
# Get rootfs block device name
|
||||
- name: Get rootfs block device name
|
||||
ansible.builtin.command:
|
||||
cmd: 'sed -n -e "/\s\/overlay\s.*$/s///p" /etc/mtab'
|
||||
register: rootfs_block_device_name
|
||||
changed_when: rootfs_block_device_name.rc != 0
|
||||
|
||||
# Set rootfs block device name fact
|
||||
- name: Set rootfs block device name fact
|
||||
ansible.builtin.set_fact:
|
||||
block_device_name: "{{ rootfs_block_device_name.stdout }}"
|
||||
|
||||
# Mount rootfs data to another directory
|
||||
- name: Mount rootfs data to another directory
|
||||
block:
|
||||
# Add new mount point for root
|
||||
- name: Add new mount point for root
|
||||
uci:
|
||||
command: "add"
|
||||
config: "fstab"
|
||||
section: "rwm"
|
||||
type: "mount"
|
||||
|
||||
# Configure new mount point for root
|
||||
- name: Configure new mount point for root
|
||||
uci:
|
||||
command: "set"
|
||||
config: "fstab"
|
||||
section: "rwm"
|
||||
type: "mount"
|
||||
value:
|
||||
device: "{{ block_device_name }}"
|
||||
target: "/rwm"
|
||||
|
||||
# Get external USB device UUID
|
||||
- name: Get external usb device uuid
|
||||
ansible.builtin.command:
|
||||
cmd: 'block info /dev/{{ extroot_device }}1 | grep -o -e "UUID=\S*"'
|
||||
register: external_usb_device_uuid
|
||||
changed_when: external_usb_device_uuid.rc != 0
|
||||
|
||||
# Set external usb device uuid fact
|
||||
- name: Set external usb device uuid fact
|
||||
ansible.builtin.set_fact:
|
||||
usb_device_uuid: '{{ external_usb_device_uuid.stdout | regex_search(''(?<=")(.*?)(?=")'') }}'
|
||||
|
||||
# Mount external USB as overlayfs
|
||||
- name: Mount external usb as overlayfs
|
||||
block:
|
||||
# Add overlay mount point
|
||||
- name: Add overlay mount point
|
||||
uci:
|
||||
command: "add"
|
||||
config: "fstab"
|
||||
section: "overlay"
|
||||
type: "mount"
|
||||
|
||||
# Configure overlay mount point
|
||||
- name: Configure overlay mount point
|
||||
uci:
|
||||
command: "set"
|
||||
config: "fstab"
|
||||
section: "overlay"
|
||||
type: "mount"
|
||||
value:
|
||||
uuid: "{{ usb_device_uuid }}"
|
||||
target: "/overlay"
|
||||
Reference in New Issue
Block a user