Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent parted warnings in script mode #7304

Merged

Conversation

oldmanhere
Copy link
Contributor

@oldmanhere oldmanhere commented Sep 21, 2023

SUMMARY

Add automatic answer "fix" when script mode -s is used with parted version >= 3.4.64

Comments from the project parted :
automatically answer exceptions with "fix" in script mode, which is useful for:
GPT header not including full disk size;
moving the backup GPT table to the end of the disk;
MAC fix missing partition map entry;
etc.
see: https://www.mail-archive.com/[email protected]/msg00369.html

Fixes #1653 #1461

minor_changes:

  • parted - on resize, use --fix option if available
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

parted

ADDITIONAL INFORMATION

just use -f with -s and resizepart in the same command.


Before:
When you enhance the drive on the vcenter, and refresh in the OS, the community.general.parted with resize=true hang like that:

Warning: Not all of the space available to /dev/sdx appears to be used, you can fix the GPT to use all of the space (an extra xxxxx blocks) or continue with the current setting? 
Error: Unable to satisfy all constraints on the partition.

After:
the resize is done correctly.

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR new_contributor Help guide this first time contributor plugins plugin (any type) small_patch Hopefully easy to review labels Sep 21, 2023
@oldmanhere
Copy link
Contributor Author

oldmanhere commented Sep 21, 2023

This can fix #1461 too

Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! Can you please add a changelog fragment? Thanks.

@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-6 labels Sep 22, 2023
@felixfontein
Copy link
Collaborator

felixfontein commented Sep 22, 2023

Also please note that integration tests are failing on several platforms, where parted doesn't support -f (or it doesn't support it in the situation where it is used).

"err": "/usr/sbin/parted: invalid option -- 'f'\nUsage: /usr/sbin/parted [-hlmsv] [-a] [DEVICE [COMMAND [PARAMETERS]]...]\n"

@oldmanhere
Copy link
Contributor Author

Changelog fragment added. Please modify if needed, as i'm not fluent in english.

@felixfontein
Copy link
Collaborator

@oldmanhere in case you added it you probably forgot to push it, since it isn't here :)

@oldmanhere
Copy link
Contributor Author

oldmanhere commented Sep 22, 2023

@felixfontein

I have added in the first post :

breaking_changes:
parted - resize : Use --fix option by default (Note: --fix from parted 3.5. If you use a old version, please update)

It's not what i have to do ?

@felixfontein
Copy link
Collaborator

The changelog fragment needs to be a file inside your PR, see https://docs.ansible.com/ansible/devel/community/collection_development_process.html#creating-a-changelog-fragment:

A basic changelog fragment is a .yaml or .yml file placed in the changelogs/fragments/ directory. Each file contains a yaml dict with keys like bugfixes or major_changes followed by a list of changelog entries of bugfixes or features.

But in any case, please note that your PR cannot be merged in this form since it is a breaking change, and breaking changes need a long enough deprecation period. See your policy on deprecation in #582 (comment).

To make your PR also work with older versions of parted, you can use the parted_version function (grep for it in the code of the module), and you need to figure out which version of parted added support for --fix.

@ansibullbot ansibullbot added the stale_ci CI is older than 7 days, rerun before merging label Oct 2, 2023
@oldmanhere
Copy link
Contributor Author

@felixfontein Thanks for your advice. I have adjust the code to take care of the parted version. It's no longer a 3chars patch and no more a breaking change one.

Now, i just need to understand how to amend this pr.

@ansibullbot

This comment was marked as outdated.

@ansibullbot ansibullbot added ci_verified Push fixes to PR branch to re-run CI and removed small_patch Hopefully easy to review stale_ci CI is older than 7 days, rerun before merging labels Oct 3, 2023
@ansibullbot ansibullbot removed ci_verified Push fixes to PR branch to re-run CI needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Oct 3, 2023
@ansibullbot

This comment was marked as outdated.

@ansibullbot ansibullbot added ci_verified Push fixes to PR branch to re-run CI needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Oct 3, 2023
@ansibullbot

This comment was marked as outdated.

@ansibullbot ansibullbot removed the ci_verified Push fixes to PR branch to re-run CI label Oct 3, 2023
@oldmanhere
Copy link
Contributor Author

the fragment seems to be good now.

@ansibullbot ansibullbot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Oct 3, 2023
changelogs/fragments/7304-prevent-parted-warnings.yml Outdated Show resolved Hide resolved
plugins/modules/parted.py Outdated Show resolved Hide resolved
@felixfontein
Copy link
Collaborator

Looks good as far as I can judge! I will merge next weekend if nobody objects.

@felixfontein felixfontein added backport-6 and removed check-before-release PR will be looked at again shortly before release and merged if possible. backport-6 labels Oct 8, 2023
@felixfontein felixfontein merged commit 324c22f into ansible-collections:main Oct 8, 2023
141 checks passed
@patchback
Copy link

patchback bot commented Oct 8, 2023

Backport to stable-7: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-7/324c22f6129864ea69ce866b19ca58fd8857b25c/pr-7304

Backported as #7365

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Oct 8, 2023
* 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 <[email protected]>

* Update plugins/modules/parted.py

Co-authored-by: Felix Fontein <[email protected]>

* Update parted.py - simplification

---------

Co-authored-by: Felix Fontein <[email protected]>
(cherry picked from commit 324c22f)
@felixfontein
Copy link
Collaborator

@oldmanhere thanks for your contribution!

felixfontein pushed a commit that referenced this pull request Oct 8, 2023
…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 <[email protected]>

* Update plugins/modules/parted.py

Co-authored-by: Felix Fontein <[email protected]>

* Update parted.py - simplification

---------

Co-authored-by: Felix Fontein <[email protected]>
(cherry picked from commit 324c22f)

Co-authored-by: oldmanhere <[email protected]>
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Oct 12, 2023
8.5.0

amazon.aws
~~~~~~~~~~

- ec2_ami - add support for ``org_arns`` and ``org_unit_arns`` in launch_permissions (ansible-collections/amazon.aws#1690).
- elb_application_lb_info - drop redundant ``describe_load_balancers`` call fetching ``ip_address_type`` (ansible-collections/amazon.aws#1768).

community.general
~~~~~~~~~~~~~~~~~

- cargo - add option ``executable``, which allows user to specify path to the cargo binary (ansible-collections/community.general#7352).
- cargo - add option ``locked`` which allows user to specify install the locked version of dependency instead of latest compatible version (ansible-collections/community.general#6134).
- dig lookup plugin - add TCP option to enable the use of TCP connection during DNS lookup (ansible-collections/community.general#7343).
- gitlab_group - add option ``force_delete`` (default: false) which allows delete group even if projects exists in it (ansible-collections/community.general#7364).
- ini_file - add ``ignore_spaces`` option (ansible-collections/community.general#7273).
- newrelic_deployment - add option ``app_name_exact_match``, which filters results for the exact app_name provided (ansible-collections/community.general#7355).
- onepassword lookup plugin - introduce ``account_id`` option which allows specifying which account to use (ansible-collections/community.general#7308).
- onepassword_raw lookup plugin - introduce ``account_id`` option which allows specifying which account to use (ansible-collections/community.general#7308).
- parted - on resize, use ``--fix`` option if available (ansible-collections/community.general#7304).
- pnpm - set correct version when state is latest or version is not mentioned. Resolves previous idempotency problem (ansible-collections/community.general#7339).
- proxmox - add ``vmid`` (and ``taskid`` when possible) to return values (ansible-collections/community.general#7263).
- random_string - added new ``ignore_similar_chars`` and ``similar_chars`` option to ignore certain chars (ansible-collections/community.general#7242).
- redfish_command - add new option ``update_oem_params`` for the ``MultipartHTTPPushUpdate`` command (ansible-collections/community.general#7331).
- redfish_config - add ``CreateVolume`` command to allow creation of volumes on servers (ansible-collections/community.general#6813).
- redfish_config - adding ``SetSecureBoot`` command (ansible-collections/community.general#7129).
- redfish_info - add support for ``GetBiosRegistries`` command (ansible-collections/community.general#7144).
- redfish_info - adds ``LinkStatus`` to NIC inventory (ansible-collections/community.general#7318).
- redis_info - refactor the redis_info module to use the redis module_utils enabling to pass TLS parameters to the Redis client (ansible-collections/community.general#7267).
- supervisorctl - allow to stop matching running processes before removing them with ``stop_before_removing=true`` (ansible-collections/community.general#7284).

community.libvirt
~~~~~~~~~~~~~~~~~

- virt - add `mutate_flags` parameter to enable XML mutation (add UUID, MAC addresses from existing domain) (ansible-collections/community.libvirt#142).
- virt - support ``--diff`` for ``define`` command (ansible-collections/community.libvirt#142).

community.routeros
~~~~~~~~~~~~~~~~~~

- api_info - add new ``include_read_only`` option to select behavior for read-only values. By default these are not returned (ansible-collections/community.routeros#213).
- api_info, api_modify - add support for ``address-list`` and ``match-subdomain`` introduced by RouterOS 7.7 in the ``ip dns static`` path (ansible-collections/community.routeros#197).
- api_info, api_modify - add support for ``user``, ``time`` and ``gmt-offset`` under the ``system clock`` path (ansible-collections/community.routeros#210).
- api_info, api_modify - add support for the ``interface ppp-client`` path (ansible-collections/community.routeros#199).
- api_info, api_modify - add support for the ``interface wireless`` path (ansible-collections/community.routeros#195).
- api_info, api_modify - add support for the ``iot modbus`` path (ansible-collections/community.routeros#205).
- api_info, api_modify - add support for the ``ip dhcp-server option`` and ``ip dhcp-server option sets`` paths (ansible-collections/community.routeros#223).
- api_info, api_modify - add support for the ``ip upnp interfaces``, ``tool graphing interface``, ``tool graphing resource`` paths (ansible-collections/community.routeros#227).
- api_info, api_modify - add support for the ``ipv6 firewall nat`` path (ansible-collections/community.routeros#204).
- api_info, api_modify - add support for the ``mode`` property in ``ip neighbor discovery-settings`` introduced in RouterOS 7.7 (ansible-collections/community.routeros#198).
- api_info, api_modify - add support for the ``port remote-access`` path (ansible-collections/community.routeros#224).
- api_info, api_modify - add support for the ``routing filter rule`` and ``routing filter select-rule`` paths (ansible-collections/community.routeros#200).
- api_info, api_modify - add support for the ``routing table`` path in RouterOS 7 (ansible-collections/community.routeros#215).
- api_info, api_modify - add support for the ``tool netwatch`` path in RouterOS 7 (ansible-collections/community.routeros#216).
- api_info, api_modify - add support for the ``user settings`` path (ansible-collections/community.routeros#201).
- api_info, api_modify - add support for the ``user`` path (ansible-collections/community.routeros#211).
- api_info, api_modify - finalize fields for the ``interface wireless security-profiles`` path and enable it (ansible-collections/community.routeros#203).
- api_info, api_modify - finalize fields for the ``ppp profile`` path and enable it (ansible-collections/community.routeros#217).
- api_modify - add new ``handle_read_only`` and ``handle_write_only`` options to handle the module's behavior for read-only and write-only fields (ansible-collections/community.routeros#213).
- api_modify, api_info - support API paths ``routing id``, ``routing bgp connection`` (ansible-collections/community.routeros#220).

community.vmware
~~~~~~~~~~~~~~~~

- add moid property in the return value for the module(ansible-collections/community.vmware#1855).
- add new snapshot_id option to the vmware_guest_snapshot module(ansible-collections/community.vmware#1847).

dellemc.powerflex
~~~~~~~~~~~~~~~~~

- Added Ansible role to support installation and uninstallation of Gateway.
- Added Ansible role to support installation and uninstallation of SDR.
- Added Ansible role to support installation and uninstallation of Web UI.

grafana.grafana
~~~~~~~~~~~~~~~

- Add check for Curl and failure step if Agent Version is not retrieved
- Allow alert resource provisioning in Grafana Role
- Bump cryptography from 39.0.2 to 41.0.3
- Bump cryptography from 41.0.3 to 41.0.4
- Bump semver from 5.7.1 to 5.7.2
- Bump word-wrap from 1.2.3 to 1.2.5
- Create local dashboard directory in check mode
- Create missing notification directory in Grafana Role
- Remove check_mode from create local directory task in Grafana Role
- Remove dependency on local-fs.target from Grafana Agent role
- Update CI Testing
- Update Cloud Stack Module failures
- Use 'ansible_system' env variable to detect os typ in Grafana Agent Role
- hange grafana Agent Wal and Positions Directory in Grafana Agent Role

ovirt.ovirt
~~~~~~~~~~~

- ovirt_vm - Add tpm_enabled (oVirt/ovirt-ansible-collection#722).
- storage_error_resume_behaviour - Support VM storage error resume behaviour "auto_resume", "kill", "leave_paused". (oVirt/ovirt-ansible-collection#721)
- vm_infra - Support boot disk renaming and resizing. (oVirt/ovirt-ansible-collection#705)

purestorage.flashblade
~~~~~~~~~~~~~~~~~~~~~~

- purefb_bucket_replica - Added support for cascading replica links
- purefb_info - New fields to display free space (remaining quota) for Accounts and Buckets. Space used by destroyed buckets is split out from virtual field to new destroyed_virtual field
- purefb_info - Report encryption state in SMB client policy rules
- purefb_info - Report more detailed space data from Purity//FB 4.3.0
- purefb_policy - Add deny effect for object store policy rules. Requires Purity//FB 4.3.0+
- purefb_policy - Added parameter to define object store policy description

vultr.cloud
~~~~~~~~~~~

- inventory - Added VPC/VPC 2.0 support by adding ``internal_ip`` to the attributes (vultr/ansible-collection-vultr#86).
etrombly pushed a commit to etrombly/community.general that referenced this pull request Oct 25, 2023
* 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 <[email protected]>

* Update plugins/modules/parted.py

Co-authored-by: Felix Fontein <[email protected]>

* Update parted.py - simplification

---------

Co-authored-by: Felix Fontein <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug module module new_contributor Help guide this first time contributor plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

parted: Resizing not working
3 participants