From 324c22f6129864ea69ce866b19ca58fd8857b25c Mon Sep 17 00:00:00 2001 From: oldmanhere <79988786+oldmanhere@users.noreply.github.com> Date: Sun, 8 Oct 2023 06:02:51 -0400 Subject: [PATCH] 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 * Update plugins/modules/parted.py Co-authored-by: Felix Fontein * Update parted.py - simplification --------- Co-authored-by: Felix Fontein --- .../fragments/7304-prevent-parted-warnings.yml | 2 ++ plugins/modules/parted.py | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/7304-prevent-parted-warnings.yml diff --git a/changelogs/fragments/7304-prevent-parted-warnings.yml b/changelogs/fragments/7304-prevent-parted-warnings.yml new file mode 100644 index 0000000000..9056ebde74 --- /dev/null +++ b/changelogs/fragments/7304-prevent-parted-warnings.yml @@ -0,0 +1,2 @@ +minor_changes: + - parted - on resize, use ``--fix`` option if available (https://github.com/ansible-collections/community.general/pull/7304). diff --git a/plugins/modules/parted.py b/plugins/modules/parted.py index 1d6b8527b5..cf821366c1 100644 --- a/plugins/modules/parted.py +++ b/plugins/modules/parted.py @@ -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: