Adding Facter
This commit is contained in:
parent
eeaeeb5a1f
commit
02b3f74f50
1 changed files with 23 additions and 4 deletions
|
@ -117,4 +117,23 @@ if ($winrm_cert_expiry)
|
|||
Set-Attr $result.ansible_facts "ansible_winrm_certificate_expires" $winrm_cert_expiry.NotAfter.ToString("yyyy-MM-dd HH:mm:ss")
|
||||
}
|
||||
|
||||
# See if Facter is on the System Path
|
||||
Try {
|
||||
$facter_exe = Get-Command facter -ErrorAction Stop
|
||||
$facter_installed = $true
|
||||
}
|
||||
Catch {
|
||||
$facter_installed = $false
|
||||
}
|
||||
|
||||
# Get JSON from Facter, and parse it out.
|
||||
if ($facter_installed) {
|
||||
&facter -j | Tee-Object -Variable facter_output | Out-Null
|
||||
$facts = "$facter_output" | ConvertFrom-Json
|
||||
ForEach($fact in $facts.PSObject.Properties) {
|
||||
$fact_name = $fact.Name
|
||||
Set-Attr $result.ansible_facts "facter_$fact_name" $fact.Value
|
||||
}
|
||||
}
|
||||
|
||||
Exit-Json $result;
|
||||
|
|
Loading…
Reference in a new issue