Bug 2228828

Summary: Ansible redhat.satellite.host module is not idempotent when multiple interfaces are specified for a host
Product: Red Hat Satellite Reporter: Giovanni Formisano <gformisa>
Component: Ansible CollectionAssignee: satellite6-bugs <satellite6-bugs>
Status: NEW --- QA Contact: Satellite QE Team <sat-qe-bz-list>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.13.1CC: ehelms, satellite6-bugs
Target Milestone: UnspecifiedFlags: gformisa: needinfo? (satellite6-bugs)
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 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:

Description Giovanni Formisano 2023-08-03 11:11:34 UTC
Description of problem:
Trying to execute an ansible playbook test provisioning hosts (vmware vm) with 2 NICs with redhat.satellite.host module and running the script the second time it's failing with this error:

failed: [localhost] (item=XXXXX.yyy.net) => {"ansible_loop_var": "item", "changed": false, "error": {"errors": {"ip": ["can't be blank"], "ip6": ["can't be blank"], "primary": ["interface is already set on the host"], "provision": ["interface is already set on the host"]}, "full_messages": ["Primary interface is already set on the host", "Provision interface is already set on the host", "IP address can't be blank", "Ip6 can't be blank"], "id": null}, "item": "xxxx.yyy.net", "msg": "Error while performing create on interfaces: 422 Client Error: Unprocessable Entity for url: https://xxxx.yyy.net/api/hosts/933/interfaces"}


ansible --version
ansible 2.9.27
  config file = /root/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.8 (default, Jan 23 2023, 22:31:05) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18)]

How reproducible:

Execute playbook without compute_attributes the behaviour is still the same.Subsequent playbook execution fails with errors

Actual results:

failed: [localhost] (item=xxxx.yyy.net) => {"ansible_loop_var": "item", "changed": false, "error": {"errors": {"ip": ["can't be blank"], "ip6": ["can't be blank"], "primary": ["interface is already set on the host"], "provision": ["interface is already set on the host"]}, "full_messages": ["Primary interface is already set on the host", "Provision interface is already set on the host", "IP address can't be blank", "Ip6 can't be blank"], "id": null}, "item": "xxxx.yyy.net", "msg": "Error while performing create on interfaces: 422 Client Error: Unprocessable Entity for url: https://xxxx.yyy.net/api/hosts/933/interfaces"}
In addition - running without compute_attributes if the host doesn't exist in Satellite,there is an additional error:


failed: [localhost] (item=xxxx.yyy.net) => {"ansible_loop_var": "item", "changed": false, "error": {"errors": {"base": ["Failed to create a compute VCenter (VMware) instance xxxx.yyy.net: Unknown Network ID: \n "]}, "full_messages": ["Failed to create a compute VCenter (VMware) instance xxxx.yyy.net: Unknown Network ID: \n "], "id": 933}, "item": "xxxx.yyy.net", "msg": "Error while performing update on hosts: 422 Client Error: Unprocessable Entity for url: https://xxxx.yyy.net/api/hosts/933"}


Expected results:

Using redhat.satellite.host module, needs idempotent while creating a VM in vSphere with 2 NICs.