diff --git a/changelogs/fragments/windows_setup_memtotal.yml b/changelogs/fragments/windows_setup_memtotal.yml new file mode 100644 index 0000000000..49cc05cdb8 --- /dev/null +++ b/changelogs/fragments/windows_setup_memtotal.yml @@ -0,0 +1,2 @@ +bugfixes: + - setup - fix the rounding of the ansible_memtotal_mb value on VMWare vm's (https://github.com/ansible/ansible/issues/49608) diff --git a/lib/ansible/modules/windows/setup.ps1 b/lib/ansible/modules/windows/setup.ps1 index 22b94fc000..912fdb4d04 100644 --- a/lib/ansible/modules/windows/setup.ps1 +++ b/lib/ansible/modules/windows/setup.ps1 @@ -298,8 +298,8 @@ if($gather_subset.Contains('memory')) { $win32_os = Get-LazyCimInstance Win32_OperatingSystem $ansible_facts += @{ # Win32_PhysicalMemory is empty on some virtual platforms - ansible_memtotal_mb = ([math]::round($win32_cs.TotalPhysicalMemory / 1024 / 1024)) - ansible_swaptotal_mb = ([math]::round($win32_os.TotalSwapSpaceSize / 1024 / 1024)) + ansible_memtotal_mb = ([math]::ceiling($win32_cs.TotalPhysicalMemory / 1024 / 1024)) + ansible_swaptotal_mb = ([math]::round($win32_os.TotalSwapSpaceSize / 1024)) } }