**EDIT**
我通过玩弄找到了一个解决方案:
I found a solution by playing around:
class add_route { exec { "route_to_internal_network": command => "C:\Windows\System32\ROUTE.EXE add 192.168.5.254 mask 255.255.255.255 10.5.5.5 -p", unless => "C:\Windows\System32\reg.exe query HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\PersistentRoutes /f 192.168.5.254,255.255.252.0,10.5.5.5,1", } }我会留下这个帖子,以防其他人遇到类似的问题
I'll leave this post up in case anyone else is running into a similar problem
**EDIT**
我正在尝试编写一个 puppet 清单,以向我的某些 Windows 主机服务器添加持久静态路由.到目前为止,我正在考虑创建一个这样的类:
I am trying to write a puppet manifest to add a persistent static route to some of my Windows host servers. So far, I am thinking of creating a class that does:
class add_route { exec { "route_to_internal_network": command => "C:\Windows\System32\ROUTE.EXE add 192.168.5.254 mask 255.255.255.255 10.5.5.5 -p", } }但是,每次木偶客户端与木偶主人签到时,此清单都会执行该命令.
However, this manifest will exec the command every time the puppet client checks in with the puppet master.
我希望在我的班级中使用 onlyif,但是在尝试检查包含我的路由的缺失注册表值时似乎有点混乱.这是最好的方法吗?还有其他想法吗?
I was hoping to use onlyif in my class, but it seems a little confusing when trying to check for an absent registry value that contains my route. Is this the best way to do this? Any other ideas?
我想我需要做一些类似的事情:
I imagine I need to do something like:
class add_route { exec { "route_to_internal_network": command => "C:\Windows\System32\ROUTE.EXE add 192.168.5.254 mask 255.255.255.255 10.5.5.5 -p", onlyif => ??? } }我希望我的 onlyif 语句能够匹配
I was hoping my onlyif statement would match to
C:\Windows\System32\reg.exe query HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\PersistentRoutes /f '192.168.5.254,255.255.255.255,10.5.5.5,1'如果上面命令的结果是:
If the result of the above command is:
搜索结束:找到 0 个匹配项.
End of search: 0 match(es) found.
但是,我认为 onlyif 只是在寻找返回码,因此无论是否找到此值,该命令都会成功完成.
However, I think the onlyif is just looking for a return code, so whether or not this value is found, the command completes successfully.
有谁知道我如何检查人偶清单中是否缺少注册表值?
Does anyone know how I could check for the absence of a registry value in a puppet manifest?
推荐答案我找到了一个解决方案:
I found a solution by playing around:
class add_route { exec { "route_to_internal_network": command => "C:\Windows\System32\ROUTE.EXE add 192.168.5.254 mask 255.255.255.255 10.5.5.5 -p", unless => "C:\Windows\System32\reg.exe query HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\PersistentRoutes /f 192.168.5.254,255.255.255.255,10.5.5.5,1", } }我会留下这个帖子,以防其他人遇到类似的问题
I'll leave this post up in case anyone else is running into a similar problem
更多推荐
仅当注册表值不存在时才执行
发布评论