**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**
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.
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 => ???
}
}
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:
End of search: 0 match(es) found.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With