1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

replace math round with ceiling for ansible_memtotal_mb + add new variables to display swapfile config (#49611)

* replace math round with ceiling to report the actually installed RAM for ansible_memtotal_mb

* add new variable ansible_memtotal to display TotalPhysicalMemory in bytes
add new variable ansible_swap_min to display initial pagefile size
add new variable ansible_swap_max to display maximum pagefile size
removed the variable ansible_swaptotal_mb

* output ansible_swap_min & ansible_swap_max value in bytes

* re-add the ansible_swaptotal_mb fact and fix the conversion of the TotalSwapSpaceSize value from kilobytes to MB

* indentation fix, replace tab with spaces
This commit is contained in:
Gregory Storme 2018-12-13 00:44:40 +01:00 committed by Jordan Borean
parent 18503e7ed6
commit b3ac5b637a

View file

@ -296,14 +296,17 @@ if ($gather_subset.Contains("local") -and $factpath -ne $null) {
if($gather_subset.Contains('memory')) { if($gather_subset.Contains('memory')) {
$win32_cs = Get-LazyCimInstance Win32_ComputerSystem $win32_cs = Get-LazyCimInstance Win32_ComputerSystem
$win32_os = Get-LazyCimInstance Win32_OperatingSystem $win32_os = Get-LazyCimInstance Win32_OperatingSystem
$win32_pf = Get-LazyCimInstance Win32_PageFileSetting
$ansible_facts += @{ $ansible_facts += @{
# Win32_PhysicalMemory is empty on some virtual platforms # Win32_PhysicalMemory is empty on some virtual platforms
ansible_memtotal_mb = ([math]::round($win32_cs.TotalPhysicalMemory / 1024 / 1024)) ansible_memtotal_mb = ([math]::ceiling($win32_cs.TotalPhysicalMemory / 1024 / 1024))
ansible_swaptotal_mb = ([math]::round($win32_os.TotalSwapSpaceSize / 1024 / 1024)) ansible_swaptotal_mb = ([math]::round($win32_os.TotalSwapSpaceSize / 1024))
ansible_memtotal = $win32_cs.TotalPhysicalMemory
ansible_swap_min = $win32_pf.InitialSize * 1024 * 1024
ansible_swap_max = $win32_pf.MaximumSize * 1024 * 1024
} }
} }
if($gather_subset.Contains('platform')) { if($gather_subset.Contains('platform')) {
$win32_cs = Get-LazyCimInstance Win32_ComputerSystem $win32_cs = Get-LazyCimInstance Win32_ComputerSystem
$win32_os = Get-LazyCimInstance Win32_OperatingSystem $win32_os = Get-LazyCimInstance Win32_OperatingSystem