[PR #7263/28b3da88 backport][stable-7] [proxmox] return vmid and taskid #7307
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a backport of PR #7263 as merged into main (28b3da8).
SUMMARY
Proxmox uses an internal ID number (
vmid
) to refer to specific containers and virtual machines.Ansible's community.general.proxmox module allows an LXC container to be created with an automatically-assigned
vmid
. However, presently (before this PR) it doesn't return the chosen ID. This means that the only way to programmatically delete a container that was programmatically created with an automatically-assigned ID involves string matching, string manipulation, and guesswork. (Some of the above logic already exists within the proxmox module, but I definitely don't trust the idea of deleting a VM based on an identifier that isn't even guaranteed unique!)Additionally, long-lived tasks such as creating/starting/updating/deleting VMs and containers are given
taskid
numbers that show up in the audit log and can be used to reference the status of the task. The community.general.proxmox does use thetaskid
to keep track of dispatched tasks, but the module doesn't return it.This PR adds
vmid
andtaskid
to the data returned by such actions, at least where it would make sense to do so. This way, for example, I can make a bunch of containers with automatically-assigned IDs and use Ansible'sregister
function to reference them later in the play.Being able to save the
taskid
may also help with other execution strategies, or for matching Ansible logs with Proxmox audit logs, or something. I'm not sure, really, but it seemed like a good idea to add it in while I was already there.ISSUE TYPE
COMPONENT NAME
proxmox
ADDITIONAL INFORMATION
This is my first contribution to Ansible, and probably my first time contributing Python code to any FOSS project! Please be gentle and be understanding if I missed anything.