parted: consider current partition state even in check_mode (#247)

* parted: consider current partition state even in check_mode

* Update changelogs/fragments/183-parted_check_mode.yml

Co-Authored-By: Andrew Klychkov <aaklychkov@mail.ru>

* Test check_mode considers get_device_info

* fixed pep8 E302: expected 2 blank lines

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
This commit is contained in:
Robert Osowiecki 2020-05-23 09:15:20 +02:00 committed by GitHub
commit eb941c30b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 3 deletions

View file

@ -632,11 +632,13 @@ def main():
changed = True
script = ""
current_parts = get_device_info(device, unit)['partitions']
if not module.check_mode:
current_parts = get_device_info(device, unit)['partitions']
if part_exists(current_parts, 'num', number) or module.check_mode:
partition = {'flags': []} # Empty structure for the check-mode
if not module.check_mode:
if changed and module.check_mode:
partition = {'flags': []} # Empty structure for the check-mode
else:
partition = [p for p in current_parts if p['num'] == number][0]
# Assign name to the partition