Skip to content

Commit

Permalink
[PR #7304/324c22f6 backport][stable-7] Prevent parted warnings in scr…
Browse files Browse the repository at this point in the history
…ipt mode (#7365)

Prevent parted warnings in script mode (#7304)

* Prevent parted warnings in script mode

* Update parted.py with check parted version

* Typo

* Create 7304-prevent-parted-warnings.yml

* Update 7304-prevent-parted-warnings.yml

* Update 7304-prevent-parted-warnings.yml

* Update 7304-prevent-parted-warnings.yml

* Update 7304-prevent-parted-warnings.yml

* Update 7304-prevent-parted-warnings.yml

* Update changelogs/fragments/7304-prevent-parted-warnings.yml

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

* Update plugins/modules/parted.py

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

* Update parted.py - simplification

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 324c22f)

Co-authored-by: oldmanhere <79988786+oldmanhere@users.noreply.github.com>
  • Loading branch information
patchback[bot] and oldmanhere authored Oct 8, 2023
1 parent 8385d2e commit ef8fb88
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/7304-prevent-parted-warnings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- parted - on resize, use ``--fix`` option if available (https://github.com/ansible-collections/community.general/pull/7304).
12 changes: 11 additions & 1 deletion plugins/modules/parted.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,18 @@ def parted(script, device, align):
if align == 'undefined':
align_option = ''

"""
Use option --fix (-f) if available. Versions prior
to 3.4.64 don't have it. For more information see:
http://savannah.gnu.org/news/?id=10114
"""
if parted_version() >= (3, 4, 64):
script_option = '-s -f'
else:
script_option = '-s'

if script and not module.check_mode:
command = "%s -s -m %s %s -- %s" % (parted_exec, align_option, device, script)
command = "%s %s -m %s %s -- %s" % (parted_exec, script_option, align_option, device, script)
rc, out, err = module.run_command(command)

if rc != 0:
Expand Down

0 comments on commit ef8fb88

Please sign in to comment.