linux-system-roles.storage

Linux Storage Role

Ansible Lint Ansible Test CodeQL Markdown Lint Python Unit Test ShellCheck TFT TFT CI Test Bad Woke

This role helps you set up local storage easily with minimal configuration.

Currently, this role supports managing file systems and mount points on:

  • disks
  • LVM volume groups
  • Stratis pools

It also supports encryption (using LUKS) and RAID (using MD). However, there is limited support for managing existing devices. You can add new LVM volumes and Stratis file systems to your current setup and adjust some features on existing devices.

Requirements

See below.

Collection Requirements

This role needs some external collections. You can install them using this command:

ansible-galaxy collection install -vv -r meta/collection-requirements.yml

Role Variables

NOTE: Starting from version 1.3.0, if you don't specify certain parameters, their interpretation differs based on whether the pool/volume is new or existing. For new pools and volumes, missing parameters will use default values found in defaults/main.yml. For existing pools and volumes, missing parameters will take on their current values. To change settings in an existing pool or volume, you must explicitly state the new values.

storage_pools

The storage_pools variable is a list of pools to manage. Each pool includes a nested list of volume dictionaries as described below, along with the following keys:

  • name: Name of the pool to create or manage (e.g., an LVM volume group).
  • type: Type of pool to manage, valid options are lvm and stratis.
  • state: Either present (default) or absent. Pools set to absent will be removed; those set to present will be created or preserved.
  • grow_to_fill: If true, resizes the pool's physical volumes to match their respective device sizes. (Default: false, applicable only for LVM pools).
  • shared: If true, manages a shared volume group. Requires specific services to be configured and active (Default: false). Changing this on existing pools will remove the pool.
  • disks: List of disks used for backing storage.
  • raid_level: Manages a volume group with a RAID array. (Valid values: linear, raid0, raid1, etc.)
  • volumes: List of volumes in the pool, following the same structure as the storage_volumes variable.
  • encryption: Indicates whether the pool should be encrypted with LUKS.
  • encryption_password: Password for unlocking the LUKS volume(s).
  • encryption_key: Full path to the key file for the LUKS volume(s).
  • Other encryption-related parameters.

storage_volumes

The storage_volumes variable is a list of volumes to manage, each with the following attributes:

  • name: Name of the volume.
  • type: Type of volume used for the file system, valid options include lvm, disk, partition, or raid (default is determined by the OS).
  • state: Either present (default) or absent.
  • disks: The disks used for the file system.
  • size: Size of the file system in a human-readable format (e.g., "50GiB").
  • fs_type: Desired file system type (e.g., xfs, ext4, swap).
  • mount_point: Directory where the file system will be mounted.
  • Other volume-related parameters.

storage_safe_mode

If true (default), errors occur instead of automatically removing existing devices or formatting them.

storage_udevadm_trigger

When true (default is false), this triggers udev changes to take effect immediately, which can resolve some platform-specific issues.

Example Playbook

- name: Manage storage
  hosts: all
  roles:
    - name: linux-system-roles.storage
      storage_pools:
        - name: app
          disks:
            - sdb
            - sdc
          volumes:
            - name: shared
              size: "100 GiB"
              mount_point: "/mnt/app/shared"
              state: present
            - name: users
              size: "400g"
              fs_type: ext4
              mount_point: "/mnt/app/users"
      storage_volumes:
        - name: images
          type: disk
          disks: ["mpathc"]
          mount_point: /opt/images
          fs_label: images

rpm-ostree

Refer to README-ostree.md for details.

License

MIT

Installa
ansible-galaxy install linux-system-roles.storage
Licenza
mit
Download
96.2k
Proprietario