Bug 1878693
| Summary: | Unable to perform image based deployment using hosts module from Red Hat Satellite Ansible Collections | ||
|---|---|---|---|
| Product: | Red Hat Satellite | Reporter: | Sayan Das <saydas> |
| Component: | Ansible Collection | Assignee: | Evgeni Golov <egolov> |
| Status: | CLOSED ERRATA | QA Contact: | Peter Ondrejka <pondrejk> |
| Severity: | high | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 6.7.0 | CC: | egolov |
| Target Milestone: | 6.8.0 | Keywords: | Triaged |
| Target Release: | Unused | ||
| Hardware: | All | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | ansible-collection-redhat-satellite-1.3.0 | Doc Type: | If docs needed, set a value |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2020-10-27 13:09:00 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
can you try the following patch against the host module?
diff --git plugins/modules/host.py plugins/modules/host.py
index 99ec2d07..e96110f8 100644
--- plugins/modules/host.py
+++ plugins/modules/host.py
@@ -221,7 +221,7 @@ def main():
owner_group=dict(type='entity', resource_type='usergroups', flat_name='owner_id'),
owner_type=dict(type='invisible'),
provision_method=dict(choices=['build', 'image', 'bootdisk']),
- image=dict(type='entity'),
+ image=dict(type='entity', scope=['compute_resource']),
compute_attributes=dict(type='dict'),
),
mutually_exclusive=[
Hello Evgeni,
Yes, that change works fine now. I can get the host created now.
$ diff collections/ansible_collections/redhat/satellite/plugins/modules/host.py collections/ansible_collections/redhat/satellite/plugins/modules/host.py_bkp
191c191
< image=dict(type='entity', scope=['compute_resource']),
---
> image=dict(type='entity'),
This resource_info module still fails to list the images with following task.
~~
- name: Get image resources
redhat.satellite.resource_info:
username: "{{ satellite_username }}"
password: "{{ satellite_password }}"
server_url: "{{ satellite_url }}"
organization: "{{ satellite_organization }}"
resource: images
register: images
ignore_errors: true
~~
Am i missing something in the task ?
(In reply to Sayan Das from comment #3) > This resource_info module still fails to list the images with following task. > ~~ > - name: Get image resources > redhat.satellite.resource_info: > username: "{{ satellite_username }}" > password: "{{ satellite_password }}" > server_url: "{{ satellite_url }}" > organization: "{{ satellite_organization }}" > resource: images > register: images > ignore_errors: true > ~~ > > Am i missing something in the task ? Yeah. So "image" objects can't be searched "as is". You need to search them scoped by another entity (that's also what the patch for the host module does, it tells our library "go, search by compute_resource"). resource_info is a rather "dumb" module, so it doesn't know that, and just throws an error at you "missing param ''operatingsystem_id'' in parameters" Now images can be scoped by three things: operatingsystems, architectures and compute_resources. I must admit scoping them by OS or arch is rather confusing, so both the "image" module and the "host" module (after the above patch) forces scoping by CR. To do the same with "resource_info", you could do smth like that: - name: Get image resources redhat.satellite.resource_info: username: "{{ satellite_username }}" password: "{{ satellite_password }}" server_url: "{{ satellite_url }}" organization: "{{ satellite_organization }}" resource: images params: compute_resource_id: 1234 register: images You'd obviously need to know the numeric ID of the CR, which you can find using… resource_info ;) FWIW, we (eng) don't consider that a bug in resource_info, but there is a long term goal to have specific _info modules for individual entities. <insert something about finite time problems here> ;) Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (Important: Satellite 6.8 release), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2020:4366 |
Description of problem: Unable to check the information about resource "images" or build a host by spcifying "image" keyword with "hosts" module from Satellite Ansible collections. Version-Release number of selected component (if applicable): Red Hat Satellite 6.7 How reproducible: Always Steps to Reproduce: 1. Create a basic satellite setup with HG\CR\CP\DHCP\TFTP\DNS etc configured. 2. Create a image in satellite UI inside the compute resource using the existing templates in your Vmware infra. 3. Create a ansible playbook using Satellite Ansible collections as displayed below to either check the information about "images" or perform a "image" based deployment and execute the same. ~~~ - name: Get image resources redhat.satellite.resource_info: username: "{{ satellite_username }}" password: "{{ satellite_password }}" server_url: "{{ satellite_url }}" organization: "{{ satellite_organization }}" resource: images register: images ignore_errors: true - debug: var=images - name: Create a host redhat.satellite.host: username: "{{ satellite_username }}" password: "{{ satellite_password }}" server_url: "{{ satellite_url }}" organization: "{{ satellite_organization }}" name: "testhost.example.com" location: "GSS" hostgroup: "satellite_image" build: true compute_profile: "Vmware-Satellite" compute_resource: "optimus" provision_method: "image" image: "RHEL7.8" state: present register: build - debug: var=build ~~~ Actual results: ~~ $ ansible-playbook test.yaml -k --vault-password-file .vault SSH password: [WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details PLAY [Test hosts modules for image based build] ***************************************************************************************************************************************** TASK [Gathering Facts] ****************************************************************************************************************************************************************** ok: [satellite.example.com] TASK [Set few facts.] ******************************************************************************************************************************************************************* ok: [satellite.example.com] TASK [Get image resources] ************************************************************************************************************************************************************** fatal: [satellite.example.com]: FAILED! => changed=false msg: 'Failed to list resource: "missing param ''operatingsystem_id'' in parameters"' ...ignoring TASK [debug] **************************************************************************************************************************************************************************** ok: [satellite.example.com] => images: changed: false failed: true msg: 'Failed to list resource: "missing param ''operatingsystem_id'' in parameters"' TASK [Create a host] ******************************************************************************************************************************************************************** fatal: [satellite.example.com]: FAILED! => changed=false msg: 'Failed to list resource: "missing param ''operatingsystem_id'' in parameters"' PLAY RECAP ****************************************************************************************************************************************************************************** satellite.example.com : ok=4 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=1 ~~ Expected results: The module should be able to find the image by looking inside associated compute resource and then the host build should be submitted successfully. Additional info: * From my prospective in both of the scenarios, It seems when the host modules tries to look for the image resource, It's not looking for the same inside "compute resource". * To demonstrate further via hammer, hammer> compute-resource image list --compute-resource optimus ---|---------|------------------|----------|--------------------------------------|---------- ID | NAME | OPERATING SYSTEM | USERNAME | UUID | USER DATA ---|---------|------------------|----------|--------------------------------------|---------- 1 | RHEL7.8 | RHEL Server 7.8 | root | 50001356-2221-54b5-a3af-94dadaad981b | false ---|---------|------------------|----------|--------------------------------------|---------- hammer> compute-resource image info --name "RHEL7.8" missing param 'operatingsystem_id' in parameters hammer> compute-resource image info --name "RHEL7.8" --compute-resource optimus Id: 1 Name: RHEL7.8 Operating System: RHEL Server 7.8 Username: root UUID: 50001356-2221-54b5-a3af-94dadaad981b User Data: false Architecture: x86_64 Created at: 2020/06/23 16:22:34 Updated at: 2020/08/25 05:49:48