Skip to content

Commit

Permalink
win_product_facts: Rewrite using AnsibleModule (ansible#48382)
Browse files Browse the repository at this point in the history
  • Loading branch information
dagwieers authored and Ghilli3 committed Nov 12, 2018
1 parent 0eb1017 commit d051f3f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/ansible/modules/windows/win_product_facts.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@
# 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"
$spec = @{
options = @{}
supports_check_mode = $true
}

# This module does not use any module parameters, this avoids pslint complaining
#$params = Parse-Args -arguments $args -supports_check_mode $true
$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec)

$result = @{
changed = $false
ansible_facts = @{
ansible_os_product_id = (Get-CimInstance Win32_OperatingSystem).SerialNumber
}
}
$module.Result.changed = $false

# First try to find the product key from ACPI
try {
Expand Down Expand Up @@ -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()

0 comments on commit d051f3f

Please sign in to comment.