From 3c708285be56da28479d23ba95ce32501ae33be9 Mon Sep 17 00:00:00 2001 From: oldmanhere <79988786+oldmanhere@users.noreply.github.com> Date: Thu, 21 Sep 2023 15:36:08 -0400 Subject: [PATCH 01/12] Prevent parted warnings in script mode --- plugins/modules/parted.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/parted.py b/plugins/modules/parted.py index 1d6b8527b5d..2b2600c6c38 100644 --- a/plugins/modules/parted.py +++ b/plugins/modules/parted.py @@ -570,7 +570,7 @@ def parted(script, device, align): align_option = '' if script and not module.check_mode: - command = "%s -s -m %s %s -- %s" % (parted_exec, align_option, device, script) + command = "%s -s -f -m %s %s -- %s" % (parted_exec, align_option, device, script) rc, out, err = module.run_command(command) if rc != 0: From 3e9e231f1268cf83c2cb4388ed142ae0b26dab99 Mon Sep 17 00:00:00 2001 From: oldmanhere <79988786+oldmanhere@users.noreply.github.com> Date: Tue, 3 Oct 2023 16:04:04 -0400 Subject: [PATCH 02/12] Update parted.py with check parted version --- plugins/modules/parted.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/plugins/modules/parted.py b/plugins/modules/parted.py index 2b2600c6c38..48d844027a5 100644 --- a/plugins/modules/parted.py +++ b/plugins/modules/parted.py @@ -559,6 +559,23 @@ def parted_version(): return major, minor, rev +def check_parted_fix(): + """ + Determines if parted have option --fix (-f). Versions prior + to 3.4.64 don't have it. For more information see: + http://savannah.gnu.org/news/?id=10114 + """ + global parted_exec # pylint: disable=global-variable-not-assigned + + parted_major, parted_minor, revision = parted_version() + if (parted_major == 3 and parted_minor == 4 and revision >= 64): + return True + if (parted_major == 3 and parted_minor >= 5) or parted_major >3: + return True + + return False + + def parted(script, device, align): """ Runs a parted script. @@ -569,8 +586,13 @@ def parted(script, device, align): if align == 'undefined': align_option = '' + if check_parted_fix(): + script_option = '-s -f' + else: + script_option = '-s' + if script and not module.check_mode: - command = "%s -s -f -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: From 847aac6ee12bd6dc4f01bea1cfb60066c95e7111 Mon Sep 17 00:00:00 2001 From: oldmanhere <79988786+oldmanhere@users.noreply.github.com> Date: Tue, 3 Oct 2023 16:17:44 -0400 Subject: [PATCH 03/12] Typo --- plugins/modules/parted.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/parted.py b/plugins/modules/parted.py index 48d844027a5..9303f7b37d6 100644 --- a/plugins/modules/parted.py +++ b/plugins/modules/parted.py @@ -570,7 +570,7 @@ def check_parted_fix(): parted_major, parted_minor, revision = parted_version() if (parted_major == 3 and parted_minor == 4 and revision >= 64): return True - if (parted_major == 3 and parted_minor >= 5) or parted_major >3: + if (parted_major == 3 and parted_minor >= 5) or parted_major > 3: return True return False From add8854b3c9ffd9b58d6d9838c2d14f4f38192ee Mon Sep 17 00:00:00 2001 From: oldmanhere <79988786+oldmanhere@users.noreply.github.com> Date: Tue, 3 Oct 2023 16:31:40 -0400 Subject: [PATCH 04/12] Create 7304-prevent-parted-warnings.yml --- changelogs/fragments/7304-prevent-parted-warnings.yml | 2 ++ 1 file changed, 2 insertions(+) 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 00000000000..fdff418b900 --- /dev/null +++ b/changelogs/fragments/7304-prevent-parted-warnings.yml @@ -0,0 +1,2 @@ +minor_changes: +parted - resize : Use --fix option by default (Note: --fix from parted 3.4.64 and up. If you use a old version, the -f is not used) From 4be5038f4c2a8f07257ce1d0645dc44caf6aa6d6 Mon Sep 17 00:00:00 2001 From: oldmanhere <79988786+oldmanhere@users.noreply.github.com> Date: Tue, 3 Oct 2023 16:39:33 -0400 Subject: [PATCH 05/12] Update 7304-prevent-parted-warnings.yml --- changelogs/fragments/7304-prevent-parted-warnings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/7304-prevent-parted-warnings.yml b/changelogs/fragments/7304-prevent-parted-warnings.yml index fdff418b900..c1d0fa87ff9 100644 --- a/changelogs/fragments/7304-prevent-parted-warnings.yml +++ b/changelogs/fragments/7304-prevent-parted-warnings.yml @@ -1,2 +1,2 @@ minor_changes: -parted - resize : Use --fix option by default (Note: --fix from parted 3.4.64 and up. If you use a old version, the -f is not used) + - parted - resize : Use --fix option by default (Note: --fix from parted 3.4.64 and up. If you use a old version, the -f is not used) From 414ff614131361b4ee1c4a9fedf15a78eb6aef92 Mon Sep 17 00:00:00 2001 From: oldmanhere <79988786+oldmanhere@users.noreply.github.com> Date: Tue, 3 Oct 2023 16:49:37 -0400 Subject: [PATCH 06/12] Update 7304-prevent-parted-warnings.yml --- changelogs/fragments/7304-prevent-parted-warnings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/7304-prevent-parted-warnings.yml b/changelogs/fragments/7304-prevent-parted-warnings.yml index c1d0fa87ff9..cc1ae6488cb 100644 --- a/changelogs/fragments/7304-prevent-parted-warnings.yml +++ b/changelogs/fragments/7304-prevent-parted-warnings.yml @@ -1,2 +1,2 @@ minor_changes: - - parted - resize : Use --fix option by default (Note: --fix from parted 3.4.64 and up. If you use a old version, the -f is not used) + - parted - resize : Use --fix option by default (--fix from parted 3.4.64 and up. If you use a old version, the -f is not used) From ddc10c4ba55b870867dfcd5fcf7f190f9bd60142 Mon Sep 17 00:00:00 2001 From: oldmanhere <79988786+oldmanhere@users.noreply.github.com> Date: Tue, 3 Oct 2023 17:00:24 -0400 Subject: [PATCH 07/12] Update 7304-prevent-parted-warnings.yml --- changelogs/fragments/7304-prevent-parted-warnings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/7304-prevent-parted-warnings.yml b/changelogs/fragments/7304-prevent-parted-warnings.yml index cc1ae6488cb..dd7af223850 100644 --- a/changelogs/fragments/7304-prevent-parted-warnings.yml +++ b/changelogs/fragments/7304-prevent-parted-warnings.yml @@ -1,2 +1,2 @@ minor_changes: - - parted - resize : Use --fix option by default (--fix from parted 3.4.64 and up. If you use a old version, the -f is not used) + - parted : On resize, use --fix option if available (https://github.com/ansible-collections/community.general/pull/7304) From c128fe31c4a0ddb3b973985b7c1cd8d52f4cfecb Mon Sep 17 00:00:00 2001 From: oldmanhere <79988786+oldmanhere@users.noreply.github.com> Date: Tue, 3 Oct 2023 17:04:33 -0400 Subject: [PATCH 08/12] Update 7304-prevent-parted-warnings.yml --- changelogs/fragments/7304-prevent-parted-warnings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/7304-prevent-parted-warnings.yml b/changelogs/fragments/7304-prevent-parted-warnings.yml index dd7af223850..cc590c1618c 100644 --- a/changelogs/fragments/7304-prevent-parted-warnings.yml +++ b/changelogs/fragments/7304-prevent-parted-warnings.yml @@ -1,2 +1,2 @@ minor_changes: - - parted : On resize, use --fix option if available (https://github.com/ansible-collections/community.general/pull/7304) + - parted: On resize, use --fix option if available (https://github.com/ansible-collections/community.general/pull/7304) From 7dd74c091c8e01c27e6722769533fe7fc725b330 Mon Sep 17 00:00:00 2001 From: oldmanhere <79988786+oldmanhere@users.noreply.github.com> Date: Tue, 3 Oct 2023 17:10:35 -0400 Subject: [PATCH 09/12] Update 7304-prevent-parted-warnings.yml --- changelogs/fragments/7304-prevent-parted-warnings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/7304-prevent-parted-warnings.yml b/changelogs/fragments/7304-prevent-parted-warnings.yml index cc590c1618c..06fa368c10c 100644 --- a/changelogs/fragments/7304-prevent-parted-warnings.yml +++ b/changelogs/fragments/7304-prevent-parted-warnings.yml @@ -1,2 +1,2 @@ minor_changes: - - parted: On resize, use --fix option if available (https://github.com/ansible-collections/community.general/pull/7304) + - parted - On resize, use --fix option if available (https://github.com/ansible-collections/community.general/pull/7304) From 5a8d7c5ebbe76cfb4812223093a468268d766db2 Mon Sep 17 00:00:00 2001 From: oldmanhere <79988786+oldmanhere@users.noreply.github.com> Date: Wed, 4 Oct 2023 08:01:41 -0400 Subject: [PATCH 10/12] Update changelogs/fragments/7304-prevent-parted-warnings.yml Co-authored-by: Felix Fontein --- changelogs/fragments/7304-prevent-parted-warnings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/7304-prevent-parted-warnings.yml b/changelogs/fragments/7304-prevent-parted-warnings.yml index 06fa368c10c..9056ebde742 100644 --- a/changelogs/fragments/7304-prevent-parted-warnings.yml +++ b/changelogs/fragments/7304-prevent-parted-warnings.yml @@ -1,2 +1,2 @@ minor_changes: - - parted - On resize, use --fix option if available (https://github.com/ansible-collections/community.general/pull/7304) + - parted - on resize, use ``--fix`` option if available (https://github.com/ansible-collections/community.general/pull/7304). From a10ff178461a6d3b629e99a502f6010cd7f75341 Mon Sep 17 00:00:00 2001 From: oldmanhere <79988786+oldmanhere@users.noreply.github.com> Date: Wed, 4 Oct 2023 09:27:05 -0400 Subject: [PATCH 11/12] Update plugins/modules/parted.py Co-authored-by: Felix Fontein --- plugins/modules/parted.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/modules/parted.py b/plugins/modules/parted.py index 9303f7b37d6..bd9cce4d5c0 100644 --- a/plugins/modules/parted.py +++ b/plugins/modules/parted.py @@ -568,9 +568,7 @@ def check_parted_fix(): global parted_exec # pylint: disable=global-variable-not-assigned parted_major, parted_minor, revision = parted_version() - if (parted_major == 3 and parted_minor == 4 and revision >= 64): - return True - if (parted_major == 3 and parted_minor >= 5) or parted_major > 3: + if (parted_major, parted_minor, revision) >= (3, 4, 64): return True return False From c3e352b7ba977eb7d51792262c171c4ccca6a5f0 Mon Sep 17 00:00:00 2001 From: oldmanhere <79988786+oldmanhere@users.noreply.github.com> Date: Wed, 4 Oct 2023 09:47:43 -0400 Subject: [PATCH 12/12] Update parted.py - simplification --- plugins/modules/parted.py | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/plugins/modules/parted.py b/plugins/modules/parted.py index bd9cce4d5c0..cf821366c1a 100644 --- a/plugins/modules/parted.py +++ b/plugins/modules/parted.py @@ -559,21 +559,6 @@ def parted_version(): return major, minor, rev -def check_parted_fix(): - """ - Determines if parted have option --fix (-f). Versions prior - to 3.4.64 don't have it. For more information see: - http://savannah.gnu.org/news/?id=10114 - """ - global parted_exec # pylint: disable=global-variable-not-assigned - - parted_major, parted_minor, revision = parted_version() - if (parted_major, parted_minor, revision) >= (3, 4, 64): - return True - - return False - - def parted(script, device, align): """ Runs a parted script. @@ -584,7 +569,12 @@ def parted(script, device, align): if align == 'undefined': align_option = '' - if check_parted_fix(): + """ + 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'