2014-06-18 16:32:02 +02:00
|
|
|
#!powershell
|
|
|
|
# This file is part of Ansible
|
|
|
|
#
|
|
|
|
# Ansible is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# Ansible is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
# WANT_JSON
|
|
|
|
# POWERSHELL_COMMON
|
|
|
|
|
2014-06-18 17:07:46 +02:00
|
|
|
# $params is not currently used in this module
|
|
|
|
# $params = Parse-Args $args;
|
2014-06-18 16:32:02 +02:00
|
|
|
|
|
|
|
$result = New-Object psobject @{
|
|
|
|
ansible_facts = New-Object psobject
|
|
|
|
changed = $false
|
|
|
|
};
|
|
|
|
|
|
|
|
$osversion = [Environment]::OSVersion
|
2014-06-21 16:27:43 +02:00
|
|
|
$memory = Get-WmiObject win32_Physicalmemory
|
2014-06-18 19:29:14 +02:00
|
|
|
$netcfg = Get-WmiObject win32_NetworkAdapterConfiguration
|
2014-06-18 16:32:02 +02:00
|
|
|
|
|
|
|
Set-Attr $result.ansible_facts "ansible_hostname" $env:COMPUTERNAME;
|
|
|
|
Set-Attr $result.ansible_facts "ansible_fqdn" "$([System.Net.Dns]::GetHostByName((hostname)).HostName)"
|
2014-06-18 16:36:10 +02:00
|
|
|
Set-Attr $result.ansible_facts "ansible_system" $osversion.Platform.ToString()
|
2014-06-18 16:32:02 +02:00
|
|
|
Set-Attr $result.ansible_facts "ansible_os_family" "Windows"
|
|
|
|
Set-Attr $result.ansible_facts "ansible_distribution" $osversion.VersionString
|
|
|
|
Set-Attr $result.ansible_facts "ansible_distribution_version" $osversion.Version.ToString()
|
|
|
|
|
2014-06-18 19:29:14 +02:00
|
|
|
Set-Attr $result.ansible_facts "ansible_totalmem" $memory.Capacity.ToString()
|
|
|
|
|
|
|
|
$ips = @()
|
|
|
|
Foreach ($ip in $netcfg.IPAddress) { If ($ip) { $ips += $ip } }
|
|
|
|
Set-Attr $result.ansible_facts "ansible_ip_addresses" $ips
|
|
|
|
|
2014-06-18 18:48:50 +02:00
|
|
|
Exit-Json $result;
|