diff --git a/library/blivet.py b/library/blivet.py index 6541e415..cb48e716 100644 --- a/library/blivet.py +++ b/library/blivet.py @@ -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 (dlehman@redhat.com) @@ -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() @@ -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( @@ -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) diff --git a/tasks/main-blivet.yml b/tasks/main-blivet.yml index 0dc27ccd..cdef16cb 100644 --- a/tasks/main-blivet.yml +++ b/tasks/main-blivet.yml @@ -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: diff --git a/tests/tests_misc.yml b/tests/tests_misc.yml index c57efd49..c1b131a8 100644 --- a/tests/tests_misc.yml +++ b/tests/tests_misc.yml @@ -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" diff --git a/vars/CentOS_7.yml b/vars/CentOS_7.yml index af7ed4af..f23e3d76 100644 --- a/vars/CentOS_7.yml +++ b/vars/CentOS_7.yml @@ -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' diff --git a/vars/RedHat_7.yml b/vars/RedHat_7.yml index af7ed4af..f23e3d76 100644 --- a/vars/RedHat_7.yml +++ b/vars/RedHat_7.yml @@ -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'