mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
parted option align: undefined to maintain parted 1.8.3 compatibility (#405)
* option align: undefined to maintain parted 1.8.3 compatibility * modified argument_spec * changelog fragment for #405 * Update changelogs/fragments/405-parted_align_undefined.yml Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
ab5533022e
commit
9e28f3cceb
2 changed files with 12 additions and 5 deletions
2
changelogs/fragments/405-parted_align_undefined.yml
Normal file
2
changelogs/fragments/405-parted_align_undefined.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- "parted - added 'undefined' align option to support parted versions < 2.1 (https://github.com/ansible-collections/community.general/pull/405)."
|
|
@ -19,7 +19,8 @@ description:
|
|||
command line tool. For a full description of the fields and the options
|
||||
check the GNU parted manual.
|
||||
requirements:
|
||||
- This module requires parted version 1.8.3 and above.
|
||||
- This module requires parted version 1.8.3 and above
|
||||
- align option (except 'undefined') requires parted 2.1 and above
|
||||
- If the version of parted is below 3.1, it requires a Linux version running
|
||||
the sysfs file system C(/sys/).
|
||||
options:
|
||||
|
@ -28,9 +29,9 @@ options:
|
|||
type: str
|
||||
required: True
|
||||
align:
|
||||
description: Set alignment for newly created partitions.
|
||||
description: Set alignment for newly created partitions. Use 'undefined' for parted default aligment.
|
||||
type: str
|
||||
choices: [ cylinder, minimal, none, optimal ]
|
||||
choices: [ cylinder, minimal, none, optimal, undefined ]
|
||||
default: optimal
|
||||
number:
|
||||
description:
|
||||
|
@ -489,8 +490,12 @@ def parted(script, device, align):
|
|||
"""
|
||||
global module, parted_exec
|
||||
|
||||
align_option = '-a %s' % align
|
||||
if align == 'undefined':
|
||||
align_option = ''
|
||||
|
||||
if script and not module.check_mode:
|
||||
command = "%s -s -m -a %s %s -- %s" % (parted_exec, align, device, script)
|
||||
command = "%s -s -m %s %s -- %s" % (parted_exec, align_option, device, script)
|
||||
rc, out, err = module.run_command(command)
|
||||
|
||||
if rc != 0:
|
||||
|
@ -542,7 +547,7 @@ def main():
|
|||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
device=dict(type='str', required=True),
|
||||
align=dict(type='str', default='optimal', choices=['cylinder', 'minimal', 'none', 'optimal']),
|
||||
align=dict(type='str', default='optimal', choices=['cylinder', 'minimal', 'none', 'optimal', 'undefined']),
|
||||
number=dict(type='int'),
|
||||
|
||||
# unit <unit> command
|
||||
|
|
Loading…
Reference in a new issue