-
Notifications
You must be signed in to change notification settings - Fork 166
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
Unable to provision a host (with Libvirt/KVM) based on a qcow2 image without explicitly setting the image_id parameter. #1160
Comments
To compare, can you post the hammer call you used? |
Yes, here is an example with a Hammer CLI command. Host creation with hammer CLI
API results - examplesTo add more details, here is what I can find from With ansible modules:
image_id is well defined, so the issue is not linked to that. With Hammer CLI:
Both have one identical |
By translation do you mean i18n translation? I think you mean more "look up"? Foreman keeps images in its database, this table has image_id (SQL INT), uuid and name fields (varchar) which are used by individual compute resources. Usually, both UI and API should only need to provide image_id which Foreman than uses to look other attributes up (uuid, name). So I think this is expected, when compute resource attribute is passed (uuid or name) Foreman will merge that and pass it into the VM creation request so it actually works and this is probably a bug, but the correct way is to really find image_id first and then providing that in the request. In general, compute attributes are implemented in a weird way and @ezr-ondrej actually started an effort to improve so poking him to take this into consideration. Maybe we should create some allow list of compute resource attributes which are allowed to be passed in from UI / CLI. This also raises a concern about security, Rails have a mechanism to protect parameters from being sent into ActiveRecord, we do however appear to merge all attributes and pass them into fog. At least how I understand this, it looks like an attacker can actually pass image path directly escaping organization boundary and performing a DOS by overwriting an existing image owned by a different organization. |
Ah, sorry. "translate" was maybe a bit wrong selection of words on my side. If you look at the API requests above, Ansible sends:
While hammer sends
And it seems without the second entry, Libvirt just doesn't know what to do. My naïve assumption was that when I pass |
I would also expect that our API will lookup the image "UUID / path" or whatever we call as image_id. That smells like a bug worth fixing. |
Image selection is particulary weird as there is a select it in Host form where I select the method, but that input is actually send as This is IMHO very wrong and I might prioritize it in the ongoing compute resources cleanup, but I can't promise any delivery upon that, as I don't fully understand the process for all the compute resources. This being said, we should probably have fix here sooner. By doing eigher
|
Following the discussion, ideally this would be fixed on the Foreman side but that is not imminently expected, so we could provide a workaround here similar to what hammer is doing. Therefore I'm labeling this as a bug, although it could also be 'depends on external project' |
Yes, the field in the compute attributes is really called `image_id`. Yes, it really expects the *UUID* of the image there. Fixes: theforeman#1160
Thanks! I've opened https://projects.theforeman.org/issues/32501 to track the API side of this, and #1215 has a workaround for now. |
Yes, the field in the compute attributes is really called `image_id`. Yes, it really expects the *UUID* of the image there. Fixes: #1160
SUMMARY
I wanted to provision a VM with a Libvirt/KVM compute ressource based on an image provision method with an existing qcow2 image. I encountered an issue where the host was created but the image provisioning wasn't correctly done by using the module
host
.The result is not the same by using the hammer CLI or the foreman/satellite web UI (with identical input parameters).
Looking further and comparing with what was done by the Satellite Web UI and Hammer CLI, I found that the
host
module (python code) doesn't send theimage_id
to the API call (Note: I didn't investigate a lot, so it is a guess). I tried again by adding the parameterimage_id
directly in the module parameters (insidecompute_attributes
) and then it worked well.I guess that the Ansible module(s) / python code must perform an additional step to resolve the image_id based on the image name and send it to the API call (as it will be more user friendly if the user only has to put the image name as an input parameter).
ISSUE TYPE
ANSIBLE VERSION
COLLECTION VERSION
Repo link: https://github.com/RedHatSatellite/satellite-ansible-collection
This was not tested with the community foreman collection version.
KATELLO/FOREMAN VERSION
STEPS TO REPRODUCE
EXPECTED RESULTS
The host is created and well provisioned based on a qcow2 image.
The boot device order is based only on the first disk.
Note: Satellite will also create a virtual CDROM device for user data / cloud-init (like this example, below you will find the definition of this device for libvirt/kvm in a XML format):
ACTUAL RESULTS
The host is created but the VM is "blank" (no OS installed, etc).
The boot device order is first "network" and then "disk".
There is no virtual CDROM device created.
WORKAROUND
By adding:
It works as expected.
The text was updated successfully, but these errors were encountered: