-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Proxmox module refactoring #9225
base: main
Are you sure you want to change the base?
Proxmox module refactoring #9225
Conversation
@Lithimlin this PR contains the following merge commits: Please rebase your branch to remove these commits. |
6fcef97
to
c2ffd98
Compare
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Lithimlin thanks for your contribution!
I would recommend breaking this PR into smaller pieces, as it seems to contain both bugfixes as well as new features. Additionally, we must not use type hints, as Ansible still provides support for Python 2.7 - it's quite a nuisance, but that should be the case until that support is dropped, I want to say end of next year but I am not sure right now.
@@ -0,0 +1,12 @@ | |||
minor_changes: | |||
- proxmox - refactors the proxmox module |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- proxmox - refactors the proxmox module | |
- proxmox - refactors the proxmox module (https://github.com/ansible-collections/community.general/pull/9225). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was not solved (missing the punctuation by the end of the line).
try: | ||
proxmox.run() | ||
except Exception as e: | ||
module.fail_json(msg="An error occurred: %s" % to_native(e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to consider using ModuleHelper
. See more in https://docs.ansible.com/ansible/latest/collections/community/general/docsite/guide_modulehelper.html
Particularly for this module, I would recommend using StateModuleHelper
, as it is already tailored for modules with different behaviour for each state
.
There is a number of modules already using these helpers, you can spot them using
git grep -E '\(\S*ModuleHelper\)'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see this comment for a reply
The last 2 versions of core already dropped support for 2.7 and 2.16 will be EOL in May 2025 |
Yes, but community.general still supports ansible-core 2.15. Felix mentioned the deadline more than once but it will be late next year - far enough into the future to be forgotten. Until then, in the collection, we must support Python 2.7. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I had approved it before, but will mark it "Request changes" to prevent other maintainers from accidentally merging it as-is now. Also, on second thought, this is quite a big revamp, so it would benefit from a more thorough examination before we merge it. I approved it before (and I should not, because the changelog needed fixing) and, days later, I cannot recall what I have seen here or not. I'm writing this to manage the expectations - this PR might take a tad longer to be merged - but please bear with us.
Yes, that would be great. While I have tested quite a few cases, I can't test all corner cases that might occur in my current setup. Having more people take a look at this and run some tests would be great. I will also take a look at the |
Sweet. Thanks for your patience.
There is proper documentation at: https://docs.ansible.com/ansible/latest/collections/community/general/docsite/guide_modulehelper.html (unless that's what you are referring to, in which case I would gladly take suggestions on how to improve those docs) |
We drop support for one ansible-core version per major release (unless we forget to do it, like for 9.0.0, and then we dropped two in 10.0.0 ;) ). We support all ansible-core versions that have not been EOL for more than a short time when we release a new major version. Since ansible-core 2.16 becomes EOL in May 2025, around when we have a new major release (11.0.0), we'll only drop support for it in the next major release (12.0.0, in ~November 2025). Only from that point on Python 2.7 is no longer supported by community.general. |
I've looked at a re-design using the I would like to change the implementation to one using the |
SUMMARY
This pull request refactors the historically grown
proxmox
module.The control flow was very opaque with some redundant checks and - most recently - features that were only introduced in parts of the module when they intended to target the whole module (see #9065).
This refactor aims to make the module more readable and more easily extendable.
Additionally, this request contains various bug fixes:
disk_volume
key is now properly parsed and passed on to the APIupdate=False
is now deprecated and will be changed toupdate=True
in version 11.0.0proxmox
utils module: The parameterchoose_first_if_multiple
ofget_vmid
is now used correctly, causing the function to return the first of multiple matches instead of failing.ISSUE TYPE
COMPONENT NAME
proxmox
ADDITIONAL INFORMATION
The following playbook should run correctly on both the old and refactored versions of this module, but the template creation will not be idempotent on the old version: