Menu Close

Chapter 45. Creating and mounting ext4 file systems using RHEL System Roles

This section describes how to create an ext4 file system with a given label on a disk, and persistently mount the file system using the storage role.

Prerequisites

  • An Ansible playbook including the storage role exists.

For information on how to apply such a playbook, see Applying a role.

45.1. Example Ansible playbook to create and mount an Ext4 file system

This section provides an example Ansible playbook. This playbook applies the Storage role to create and mount an Ext4 file system.

Example 45.1. A playbook that creates Ext4 on /dev/sdb and mounts it at /mnt/data

---
- hosts: all
  vars:
    storage_volumes:
      - name: barefs
        type: disk
        disks:
          - sdb
        fs_type: ext4
        fs_label: label-name
        mount_point: /mnt/data
  roles:
    - rhel-system-roles.storage
  • The playbook creates the file system on the /dev/sdb disk.
  • The playbook persistently mounts the file system at the /mnt/data directory.
  • The label of the file system is label-name.

Additional resources

  • The /usr/share/ansible/roles/rhel-system-roles.storage/README.md file.

45.2. Additional resources