ansible-collections / community.windows

Windows community collection for Ansible
https://galaxy.ansible.com/community/windows
GNU General Public License v3.0
198 stars 153 forks source link

community.windows.win_dhcp_lease - Crashes when Chaning Mac on Existing Reservation #512

Open ai-ryanbess opened 1 year ago

ai-ryanbess commented 1 year ago

Confirmed

Can't find devel. Currently running 1.12.0

SUMMARY

When you attempt to change the mac of an existing reservation, the reservation does get updated but the code crashes right after.

ISSUE TYPE
COMPONENT NAME

https://docs.ansible.com/ansible/latest/collections/community/windows/win_dhcp_lease_module.html specifically https://github.com/ansible-collections/community.windows/blob/main/plugins/modules/win_dhcp_lease.ps1 lines 336

ANSIBLE VERSION
2.12.5
COLLECTION VERSION
1.12.0
CONFIGURATION
running from within AAP so not sure how to do this
OS / ENVIRONMENT
STEPS TO REPRODUCE

Create a DHCP reservation just like on the example.

Now change the mac and run code again. You should see the reservation update in the DHCP mmc but it should crash at line 336

EXPECTED RESULTS

Expect that the reservation be updated (which it does), have the code not crash and have a before and after output of what changed. In this example the Mac address is the only thing that changed.

ACTUAL RESULTS

"exception": "Failed to get lease information for ClientId f4-39-09-09-2b-1f from DHCP server someserver.\r\nAt line:336 char:32\r\n+ ... servation = Get-DhcpServerv4Lease -ClientId $current_lease.ClientId - ...\r\n+ ~~~~~~~~~~~~~\r\n + CategoryInfo : InvalidType: (f4-39-09-09-2b-1f:root/Microsoft/...cpServerv4Lease) [Get-DhcpServerv4Lease], CimException\r\n + FullyQualifiedErrorId : DHCP 20016,Get-DhcpServerv4Lease\r\n\r\nScriptStackTrace:\r\n\r\n", "msg": "Unhandled exception while executing module: Failed to get lease information for ClientId f4-39-09-09-2b-1f from DHCP server someserver.", "_ansible_no_log": false, "changed": false, "_ansible_delegated_vars": { "ansible_host": "someserver", "ansible_port": 5985, "ansible_user": "{{ WIN_USERNAME }}", "ansible_connection": "winrm" } }