parted: Allow passing negative numbers to specify partition boundary relative to disk end (#129)

* Allow passing negative numbers to specify partition boundary relative to disk end
Fixes: https://github.com/ansible/ansible/issues/43369

* parted: unit test case, create partition with part_start: -1GiB

* fs_type parameter is not really optional for negative part_start parameter

* Revert "fs_type parameter is not really optional for negative part_start parameter"

This reverts commit 800b1cb00b.

Instead: added notes and documentation about netagive part_start and fs_type.

* include fs_type in negative part_start example
This commit is contained in:
Robert Osowiecki 2020-06-23 14:02:35 +02:00 committed by GitHub
commit ced14746a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 5 deletions

View file

@ -198,6 +198,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='unit KiB mkpart primary 0% 1GiB')
def test_create_new_partition_minus_1G(self):
set_module_args({
'device': '/dev/sdb',
'number': 4,
'state': 'present',
'fs_type': 'ext2',
'part_start': '-1GiB',
})
with patch('ansible_collections.community.general.plugins.modules.system.parted.get_device_info', return_value=parted_dict1):
self.execute_module(changed=True, script='unit KiB mkpart primary ext2 -1GiB 100%')
def test_remove_partition_number_1(self):
set_module_args({
'device': '/dev/sdb',