foreman-ansible-modules
foreman-ansible-modules copied to clipboard
storage_pod can not be set
SUMMARY
I am using compute_profile plugin to create configuration on katello. However, this plugin let the storage_pod parameter empty after problem free Ansible run
ISSUE TYPE
- Bug Report
ANSIBLE VERSION
2.9.17
COLLECTION VERSION
v2.1.0
KATELLO/FOREMAN VERSION
tfm-rubygem-katello-3.16.0.20-1.el7sat.noarch
foreman-2.1.2.25-1.el7sat.noarch
STEPS TO REPRODUCE
- name: Create compute profiles
theforeman.foreman.compute_profile:
name: "{{ item.name }}"
compute_attributes: "{{ item.compute_attributes }}"
server_url: "{{ satellite_url }}"
username: "{{ satellite_admin_username }}"
password: "{{ satellite_admin_password }}"
state: "{{ item.state | default(omit) }}"
loop: "{{ compute_profiles | default([]) }}"
when: compute_profiles is defined
no_log: yes
###here is the host_vars:
compute_profiles:
- name: Small
compute_attributes:
- compute_resource: "VMware Central Intel"
vm_attrs:
cluster: 348-CPU-DC-Cluster
resource_pool: Resources
cpus: 1
corespersocket: 1
memory_mb: 2048
firmware: bios
guest_id: rhel8_64Guest
ha: 1
scsi_controllers:
- type: ParaVirtualSCSIController
volumes_attributes:
0:
size_gb: 100
thin: false
mode: persistent
storage_pod: DatastoreCluster-Server-INTEL-VPLEX
interfaces_attributes:
0:
type: VirtualVmxnet3
network: VLAN51_DC_VM_SRV_PLT-BEK
............
EXPECTED RESULTS
Set the storage-pod parameter in my Small compute profile
ACTUAL RESULTS
Can you post the output of ansible-playbook --check --diff playbook.yml
when the profile is not yet present? And ideally another one when it is.
ansible-playbook --check --diff redhat_satellite.yml -i on_prem_environment/inventory
PLAY [redhat_satellite] ***************************************************************************************************************************************************************************************************************************************
TASK [redhat_satellite : Include tasks to configure satellite] ************************************************************************************************************************************************************************************************
included: /home/elmvp/bag-bdpa-helper/roles/redhat_satellite/tasks/satellite-config.yml for example-katello.com
TASK [redhat_satellite : Include infrastructure task] *********************************************************************************************************************************************************************************************************
included: /home/elmvp/bag-bdpa-helper/roles/redhat_satellite/tasks/infrastructure.yml for example-katello.com
TASK [redhat_satellite : Create compute profiles] *************************************************************************************************************************************************************************************************************
--- before
+++ after
@@ -1,8 +1,43 @@
{
"compute_attributes": [
- {}
+ {
+ "compute_resource_id": 3,
+ "id": -1,
+ "vm_attrs": {
+ "cluster": "348-CPU-DC-Cluster",
+ "corespersocket": 1,
+ "cpus": 1,
+ "firmware": "bios",
+ "guest_id": "rhel8_64Guest",
+ "ha": 1,
+ "interfaces_attributes": {
+ "0": {
+ "network": "dvportgroup-257",
+ "type": "VirtualVmxnet3"
+ }
+ },
+ "memory_mb": 2048,
+ "resource_pool": "Resources",
+ "scsi_controllers": [
+ {
+ "type": "ParaVirtualSCSIController"
+ }
+ ],
+ "volumes_attributes": {
+ "0": {
+ "mode": "persistent",
+ "size_gb": 100,
+ "storage_pod": "group-p666",
+ "thin": false
+ }
+ }
+ }
+ }
],
"compute_profiles": [
- {}
+ {
+ "id": -1,
+ "name": "Small"
+ }
]
}
changed: [example-katello.com] => (item={u'name': u'Small', u'compute_attributes': [{u'compute_resource': u'VMware Central Intel', u'vm_attrs': {u'resource_pool': u'Resources', u'memory_mb': 2048, u'volumes_attributes': {0: {u'size_gb': 100, u'storage_pod': u'DatastoreCluster-Server-INTEL-VPLEX', u'thin': False, u'mode': u'persistent'}}, u'interfaces_attributes': {0: {u'type': u'VirtualVmxnet3', u'network': u'VLAN51_DC_VM_SRV_PLT-BEK'}}, u'guest_id': u'rhel8_64Guest', u'firmware': u'bios', u'cpus': 1, u'scsi_controllers': [{u'type': u'ParaVirtualSCSIController'}], u'cluster': u'348-CPU-DC-Cluster', u'corespersocket': 1, u'ha': 1}}]})
PLAY RECAP ****************************************************************************************************************************************************************************************************************************************************
example-katello.com : ok=3 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
After creating the profile:
ansible-playbook --check --diff redhat_satellite.yml -i on_prem_environment/inventory
PLAY [redhat_satellite] ***************************************************************************************************************************************************************************************************************************************
TASK [redhat_satellite : Include tasks to configure satellite] ************************************************************************************************************************************************************************************************
included: /home/elmvp/bag-bdpa-helper/roles/redhat_satellite/tasks/satellite-config.yml for example-katello.com
TASK [redhat_satellite : Include infrastructure task] *********************************************************************************************************************************************************************************************************
included: /home/elmvp/bag-bdpa-helper/roles/redhat_satellite/tasks/infrastructure.yml for example-katello.com
TASK [redhat_satellite : Create compute profiles] *************************************************************************************************************************************************************************************************************
ok: [example-katello.com] => (item={u'name': u'Small', u'compute_attributes': [{u'compute_resource': u'VMware Central Intel', u'vm_attrs': {u'resource_pool': u'Resources', u'memory_mb': 2048, u'volumes_attributes': {0: {u'size_gb': 100, u'storage_pod': u'DatastoreCluster-Server-INTEL-VPLEX', u'thin': False, u'mode': u'persistent'}}, u'interfaces_attributes': {0: {u'type': u'VirtualVmxnet3', u'network': u'VLAN51_DC_VM_SRV_PLT-BEK'}}, u'guest_id': u'rhel8_64Guest', u'firmware': u'bios', u'cpus': 1, u'scsi_controllers': [{u'type': u'ParaVirtualSCSIController'}], u'cluster': u'348-CPU-DC-Cluster', u'corespersocket': 1, u'ha': 1}}]})
PLAY RECAP ****************************************************************************************************************************************************************************************************************************************************
example-katello.com: ok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
I tried with group-p666 as a storage pod name, but I got the same results. Two screenshots are attached confirming the empty storage pod field after creating the profile and the available choices.
Thanks!
Another request (sorry!)
Can you select the right pod in the UI, save it, and then again run the playbook with --diff
and show us?
Background: the output you posted implies the API did accept the pod, but if the UI disagrees, we might be using a wrong identifier or something?
ansible-playbook --check --diff redhat_satellite.yml -i on_prem_environment/inventory
PLAY [redhat_satellite] ***************************************************************************************************************************************************************************************************************************************
TASK [redhat_satellite : Include tasks to configure satellite] ************************************************************************************************************************************************************************************************
included: /home/elmvp/bag-bdpa-helper/roles/redhat_satellite/tasks/satellite-config.yml for example-katello.com
TASK [redhat_satellite : Include infrastructure task] *********************************************************************************************************************************************************************************************************
included: /home/elmvp/bag-bdpa-helper/roles/redhat_satellite/tasks/infrastructure.yml for example-katello.com
TASK [redhat_satellite : Create compute profiles] *************************************************************************************************************************************************************************************************************
--- before
+++ after
@@ -4,44 +4,30 @@
"compute_resource_id": 3,
"id": 55,
"vm_attrs": {
- "add_cdrom": "0",
- "annotation": "",
- "boot_order": [
- "network",
- "disk"
- ],
"cluster": "348-CPU-DC-Cluster",
- "corespersocket": "1",
- "cpuHotAddEnabled": "0",
- "cpus": "1",
+ "corespersocket": 1,
+ "cpus": 1,
"firmware": "bios",
"guest_id": "rhel8_64Guest",
- "hardware_version": "Default",
- "image_id": "",
+ "ha": 1,
"interfaces_attributes": {
"0": {
"network": "dvportgroup-257",
"type": "VirtualVmxnet3"
}
},
- "memoryHotAddEnabled": "0",
- "memory_mb": "2048",
- "path": "/Datacenters/BK-DC-INTEL/vm",
+ "memory_mb": 2048,
"resource_pool": "Resources",
"scsi_controllers": [
{
- "key": 1000,
"type": "ParaVirtualSCSIController"
}
],
"volumes_attributes": {
"0": {
- "controller_key": 1000,
- "datastore": null,
"mode": "persistent",
- "name": "Hard disk",
"size_gb": 100,
- "storage_pod": "DatastoreCluster-Server-INTEL-VPLEX",
+ "storage_pod": "group-p666",
"thin": false
}
}
changed: [example-katello.com] => (item={u'name': u'Small', u'compute_attributes': [{u'compute_resource': u'VMware Central Intel', u'vm_attrs': {u'resource_pool': u'Resources', u'memory_mb': 2048, u'volumes_attributes': {0: {u'size_gb': 100, u'storage_pod': u'DatastoreCluster-Server-INTEL-VPLEX', u'thin': False, u'mode': u'persistent'}}, u'interfaces_attributes': {0: {u'type': u'VirtualVmxnet3', u'network': u'VLAN51_DC_VM_SRV_PLT-BEK'}}, u'guest_id': u'rhel8_64Guest', u'firmware': u'bios', u'cpus': 1, u'scsi_controllers': [{u'type': u'ParaVirtualSCSIController'}], u'cluster': u'348-CPU-DC-Cluster', u'corespersocket': 1, u'ha': 1}}]})
PLAY RECAP ****************************************************************************************************************************************************************************************************************************************************
example-katello.com : ok=3 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
I think, the problem is, the plugin uses the pod id "group-p666" by creating or checking the pod parameter, that does not match with katello API, I think katello wants the pod name not the pod id, does it? Have a look please at the network name and compare it with the pod, the plugin uses the network id dvportgroup-257 by creating and checking which suits katello API.
Interesting, thanks!
Out of curiosity, did you try deploying a host with the "broken" (the one using the id, not name) compute profile?
I have a feeling this should work and the UI is just displaying it wrongly, but don't have a VMware to test on :(
Your feeling is right :) I used the name as pod name
storage_pod: DatastoreCluster-Server-INTEL-VPLEX
The UI does not display the pod under the profile, but while creating a virtual machine, I can see the pod under the vm configurations. In addition, the creating of new vm works.
"nice"
We'll try get access to an VMware to test this and other parameters properly and issue a fix afterwards.
cc @ezr-ondrej for "how broken is this intergration?!"
I've experienced the same problem with FAM 2.2.0. The behaviour changed probably due to https://github.com/theforeman/foreman-ansible-modules/commit/d0050d1386f93b2427b4c2b26a0eedb7a35eed08.
I can assist in debugging FAM (and Foreman) if you need someone with access to VMware.
Hello,
I've tried this change : volume['storage_pod'] = storage_pod['name']
instead of
volume['storage_pod'] = storage_pod['id']
in plugins/modules/compute_profile.py
and the storage_pod is displayed.
@evgeni Hello, I can confirm the solution from @lovilak. I have tested it with collection 3.8 and RedHat Satellite 6.10.7.
I have tested also the storage_domain with name and id It worked in both cases. storage_pod works only with name but not with id
same here, changing storage_pod['id'] to storage_pod['name'] did the trick. I've tested with collection 3.8 and foreman-3.4.1-1
Hello, I'm facing the same issue. I've a fresh installation of RH Satellite 6.14.0 (i.e. foreman-3.7.0.9-1.el8sat.noarch) and collection 3.10.0. There is any fix for this situation?
I've tried the fix suggested by @s-reimann and implemented a pull request #1686.