25.5. Creating and mounting a file system by using the storage RHEL system role


You can use the storage RHEL system role to create and mount file systems that persist across reboots. The role automatically adds entries to /etc/fstab to ensure persistent mounting.

Prerequisites

Procedure

  1. Create a playbook file, for example, ~/playbook.yml, with the following content:

    ---
    - name: Manage local storage
      hosts: managed-node-01.example.com
      tasks:
        -name: Create and mount a file system
        ansible.builtin.include_role:
            name: redhat.rhel_system_roles.storage
        vars:
          storage_safe_mode: false
    
          storage_volumes:
            - name: barefs
              type: disk
              disks:
                - sdb
              fs_type: ext4
              fs_label: label-name
              mount_point: /mnt/data

    The settings specified in the example playbook include the following:

    disks: <list_of_devices>
    A YAML list of device names that the role uses when it creates the volume.
    fs_type: <file_system>
    Specifies the file system the role should set on the volume. You can select xfs, ext3, ext4, swap, or unformatted.
    label-name: <file_system_label>
    Optional: sets the label of the file system.
    mount_point: <directory>
    Optional: if the volume should be automatically mounted, set the mount_point variable to the directory to which the volume should be mounted.

    For details about all variables used in the playbook, see the /usr/share/ansible/roles/rhel-system-roles.storage/README.md file on the control node.

  2. Validate the playbook syntax:

    $ ansible-playbook --syntax-check ~/playbook.yml

    Note that this command only validates the syntax and does not protect against a wrong but valid configuration.

  3. Run the playbook:

    $ ansible-playbook ~/playbook.yml
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2026 Red Hat
トップに戻る