Add ability to resize existing partition (#773)

* Add ability to resize existing partition

* Add 'resize' flag to support backwards compatability, and allow partition reduction

* Add changelog fragment for #773

* Update changelogs/fragments/773-resize-partition.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/system/parted.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update resize flag with PR review comments

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>

* Update plugins/modules/system/parted.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update default on resize flag in parted.py

* Apply suggestions from code review

Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
This commit is contained in:
jake2184 2020-11-21 20:18:42 +00:00 committed by GitHub
parent 0a28a0c8b0
commit 8f99f9cb1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 0 deletions

View file

@ -206,6 +206,17 @@ class TestParted(ModuleTestCase):
with patch('ansible_collections.community.general.plugins.modules.system.parted.get_device_info', return_value=parted_dict1):
self.execute_module(changed=True, script='rm 1')
def test_resize_partition(self):
set_module_args({
'device': '/dev/sdb',
'number': 3,
'state': 'present',
'part_end': '100%',
'resize': True
})
with patch('ansible_collections.community.general.plugins.modules.system.parted.get_device_info', return_value=parted_dict1):
self.execute_module(changed=True, script='resizepart 3 100%')
def test_change_flag(self):
# Flags are set in a second run of parted().
# Between the two runs, the partition dict is updated.