win_product_facts: Rewrite using AnsibleModule (#48382)
This commit is contained in:
parent
d174ebc65e
commit
2dd56eb15c
1 changed files with 13 additions and 13 deletions
|
@ -3,20 +3,17 @@
|
|||
# Copyright: (c) 2017, Dag Wieers (dagwieers) <dag@wieers.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
#Requires -Module Ansible.ModuleUtils.Legacy
|
||||
#AnsibleRequires -CSharpUtil Ansible.Basic
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
# This module does not use any module parameters, this avoids pslint complaining
|
||||
#$params = Parse-Args -arguments $args -supports_check_mode $true
|
||||
|
||||
$result = @{
|
||||
changed = $false
|
||||
ansible_facts = @{
|
||||
ansible_os_product_id = (Get-CimInstance Win32_OperatingSystem).SerialNumber
|
||||
}
|
||||
$spec = @{
|
||||
options = @{}
|
||||
supports_check_mode = $true
|
||||
}
|
||||
|
||||
$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec)
|
||||
|
||||
$module.Result.changed = $false
|
||||
|
||||
# First try to find the product key from ACPI
|
||||
try {
|
||||
$product_key = (Get-CimInstance -Class SoftwareLicensingService).OA3xOriginalProductKey
|
||||
|
@ -62,6 +59,9 @@ if (-not $product_key) {
|
|||
}
|
||||
}
|
||||
|
||||
$result.ansible_facts.ansible_os_product_key = $product_key
|
||||
$module.Result.ansible_facts = @{
|
||||
ansible_os_product_id = (Get-CimInstance Win32_OperatingSystem).SerialNumber
|
||||
ansible_os_product_key = $product_key
|
||||
}
|
||||
|
||||
Exit-Json -obj $result
|
||||
$module.ExitJson()
|
||||
|
|
Loading…
Reference in a new issue