Summary
The vm_nic module does not update the connected field on an existing NIC. When connected: false is passed (with either state: set or state: present) on a NIC that is currently connected, the module returns changed=false and leaves the NIC in its original state.
Steps to Reproduce
- name: Disconnect NICscale_computing.hypercore.vm_nic:
vm_name: my-vmitems:
- vlan: 164type: virtioconnected: falsestate: setVM has one NIC: type=virtio, vlan=164, connected=true (verified via REST API and HyperCore UI before task runs).Expected BehaviorThe NIC's connected field should be set to false. Task should report changed=true.Actual BehaviorTask reports changed=false. NIC remains connected=true. Module output with -vvv:
TASK [Disconnect NIC]ok: [my-vm] => {"changed": false,"diff": {"after": [],"before": []},"records": [],"vm_name": "my-vm"}diff.before and diff.after are both empty lists, indicating connected is not included in the idempotency comparison.Despite correct arguments being received by the module:
"items": [{"connected": false,"mac": null,"type": "virtio","vlan": 164,"vlan_new": null,"vm_uuid": "aa856228-..."}]Also Tested with state: present
- scale_computing.hypercore.vm_nic:
vm_name: my-vmitems:
- vlan: 164type: virtioconnected: falsestate: presentSame result: changed=false, NIC remains connected.EnvironmentCollection: scale_computing.hypercore (latest)HyperCore ICOS: 9.xAnsible: ansible-core 2.16.xSuspected Root CauseThe ManageVMNics class in plugins/module_utils/vm.py does not include connected when comparing desired NIC state against current NIC state. The diff computation returns empty lists because connected is excluded from the idempotency comparison.No integration test exists for toggling connected on an existing NIC. tests/integration/targets/vm_nic/tasks/02_vm_nic_running.yml covers NIC creation, VLAN changes, MAC changes, and deletion — but not connected: false on a live NIC.WorkaroundDirect REST API PATCH works correctly:
- name: Disconnect NIC via REST API (workaround)ansible.builtin.uri:
url: "https://{{ sc_host }}/rest/v1/VirDomainNetDevice/{{ nic_uuid }}"method: PATCHurl_username: "{{ sc_username }}"url_password: "{{ sc_password }}"force_basic_auth: truevalidate_certs: falsebody_format: jsonbody:
connected: falsestatus_code: 200NIC UUID is available via vm_info → nics[].uuid.Suggested FixInclude connected in the NIC comparison logic in ManageVMNics so a change in connected state is detected and results in a PATCH to the NIC endpoint.Add an integration test case to 02_vm_nic_running.yml that:
Creates a VM with connected: trueRuns vm_nic with connected: false, asserts changed=trueQueries the VM and asserts NIC is now connected: falseRuns the same task again and asserts changed=false (idempotency)
Summary
The
vm_nicmodule does not update theconnectedfield on an existing NIC. Whenconnected: falseis passed (with eitherstate: setorstate: present) on a NIC that is currently connected, the module returnschanged=falseand leaves the NIC in its original state.Steps to Reproduce