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: Rewrite using AnsibleModule #48382

Merged
merged 1 commit into from
Nov 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 = @{}
dagwieers marked this conversation as resolved.
Show resolved Hide resolved
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
dagwieers marked this conversation as resolved.
Show resolved Hide resolved

# 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()