mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 21:30:22 -07:00
Add vfat support for the filesystem module (#23527)
* Add fat filesystem support fatresize is temporarily disabled * Refactor Filesystem.get_dev_size For more sharing with vFAT class * Fix filesystem tests on some OSs I think this is due to older mke2fs on those systems. * Fix vFAT command on FreeBSD newfs doesn't seem to work on image files * Refactor filesystem.grow() Split out grow_cmd generation and Device operations * Use swap as unsupported filesystem Except FreeBSD, which doesn't have mkswap * Be consistent about str(dev) vs dev.path Prefer str(dev), this works transparently with '%s' formatting. * Enable vfat resize, only test fatresize >= 1.0.4 Lower versions have a segfault bug. * Only install fatresize where available FreeBSD, OpenSUSE, RHEL and CentOS < 7 don't ship it.
This commit is contained in:
parent
67c217398c
commit
f30a08d049
5 changed files with 83 additions and 37 deletions
|
@ -11,4 +11,5 @@ tested_filesystems:
|
|||
ext2: {fssize: 10, grow: True}
|
||||
xfs: {fssize: 20, grow: False} # grow requires a mounted filesystem
|
||||
btrfs: {fssize: 100, grow: False} # grow not implemented
|
||||
vfat: {fssize: 20, grow: True}
|
||||
# untested: lvm, requires a block device
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
- name: increase fake device
|
||||
shell: 'dd if=/dev/zero bs=1M count=20 >> {{ dev }}'
|
||||
|
||||
- when: 'grow|bool'
|
||||
- when: 'grow|bool and (fstype != "vfat" or resize_vfat)'
|
||||
block:
|
||||
- name: Expand filesystem
|
||||
filesystem:
|
||||
|
@ -81,6 +81,7 @@
|
|||
- 'fs5_result is successful'
|
||||
|
||||
- import_tasks: overwrite_another_fs.yml
|
||||
when: ansible_system != 'FreeBSD'
|
||||
|
||||
always:
|
||||
- file:
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
- name: 'Recreate "disk" file'
|
||||
command: 'dd if=/dev/zero of={{ dev }} bs=1M count={{ fssize }}'
|
||||
|
||||
- name: 'Create a vfat filesystem'
|
||||
command: 'mkfs.vfat {{ dev }}'
|
||||
when: ansible_system != 'FreeBSD'
|
||||
|
||||
- name: 'Create a vfat filesystem'
|
||||
command: 'newfs_msdos -F12 {{ dev }}'
|
||||
when: ansible_system == 'FreeBSD'
|
||||
- name: 'Create a swap filesystem'
|
||||
command: 'mkswap {{ dev }}'
|
||||
|
||||
- command: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
||||
register: uuid
|
||||
|
|
|
@ -31,6 +31,20 @@
|
|||
- btrfsprogs
|
||||
when: ansible_system == 'Linux'
|
||||
|
||||
- block:
|
||||
- name: install fatresize
|
||||
package:
|
||||
name: fatresize
|
||||
state: present
|
||||
- command: fatresize --help
|
||||
register: fatresize
|
||||
- set_fact:
|
||||
fatresize_version: '{{ fatresize.stdout_lines[0] | regex_search("[0-9]+\.[0-9]+\.[0-9]+") }}'
|
||||
when:
|
||||
- ansible_system == 'Linux'
|
||||
- ansible_os_family != 'Suse'
|
||||
- ansible_os_family != 'RedHat' or (ansible_distribution == 'CentOS' and ansible_distribution_version is version('7.0', '>='))
|
||||
|
||||
- command: mke2fs -V
|
||||
register: mke2fs
|
||||
|
||||
|
@ -43,3 +57,5 @@
|
|||
# Mke2fs no longer complains if the user tries to create a file system
|
||||
# using the entire block device.
|
||||
force_creation: "{{ e2fsprogs_version is version('1.43', '<') }}"
|
||||
# Earlier versions have a segfault bug
|
||||
resize_vfat: "{{ fatresize_version|default('0.0') is version('1.0.4', '>=') }}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue