From ae61f10411a83173ac3925c99f857f556d7f3a29 Mon Sep 17 00:00:00 2001 From: Pavel Cahyna Date: Fri, 21 Aug 2020 12:54:08 +0200 Subject: [PATCH] Rename the mkfs option map More descriptive name both for Ansible and Python variables, and add documentation --- library/blivet.py | 12 ++++++++---- tasks/main-blivet.yml | 2 +- vars/CentOS_7.yml | 3 ++- vars/RedHat_7.yml | 3 ++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/library/blivet.py b/library/blivet.py index f83224bb..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) @@ -453,7 +457,7 @@ def _type_check(self): def _get_format(self): fmt = super(BlivetDiskVolume, self)._get_format() # pass -F to mke2fs on whole disks in RHEL7 - mkfs_options = mkfs_option_map.get(self._volume['fs_type']) + mkfs_options = diskvolume_mkfs_option_map.get(self._volume['fs_type']) if mkfs_options: if fmt.create_options: fmt.create_options += " " @@ -1125,7 +1129,7 @@ def run_module(): 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), - mkfs_option_map=dict(type='dict', required=False, default={})) + diskvolume_mkfs_option_map=dict(type='dict', required=False, default={})) # seed the result dict in the object result = dict( @@ -1161,8 +1165,8 @@ def run_module(): global safe_mode safe_mode = module.params['safe_mode'] - global mkfs_option_map - mkfs_option_map = module.params['mkfs_option_map'] + global diskvolume_mkfs_option_map + diskvolume_mkfs_option_map = module.params['diskvolume_mkfs_option_map'] b = Blivet() b.reset() diff --git a/tasks/main-blivet.yml b/tasks/main-blivet.yml index fec3f4d9..cdef16cb 100644 --- a/tasks/main-blivet.yml +++ b/tasks/main-blivet.yml @@ -108,7 +108,7 @@ use_partitions: "{{ storage_use_partitions }}" disklabel_type: "{{ storage_disklabel_type }}" safe_mode: "{{ storage_safe_mode }}" - mkfs_option_map: "{{ __storage_blivet_mkfs_option_map|default(omit) }}" + diskvolume_mkfs_option_map: "{{ __storage_blivet_diskvolume_mkfs_option_map|d(omit) }}" register: blivet_output - debug: diff --git a/vars/CentOS_7.yml b/vars/CentOS_7.yml index 7c13da56..f23e3d76 100644 --- a/vars/CentOS_7.yml +++ b/vars/CentOS_7.yml @@ -6,7 +6,8 @@ blivet_package_list: - libblockdev-lvm - libblockdev-mdraid - libblockdev-swap -__storage_blivet_mkfs_option_map: +# 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 7c13da56..f23e3d76 100644 --- a/vars/RedHat_7.yml +++ b/vars/RedHat_7.yml @@ -6,7 +6,8 @@ blivet_package_list: - libblockdev-lvm - libblockdev-mdraid - libblockdev-swap -__storage_blivet_mkfs_option_map: +# additional options for mkfs when creating a disk volume (whole disk fs) +__storage_blivet_diskvolume_mkfs_option_map: ext2: '-F' ext3: '-F' ext4: '-F'