From bf8fe221bff0a3505a65be2a67121609477dee2d Mon Sep 17 00:00:00 2001 From: Gianluca Date: Fri, 15 Nov 2019 02:19:01 +0100 Subject: [PATCH] Modified setup.ps1 in order to show Windows Installation type (#41002) * Modified setup.ps1 in order to show Windows Installation type * Fix after pull request comment * Added changelog fragment --- changelogs/fragments/win_setup-install-type.yaml | 2 ++ lib/ansible/modules/windows/setup.ps1 | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 changelogs/fragments/win_setup-install-type.yaml diff --git a/changelogs/fragments/win_setup-install-type.yaml b/changelogs/fragments/win_setup-install-type.yaml new file mode 100644 index 00000000000..3285968cf43 --- /dev/null +++ b/changelogs/fragments/win_setup-install-type.yaml @@ -0,0 +1,2 @@ +minor_changes: +- windows setup - Added ``ansible_os_installation_type`` to denote the type of Windows installation the remote host is. diff --git a/lib/ansible/modules/windows/setup.ps1 b/lib/ansible/modules/windows/setup.ps1 index 3422163d887..33f88499906 100644 --- a/lib/ansible/modules/windows/setup.ps1 +++ b/lib/ansible/modules/windows/setup.ps1 @@ -207,6 +207,13 @@ 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() @@ -214,6 +221,7 @@ if($gather_subset.Contains('distribution')) { 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 } }