Hi everyone,
I am running Puppet 3.6.2 on the affected Windows Server 2008 R2 node.
First of all the manifest that I'm trying to use:
define static_route ($net,$netmask,$gw)
{
if $::kernel == 'Linux'
{
exec { "$name":
command => "route add -net ${net} netmask ${netmask} gw ${gw}",
path => "$::path",
unless => "route -n | grep -i '${net}\s*${gw}\s*${netmask}'",
}
}
if $::kernel == 'windows' {
exec { "$name":
command => "route ADD ${net} MASK ${netmask} ${gw}",
path => "$::path",
unless => "cmd /c route PRINT -4 | FINDSTR /r ${net}.*${netmask}.*${gw}",
}
}
}
# example values
static_route { 'route01':
net => '200.60.80.148',
netmask => '255.255.255.128',
gw => '10.21.10.5',
}
This enables me to add a static route to Windows and Linux nodes with the same Puppet syntax. On my Linux nodes this works just fine.
But on my Windows node i notice a strange behavior:
- When I test this manifest with 'puppet agent -t' ,Puppet creates the static route in the first try. When I run 'puppet agent -t' again there are no further changes. (this is the expected behavior)
- But when the Puppet run gets triggered by the Puppet service (every 30 minutes) it executes the route add command on EVERY following run. (As if the route is not present. The agent sends a report to the Puppet Dashboard that indicates an successfully executed "Exec" resource)
Is there a mistake in my Puppet code? Or is there any other logical explanation for this behavior?