我有一个成功检测 VM 是否为 VMware VM 的代码块:
if node['hostnamectl']['virtualization'].include? "vmware"
include_recipe "system_baseline::vmware"
....
但是,如果我用 AWS 尝试同样的事情,它似乎不起作用:
if node['hostnamectl']['virtualization'].include? "xen"
include_recipe "system_baseline::aws"
....
从 VM 命令行运行“ohai hostnamectl”,属性看起来类似:
虚拟机:
{
"static_hostname": "server_vm01",
"icon_name": "computer-vm",
"chassis": "vm",
"machine_id": "147ded104b3e4bf7beab2b765482dc0d",
"boot_id": "8a68451144a8462882e194cde6188dc4",
"virtualization": "vmware",
"operating_system": "CentOS Linux 7 (Core)",
"cpe_os_name": "cpe",
"kernel": "Linux 3.10.0-693.17.1.el7.x86_64",
"architecture": "x86-64"
}
和 AWS 实例:
{
"static_hostname": "server_vm02",
"icon_name": "computer-vm",
"chassis": "vm",
"machine_id": "147ded104b3e4bf7bfab2b765482dc0d",
"boot_id": "8a68451144a8462882e134cde6188dc4",
"virtualization": "xen",
"operating_system": "CentOS Linux 7 (Core)",
"cpe_os_name": "cpe",
"kernel": "Linux 3.10.0-693.17.1.el7.x86_64",
"architecture": "x86-64"
}
谁能告诉我为什么 xen 属性没有像 vmware 属性那样被拾取?