ansible.builtin.filesystem (v2.9.27) — module

Makes a filesystem

| "added in version" 1.2 of ansible.builtin"

Authors: Alexander Bulimov (@abulimov)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.27

Description

This module creates a filesystem.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a ext2 filesystem on /dev/sdb1
  filesystem:
    fstype: ext2
    dev: /dev/sdb1
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a ext4 filesystem on /dev/sdb1 and check disk blocks
  filesystem:
    fstype: ext4
    dev: /dev/sdb1
    opts: -cc

Inputs

    
dev:
    aliases:
    - device
    description:
    - Target path to device or image file.
    required: true

opts:
    description:
    - List of options to be passed to mkfs command.

force:
    default: 'no'
    description:
    - If C(yes), allows to create new filesystem on devices that already has filesystem.
    type: bool

fstype:
    aliases:
    - type
    choices:
    - btrfs
    - ext2
    - ext3
    - ext4
    - ext4dev
    - f2fs
    - lvm
    - ocfs2
    - reiserfs
    - xfs
    - vfat
    - swap
    description:
    - Filesystem type to be created.
    - reiserfs support was added in 2.2.
    - lvm support was added in 2.5.
    - since 2.5, I(dev) can be an image file.
    - vfat support was added in 2.5
    - ocfs2 support was added in 2.6
    - f2fs support was added in 2.7
    - swap support was added in 2.8
    required: true

resizefs:
    default: 'no'
    description:
    - If C(yes), if the block device and filesystem size differ, grow the filesystem into
      the space.
    - Supported for C(ext2), C(ext3), C(ext4), C(ext4dev), C(f2fs), C(lvm), C(xfs), C(vfat),
      C(swap) filesystems.
    - XFS Will only grow if mounted.
    - vFAT will likely fail if fatresize < 1.04.
    type: bool
    version_added: '2.0'
    version_added_collection: ansible.builtin