mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Windows facts for licensing information (#50079)
* Windows facts for ansible_winlicense_edition, ansible_winlicense_channel, ansible_winlicense_status added * bugfix, replaced = with : * changed facts to ansible_os_license_* in win_product_facts.ps1 Shortened the short_description in win_product_facts.py removed errant - options: {} from win_product_facts.py * Code optimisations and changed return code to $null from NA when unknown license information returned from CIM SoftwareLicensingProduct class. * code optimisation
This commit is contained in:
parent
9c058d3121
commit
84a6519481
2 changed files with 24 additions and 2 deletions
|
@ -57,9 +57,29 @@ if (-not $product_key) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Retrieve license information
|
||||||
|
$license_info = Get-CimInstance SoftwareLicensingProduct | Where-Object PartialProductKey
|
||||||
|
|
||||||
|
$winlicense_status = switch ($license_info.LicenseStatus) {
|
||||||
|
0 { "Unlicensed" }
|
||||||
|
1 { "Licensed" }
|
||||||
|
2 { "OOBGrace" }
|
||||||
|
3 { "OOTGrace" }
|
||||||
|
4 { "NonGenuineGrace" }
|
||||||
|
5 { "Notification" }
|
||||||
|
6 { "ExtendedGrace" }
|
||||||
|
default { $null }
|
||||||
|
}
|
||||||
|
|
||||||
|
$winlicense_edition = $license_info.Name
|
||||||
|
$winlicense_channel = $license_info.ProductKeyChannel
|
||||||
|
|
||||||
$module.Result.ansible_facts = @{
|
$module.Result.ansible_facts = @{
|
||||||
ansible_os_product_id = (Get-CimInstance Win32_OperatingSystem).SerialNumber
|
ansible_os_product_id = (Get-CimInstance Win32_OperatingSystem).SerialNumber
|
||||||
ansible_os_product_key = $product_key
|
ansible_os_product_key = $product_key
|
||||||
|
ansible_os_license_edition = $winlicense_edition
|
||||||
|
ansible_os_license_channel = $winlicense_channel
|
||||||
|
ansible_os_license_status = $winlicense_status
|
||||||
}
|
}
|
||||||
|
|
||||||
$module.ExitJson()
|
$module.ExitJson()
|
||||||
|
|
|
@ -11,11 +11,10 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||||
DOCUMENTATION = r'''
|
DOCUMENTATION = r'''
|
||||||
---
|
---
|
||||||
module: win_product_facts
|
module: win_product_facts
|
||||||
short_description: Provides Windows product information (product id, product key)
|
short_description: Provides Windows product and license information
|
||||||
description:
|
description:
|
||||||
- Provides Windows product information.
|
- Provides Windows product information.
|
||||||
version_added: '2.5'
|
version_added: '2.5'
|
||||||
options: {}
|
|
||||||
author:
|
author:
|
||||||
- Dag Wieers (@dagwieers)
|
- Dag Wieers (@dagwieers)
|
||||||
'''
|
'''
|
||||||
|
@ -33,4 +32,7 @@ ansible_facts:
|
||||||
sample:
|
sample:
|
||||||
ansible_os_product_id: 00326-10000-00000-AA698
|
ansible_os_product_id: 00326-10000-00000-AA698
|
||||||
ansible_os_product_key: T49TD-6VFBW-VV7HY-B2PXY-MY47H
|
ansible_os_product_key: T49TD-6VFBW-VV7HY-B2PXY-MY47H
|
||||||
|
ansible_os_license_edition: Windows(R) ServerStandard edition
|
||||||
|
ansible_os_license_channel: Volume:MAK
|
||||||
|
ansible_os_license_status: Licensed
|
||||||
'''
|
'''
|
||||||
|
|
Loading…
Reference in a new issue