mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
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
69e7999586
2 changed files with 49 additions and 22 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…
Add table
Add a link
Reference in a new issue