Merge pull request #8812 from trondhindenes/win_json_facts_setup_improvements

win_json_facts_setup_improvements; All changes referenced in PRs #8767 , #8768 , #8769
reviewable/pr18780/r1
Chris Church 10 years ago
commit 30a3668d2b

@ -32,6 +32,27 @@ $capacity = 0
$memory | foreach {$capacity += $_.Capacity} $memory | foreach {$capacity += $_.Capacity}
$netcfg = Get-WmiObject win32_NetworkAdapterConfiguration $netcfg = Get-WmiObject win32_NetworkAdapterConfiguration
$ActiveNetcfg = @(); $ActiveNetcfg+= $netcfg | where {$_.ipaddress -ne $null}
$formattednetcfg = @()
foreach ($adapter in $ActiveNetcfg)
{
$thisadapter = New-Object psobject @{
interface_name = $adapter.description
dns_domain = $adapter.dnsdomain
default_gateway = $null
interface_index = $adapter.InterfaceIndex
}
if ($adapter.defaultIPGateway)
{
$thisadapter.default_gateway = $adapter.DefaultIPGateway[0].ToString()
}
$formattednetcfg += $thisadapter;$thisadapter = $null
}
Set-Attr $result.ansible_facts "ansible_interfaces" $formattednetcfg
Set-Attr $result.ansible_facts "ansible_hostname" $env:COMPUTERNAME; Set-Attr $result.ansible_facts "ansible_hostname" $env:COMPUTERNAME;
Set-Attr $result.ansible_facts "ansible_fqdn" "$([System.Net.Dns]::GetHostByName((hostname)).HostName)" Set-Attr $result.ansible_facts "ansible_fqdn" "$([System.Net.Dns]::GetHostByName((hostname)).HostName)"
Set-Attr $result.ansible_facts "ansible_system" $osversion.Platform.ToString() Set-Attr $result.ansible_facts "ansible_system" $osversion.Platform.ToString()

Loading…
Cancel
Save