community.general.filesystem – Makes a filesystem
Note
This plugin is part of the community.general collection (version 3.8.3).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
To use it in a playbook, specify: community.general.filesystem
.
Requirements
The below requirements are needed on the host that executes this module.
Uses specific tools related to the fstype for creating or resizing a filesystem (from packages e2fsprogs, xfsprogs, dosfstools, and so on).
Uses generic tools mostly related to the Operating System (Linux or FreeBSD) or available on both, as
blkid
.On FreeBSD, either
util-linux
ore2fsprogs
package is required.
Parameters
Parameter |
Comments |
---|---|
Target path to block device (Linux) or character device (FreeBSD) or regular file (both). When setting Linux-specific filesystem types on FreeBSD, this module only works when applying to regular files, aka disk images. Currently Support for character devices on FreeBSD has been added in community.general 3.4.0. |
|
If Choices:
|
|
Filesystem type to be created. This option is required with ufs support has been added in community.general 3.4.0. Choices:
|
|
List of options to be passed to mkfs command. |
|
If Supported for XFS Will only grow if mounted. Currently, the module is based on commands from vFAT will likely fail if fatresize < 1.04. Choices:
|
|
If If When Choices:
|
Notes
Note
Potential filesystems on dev are checked using
blkid
. In caseblkid
is unable to detect a filesystem (and in casefstyp
on FreeBSD is also unable to detect a filesystem), this filesystem is overwritten even if force isno
.On FreeBSD systems, both
e2fsprogs
andutil-linux
packages provide ablkid
command that is compatible with this module. However, these packages conflict with each other, and only theutil-linux
package provides the command required to not fail when state=absent.This module supports check_mode.
See Also
See also
- community.general.filesize
The official documentation on the community.general.filesize module.
- ansible.posix.mount
The official documentation on the ansible.posix.mount module.
Examples
- 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
- name: Create a filesystem on top of a regular file
community.general.filesystem:
dev: /path/to/disk.img
fstype: vfat
Authors
Alexander Bulimov (@abulimov)
quidame (@quidame)