我正在尝试学习如何使用傀儡查询,但发现很难使用正则表达式来定位特定的事实路径。
如果我使用以下查询,我就会得到我正在寻找的内容:
puppet-query 'inventory[certname, facts.os.family, facts.mountpoints./nfs/systems.filesystem] { facts.os.family = "RedHat" and facts.os.release.major <= "6" and facts.mountpoints./nfs/systems.filesystem = "nfs" }'
{
"certname": "SERVER1",
"facts.os.family": "RedHat",
"facts.mountpoints./nfs/systems.filesystem": "nfs"
},
{
"certname": "SERVER2",
"facts.os.family": "RedHat",
"facts.mountpoints./nfs/systems.filesystem": "nfs"
},
{
"certname": "SERVER3",
"facts.os.family": "RedHat",
"facts.mountpoints./nfs/systems.filesystem": "nfs"
}
]
但是,并非每个服务器都会使用精确的挂载路径“/nfs/systems”。
因此我尝试使用正则表达式:
puppet-query 'inventory[certname, facts.os.family, facts.mountpoints.(.*).filesystem] { facts.os.family = "RedHat" and facts.os.release.major <= "6" and facts.mountpoints(.*).filesystem = "nfs" }'
puppet 不会抱怨语法,但它不会返回任何内容。
我的语法有什么错误?