Chapter 2. Managing local storage using RHEL System Roles

To manage LVM and local file systems (FS) using Ansible, you can use the storage role, which is one of the RHEL System Roles available in RHEL 8.

Using the storage role enables you to automate administration of file systems on disks and logical volumes on multiple machines and across all versions of RHEL starting with RHEL 7.7.

For more information on RHEL System Roles and how to apply them, see What RHEL System Roles are and which tasks they can be used for.

2.1. Introduction to the storage role

The storage role can manage:

  • File systems on disks which have not been partitioned
  • Complete LVM volume groups including their logical volumes and file systems

With the storage role you can perform the following tasks:

  • Create a file system
  • Remove a file system
  • Mount a file system
  • Unmount a file system
  • Create LVM volume groups
  • Remove LVM volume groups
  • Create logical volumes
  • Remove logical volumes

2.2. Storage role parameters

The section provides a table with input variables that the storage role accepts.

Table 2.1. Storage role parameters

ParameterDescriptionAdditional information

storage_volumes

List of file systems on all unpartitioned disks to be managed.

Partitions are currently unsupported.

storage_pools

List of pools to be managed.

Currently the only supported pool type is LVM. With LVM, pools represent volume groups (VGs). Under each pool there is a list of volumes to be managed by the role. With LVM, each volume corresponds to a logical volume (LV) with a file system.

storage_safe_mode

Boolean option to enable and disable safe mode.

In safe mode, the storage role does not reformat disks containing data such as file systems or LVM physical volumes, but instead the role aborts with an error message. By default, safe mode is on to prevent accidentally overwriting existing data. Red Hat recommends to keep safe mode enabled, and disable it only for specific cases and after thorough testing.

The storage role only changes file systems, volumes, and pools that are listed in the following variables:

  • storage_pools
  • storage_volumes

Additional resources

For more information, install the rhel-system-roles package, and see the /usr/share/doc/rhel-system-roles/storage/ and /usr/share/ansible/roles/rhel-system-roles.storage/ directories.