Skip to content

Commit

Permalink
Rename the mkfs option map
Browse files Browse the repository at this point in the history
More descriptive name both for Ansible and Python variables, and
add documentation
  • Loading branch information
pcahyna committed Aug 21, 2020
1 parent b4029ed commit ae61f10
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
12 changes: 8 additions & 4 deletions 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 @@ -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 += " "
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tasks/main-blivet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion vars/CentOS_7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
3 changes: 2 additions & 1 deletion vars/RedHat_7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

0 comments on commit ae61f10

Please sign in to comment.