Skip to content

Commit

Permalink
Modified setup.ps1 in order to show Windows Installation type (ansibl…
Browse files Browse the repository at this point in the history
…e#41002)

* Modified setup.ps1 in order to show Windows Installation type

* Fix after pull request comment

* Added changelog fragment
  • Loading branch information
Gianlu authored and anshulbehl committed Dec 10, 2019
1 parent d870539 commit 46c158e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/win_setup-install-type.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- windows setup - Added ``ansible_os_installation_type`` to denote the type of Windows installation the remote host is.
8 changes: 8 additions & 0 deletions lib/ansible/modules/windows/setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,21 @@ if($gather_subset.Contains('distribution')) {
default { "unknown" }
}

$installation_type = $null
$current_version_path = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
if (Test-Path -LiteralPath $current_version_path) {
$install_type_prop = Get-ItemProperty -LiteralPath $current_version_path -ErrorAction SilentlyContinue
$installation_type = [String]$install_type_prop.InstallationType
}

$ansible_facts += @{
ansible_distribution = $win32_os.Caption
ansible_distribution_version = $osversion.Version.ToString()
ansible_distribution_major_version = $osversion.Version.Major.ToString()
ansible_os_family = "Windows"
ansible_os_name = ($win32_os.Name.Split('|')[0]).Trim()
ansible_os_product_type = $product_type
ansible_os_installation_type = $installation_type
}
}

Expand Down

0 comments on commit 46c158e

Please sign in to comment.