community / community.general / 2.5.9 / module / filesystem Makes a filesystem Authors: Alexander Bulimov (@abulimov)community.general.filesystem (2.5.9) — module
Install with ansible-galaxy collection install community.general:==2.5.9
collections: - name: community.general version: 2.5.9
This module creates a filesystem.
- name: Create a ext2 filesystem on /dev/sdb1 community.general.filesystem: fstype: ext2 dev: /dev/sdb1
- name: Create a ext4 filesystem on /dev/sdb1 and check disk blocks community.general.filesystem: fstype: ext4 dev: /dev/sdb1 opts: -cc
- name: Blank filesystem signature on /dev/sdb1 community.general.filesystem: dev: /dev/sdb1 state: absent
dev: aliases: - device description: - Target path to device or image file. required: true type: path opts: description: - List of options to be passed to mkfs command. type: str force: default: 'no' description: - If C(yes), allows to create new filesystem on devices that already has filesystem. type: bool state: choices: - present - absent default: present description: - If C(state=present), the filesystem is created if it doesn't already exist, that is the default behaviour if I(state) is omitted. - If C(state=absent), filesystem signatures on I(dev) are wiped if it contains a filesystem (as known by C(blkid)). - When C(state=absent), all other options but I(dev) are ignored, and the module doesn't fail if the device I(dev) doesn't actually exist. - C(state=absent) is not supported and will fail on FreeBSD systems. type: str version_added: 1.3.0 version_added_collection: community.general fstype: aliases: - type choices: - btrfs - ext2 - ext3 - ext4 - ext4dev - f2fs - lvm - ocfs2 - reiserfs - xfs - vfat - swap description: - Filesystem type to be created. This option is required with C(state=present) (or if I(state) is omitted). - 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 type: str 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) and C(vfat) filesystems. Attempts to resize other filesystem types will fail. - XFS Will only grow if mounted. Currently, the module is based on commands from C(util-linux) package to perform operations, so resizing of XFS is not supported on FreeBSD systems. - vFAT will likely fail if fatresize < 1.04. type: bool