Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win_product_facts: The module doesn't return correctly the product id #247

Closed
sky-joker opened this issue May 14, 2021 · 0 comments · Fixed by #251
Closed

win_product_facts: The module doesn't return correctly the product id #247

sky-joker opened this issue May 14, 2021 · 0 comments · Fixed by #251

Comments

@sky-joker
Copy link
Contributor

SUMMARY

I got the product id of Windows 10 with the win_product_facts module after I installed a KMS client key to Windows 10, but the id was wrong.
I installed the key is W269N-WFGWX-YVC9B-4J6C9-T83GX, but I actually got R3HB7-X6HMH-F48J3-8XJVP-9QBP9.
https://docs.microsoft.com/en-us/windows-server/get-started/kmsclientkeys#windows-10-all-supported-semi-annual-channel-versions

That is the following result.

192.168.10.63 | SUCCESS => {
    "ansible_facts": {
        "ansible_os_license_channel": "Volume:GVLK",
        "ansible_os_license_edition": "Windows(R), Professional edition",
        "ansible_os_license_status": "Notification",
        "ansible_os_product_id": "00331-10000-00001-AA171",
        "ansible_os_product_key": "R3HB7-X6HMH-F48J3-8XJVP-9QBP9"
    },
    "changed": false
}

I seem that the cause of the issue is the converting process of the product id has an issue.

if ($data) {
$product_key = $null
$hexdata = $data[52..66]
$chardata = "B","C","D","F","G","H","J","K","M","P","Q","R","T","V","W","X","Y","2","3","4","6","7","8","9"
# Decode base24 binary data
for ($i = 24; $i -ge 0; $i--) {
$k = 0
for ($j = 14; $j -ge 0; $j--) {
$k = $k * 256 -bxor $hexdata[$j]
$hexdata[$j] = [math]::truncate($k / 24)
$k = $k % 24
}
$product_key = $chardata[$k] + $product_key
if (($i % 5 -eq 0) -and ($i -ne 0)) {
$product_key = "-" + $product_key
}
}
}

ISSUE TYPE
  • Bug Report
COMPONENT NAME

plugins/modules/win_product_facts.ps1

ANSIBLE VERSION
# ansible --version
ansible 2.10.9
CONFIGURATION
# ansible-config dump --only-changed
COLLECTIONS_PATHS(/root/community.windows/PR/xxx/ansible.cfg) = ['/root/community.windows/PR/xxx/collections']
OS / ENVIRONMENT

Windows 10 Professional

STEPS TO REPRODUCE

I executed the following command.

# ansible all -i inventory.yml -m community.windows.win_product_facts -u administrator -k
SSH password:
EXPECTED RESULTS

The module gets correctly the product id.

ACTUAL RESULTS

The module doesn't get correctly the product id.

sky-joker added a commit to sky-joker/community.windows that referenced this issue May 15, 2021
jborean93 pushed a commit that referenced this issue Jun 19, 2021
…vert a product id (#251)

* fix issue247 #247

* add changelog file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant