Create Windows facts for ansible_virtualization_role and ansible_virt… (#49775)
* Create Windows facts for ansible_virtualization_role and ansible_virtualization_type * Create Windows facts for ansible_virtualization_role and ansible_virtualization_type Updated formatting * Removed executable flag on setup.ps1 * Changed Get-WMIObject to Get-CimInstance as Get-WMIObject has been deprecated and fails testing. * Changed new variables to snake_case and also changed Get-CimInstance to Get-LazyCimInstance * removed -class from Get-LazyCimInstance call as failed test.
This commit is contained in:
parent
bf065e853f
commit
18503e7ed6
1 changed files with 37 additions and 1 deletions
|
@ -68,7 +68,7 @@ $result = @{
|
|||
$grouped_subsets = @{
|
||||
min=[System.Collections.Generic.List[string]]@('date_time','distribution','dns','env','local','platform','powershell_version','user')
|
||||
network=[System.Collections.Generic.List[string]]@('all_ipv4_addresses','all_ipv6_addresses','interfaces','windows_domain', 'winrm')
|
||||
hardware=[System.Collections.Generic.List[string]]@('bios','memory','processor','uptime')
|
||||
hardware=[System.Collections.Generic.List[string]]@('bios','memory','processor','uptime','virtual')
|
||||
external=[System.Collections.Generic.List[string]]@('facter')
|
||||
}
|
||||
|
||||
|
@ -439,6 +439,42 @@ if($gather_subset.Contains('winrm')) {
|
|||
}
|
||||
}
|
||||
|
||||
if($gather_subset.Contains('virtual')) {
|
||||
$machine_info = Get-LazyCimInstance Win32_ComputerSystem
|
||||
|
||||
switch ($machine_info.model) {
|
||||
"Virtual Machine" {
|
||||
$machine_type="Hyper-V"
|
||||
$machine_role="guest"
|
||||
}
|
||||
|
||||
"VMware Virtual Platform" {
|
||||
$machine_type="VMware"
|
||||
$machine_role="guest"
|
||||
}
|
||||
|
||||
"VirtualBox" {
|
||||
$machine_type="VirtualBox"
|
||||
$machine_role="guest"
|
||||
}
|
||||
|
||||
"HVM domU" {
|
||||
$machine_type="Xen"
|
||||
$machine_role="guest"
|
||||
}
|
||||
|
||||
default {
|
||||
$machine_type="NA"
|
||||
$machine_role="NA"
|
||||
}
|
||||
}
|
||||
|
||||
$ansible_facts += @{
|
||||
ansible_virtualization_role = $machine_role
|
||||
ansible_virtualization_type = $machine_type
|
||||
}
|
||||
}
|
||||
|
||||
$result.ansible_facts += $ansible_facts
|
||||
|
||||
Exit-Json $result
|
||||
|
|
Loading…
Reference in a new issue