On Thu, Feb 14, 2013 at 7:29 AM, jim <stra...@gmail.com> wrote:

> Hello all,
>
> I'm currently running 2.7.19 (Puppet Enterprise 2.7.0)
>
> I want to use puppet to add / amend or delete windows firewall rules, is
> there a tidy way of doing this ????
>
> exec { "Check_MK_Firewall_Rule_create":
> command => 'C:\Windows\System32\netsh.exe advfirewall firewall add rule
> name="Check_MK" dir=in action=allow protocol=TCP localport=6556',
> unless => 'C:\Windows\System32\netsh.exe advfirewall firewall show rule
> name="Check_MK"',
> }
>
> ## If I remove the unless statement, it will keep add the same rule over
> and over again, which will make the firewall rule list un-manageable
>
>
> exec { "Check_MK_Firewall_Rule_enable":
> command => 'C:\Windows\System32\netsh.exe advfirewall firewall set rule
> name="Check_MK" new enable=Yes',
> }
>
> ## When I do a puppet run it keeps running this, is there a way to only
> run if disabled ???
>
> Hope this make sense
>
> regards
>
> James
>

I belive you want to your second exec to subscribe to the first (so the
first exec only runs if the rule doesn't exist and the second only runs if
the first does).

To tidy that up you could put them in a defined type so you can write
something like:
win_firewall { "Check_MK":
  direction => in,
  action     => allow,
  protocol  => TCP,
  port         => 6556,
}

Of course there's a whole host of things you can do to continue tiding up.
Like creating a native type & provider for windows firewall, extending a
current type with a windows provider, or wrapping linux firewall types &
windows firewall types in a more generic 'firewall' type, that just depends
on how far you want to take it.....

 - Justin


>  --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-users+unsubscr...@googlegroups.com.
> To post to this group, send email to puppet-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/puppet-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to