ansible-collections / community.windows

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

win_product_facts returning list instead of string #540

Open Yannik opened 8 months ago

Yannik commented 8 months ago
SUMMARY

As far as my understanding goes, win_product_facts should provide information about the windows operating system licensing status. This is further supported by the logic to retrieve the product key, which only results in one product key, the one of the windows operating system. Finally, the returned facts description also indicates that ansible_os_license_edition, ansible_os_license_status and ansible_os_license_channel should contain a string regarding the windows operating system licensing state.

However, I have noticed that when microsoft office is installed, win_product_facts actually sets ansible_os_license_edition, ansible_os_license_status and ansible_os_license_channel to an array which contains information about both windows and ms office.

Using the examples from the module page:

TASK [windows-activation : Display Windows edition] ************************************************
ok: [myhost] => 
  ansible_os_license_edition:
  - Windows(R), Professional edition
  - Office 16, Office16StandardVL_KMS_Client edition

TASK [windows-activation : Display Windows license status] *****************************************
ok: [myhost] => 
  ansible_os_license_status:
  - Licensed
  - Licensed

The reason for this is the Get-CimInstance SoftwareLicensingProduct | Where-Object PartialProductKey command, which can return more than one result. It would be sensible to append a Where-Object Name -match Windows filter.

ISSUE TYPE
COMPONENT NAME

win_product_facts