Adding gathering environment variables to gather facts on Windows making similar in functionality to gather facts on Linux
This commit is contained in:
parent
1354ef0285
commit
8d5cebd597
1 changed files with 10 additions and 0 deletions
|
@ -81,6 +81,16 @@ $ips = @()
|
||||||
Foreach ($ip in $netcfg.IPAddress) { If ($ip) { $ips += $ip } }
|
Foreach ($ip in $netcfg.IPAddress) { If ($ip) { $ips += $ip } }
|
||||||
Set-Attr $result.ansible_facts "ansible_ip_addresses" $ips
|
Set-Attr $result.ansible_facts "ansible_ip_addresses" $ips
|
||||||
|
|
||||||
|
$env_vars = New-Object psobject
|
||||||
|
foreach ($item in Get-ChildItem Env:)
|
||||||
|
{
|
||||||
|
$name = $item | select -ExpandProperty Name
|
||||||
|
# Powershell ConvertTo-Json fails if string ends with \
|
||||||
|
$value = ($item | select -ExpandProperty Value).TrimEnd("\")
|
||||||
|
Set-Attr $env_vars $name $value
|
||||||
|
}
|
||||||
|
Set-Attr $result.ansible_facts "ansible_env" $env_vars
|
||||||
|
|
||||||
$psversion = $PSVersionTable.PSVersion.Major
|
$psversion = $PSVersionTable.PSVersion.Major
|
||||||
Set-Attr $result.ansible_facts "ansible_powershell_version" $psversion
|
Set-Attr $result.ansible_facts "ansible_powershell_version" $psversion
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue