mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
parted module not idempotent for esp flag and name (#40547)
* parted module not idempotent for esp flag and name Fixes #40452 Currently the parted module doesn't take into account names with spaces in them which leads to non-idempotent transactions on the state of the system because the name comparison will never succeed. Also, when the esp flag is set, parted infers the boot flag and the parted module did not previously account for this. This lead to non-idempotent transactions as well. Signed-off-by: Adam Miller <admiller@redhat.com> * fix unit tests, expected command changed in the patch Signed-off-by: Adam Miller <admiller@redhat.com>
This commit is contained in:
parent
67e0df81c1
commit
bc7ff83cd9
2 changed files with 10 additions and 2 deletions
|
@ -658,10 +658,18 @@ def main():
|
|||
|
||||
# Assign name to the partition
|
||||
if name is not None and partition.get('name', None) != name:
|
||||
script += "name %s %s " % (number, name)
|
||||
# Wrap double quotes in single quotes so the shell doesn't strip
|
||||
# the double quotes as those need to be included in the arg
|
||||
# passed to parted
|
||||
script += 'name %s \'"%s"\' ' % (number, name)
|
||||
|
||||
# Manage flags
|
||||
if flags:
|
||||
# Parted infers boot with esp, if you assign esp, boot is set
|
||||
# and if boot is unset, esp is also unset.
|
||||
if 'esp' in flags and 'boot' not in flags:
|
||||
flags.append('boot')
|
||||
|
||||
# Compute only the changes in flags status
|
||||
flags_off = list(set(partition['flags']) - set(flags))
|
||||
flags_on = list(set(flags) - set(partition['flags']))
|
||||
|
|
|
@ -237,4 +237,4 @@ class TestParted(ModuleTestCase):
|
|||
'_ansible_check_mode': True,
|
||||
})
|
||||
with patch('ansible.modules.system.parted.get_device_info', return_value=parted_dict2):
|
||||
self.execute_module(changed=True, script='unit KiB mklabel gpt mkpart primary 0% 100% unit KiB name 1 lvmpartition set 1 lvm on')
|
||||
self.execute_module(changed=True, script='unit KiB mklabel gpt mkpart primary 0% 100% unit KiB name 1 \'"lvmpartition"\' set 1 lvm on')
|
||||
|
|
Loading…
Reference in a new issue