Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass -F to mke2fs for whole disks in RHEL #154

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion library/blivet.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
description:
- boolean indicating that we should fail rather than implicitly/automatically
removing devices or formatting
diskvolume_mkfs_option_map:
description:
- dict which maps filesystem names to additional mkfs options that should be used
when creating a disk volume (that is, a whole disk filesystem)

author:
- David Lehman ([email protected])
Expand Down Expand Up @@ -450,6 +454,19 @@ def _get_device_id(self):
def _type_check(self):
return self._device.raw_device.is_disk

def _get_format(self):
fmt = super(BlivetDiskVolume, self)._get_format()
# pass -F to mke2fs on whole disks in RHEL7
mkfs_options = diskvolume_mkfs_option_map.get(self._volume['fs_type'])
if mkfs_options:
if fmt.create_options:
fmt.create_options += " "
else:
fmt.create_options = ""
fmt.create_options += mkfs_options

return fmt

def _create(self):
self._reformat()

Expand Down Expand Up @@ -1111,7 +1128,8 @@ def run_module():
packages_only=dict(type='bool', required=False, default=False),
disklabel_type=dict(type='str', required=False, default=None),
safe_mode=dict(type='bool', required=False, default=True),
use_partitions=dict(type='bool', required=False, default=True))
use_partitions=dict(type='bool', required=False, default=True),
diskvolume_mkfs_option_map=dict(type='dict', required=False, default={}))

# seed the result dict in the object
result = dict(
Expand Down Expand Up @@ -1147,6 +1165,9 @@ def run_module():
global safe_mode
safe_mode = module.params['safe_mode']

global diskvolume_mkfs_option_map
diskvolume_mkfs_option_map = module.params['diskvolume_mkfs_option_map']

b = Blivet()
b.reset()
fstab = FSTab(b)
Expand Down
1 change: 1 addition & 0 deletions tasks/main-blivet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
use_partitions: "{{ storage_use_partitions }}"
disklabel_type: "{{ storage_disklabel_type }}"
safe_mode: "{{ storage_safe_mode }}"
diskvolume_mkfs_option_map: "{{ __storage_blivet_diskvolume_mkfs_option_map|d(omit) }}"
register: blivet_output

- debug:
Expand Down
2 changes: 1 addition & 1 deletion tests/tests_misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
- name: Verify the output when resizing with large size
assert:
that: "blivet_output.failed and
blivet_output.msg|regex_search('volume.*foo-test1.*cannot be resized from.*to.*') and
blivet_output.msg|regex_search('volume.*test1.*cannot be resized to.*') and
not blivet_output.changed"
msg: "Unexpected behavior when resizing with large size"

Expand Down
5 changes: 5 additions & 0 deletions vars/CentOS_7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ blivet_package_list:
- libblockdev-lvm
- libblockdev-mdraid
- libblockdev-swap
# additional options for mkfs when creating a disk volume (whole disk fs)
__storage_blivet_diskvolume_mkfs_option_map:
ext2: '-F'
ext3: '-F'
ext4: '-F'
5 changes: 5 additions & 0 deletions vars/RedHat_7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ blivet_package_list:
- libblockdev-lvm
- libblockdev-mdraid
- libblockdev-swap
# additional options for mkfs when creating a disk volume (whole disk fs)
__storage_blivet_diskvolume_mkfs_option_map:
ext2: '-F'
ext3: '-F'
ext4: '-F'