Merge pull request #8812 from trondhindenes/win_json_facts_setup_improvements
win_json_facts_setup_improvements; All changes referenced in PRs #8767 , #8768 , #8769
This commit is contained in:
commit
30a3668d2b
1 changed files with 21 additions and 0 deletions
|
@ -32,6 +32,27 @@ $capacity = 0
|
|||
$memory | foreach {$capacity += $_.Capacity}
|
||||
$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_fqdn" "$([System.Net.Dns]::GetHostByName((hostname)).HostName)"
|
||||
Set-Attr $result.ansible_facts "ansible_system" $osversion.Platform.ToString()
|
||||
|
|
Loading…
Reference in a new issue