Only write file if copy on master is present

27 views
Skip to first unread message

Dennis Jacobfeuerborn

unread,
Apr 21, 2012, 9:15:19 PM4/21/12
to puppet...@googlegroups.com
Hi,
I'm trying to find a way to configure the firewall on centos systems using puppet by copying the /etc/sysconfig/iptables file and restarting the iptables service.
That part is simple to accomplish. The twist I need to add though is that I only want to do this if a copy of that file for the node exists on the server. If this file doesn't
exists then I want puppet to not replace the file on the client and not restart the service.

Is there a way to accomplish this sort of conditional execution?

Regards,
  Dennis

Krzysztof Wilczynski

unread,
Apr 22, 2012, 2:49:50 PM4/22/12
to puppet...@googlegroups.com
Hi,

On Sunday, 22 April 2012 02:15:19 UTC+1, Dennis Jacobfeuerborn wrote:
 
[...]
The twist I need to add though is that I only want to do this if a copy of that file for the node exists on the server. If this file doesn't
exists then I want puppet to not replace the file on the client and not restart the service.

Is there a way to accomplish this sort of conditional execution?

Have a look on: https://github.com/kwilczynski/puppet-functions/blob/master/lib/puppet/parser/functions/exists.rb

Maybe it will be of any use to you in this case.

KW

Dennis Jacobfeuerborn

unread,
Apr 23, 2012, 8:59:00 AM4/23/12
to puppet...@googlegroups.com
Thanks, this looks like it will do the trick. The lack of puppet:// support probably means I will have to hard-code a path to a directory somewhere but that shouldn't be to big of a deal.

Krzysztof Wilczynski

unread,
Apr 23, 2012, 9:57:08 AM4/23/12
to puppet...@googlegroups.com
Hi,


On Monday, 23 April 2012 13:59:00 UTC+1, Dennis Jacobfeuerborn wrote:
Thanks, this looks like it will do the trick. The lack of puppet:// support probably means I will have to hard-code a path to a directory somewhere but that shouldn't be to big of a deal.
[...]

Apologies for that :-(

Adding support for "puppet://" is quite tricky (there is a lot going on under-the-hood with this one), and I never have the time to do it (unless somebody is willing to help out and/or sponsor).

For the time being, please bare with fully-qualified paths ...

KW

Dennis Jacobfeuerborn

unread,
Apr 23, 2012, 11:14:59 AM4/23/12
to puppet...@googlegroups.com
I didn't mean to imply that this was your fault and I already knew that the puppet support probably was missing because it's quite tricky to implement.
Since I've started looking into writing my own functions and modules and get a bit deeper into puppet I might actually look into this myself if I find the time. If I make any progress there you can expect a pull request for the changes :)

Krzysztof Wilczynski

unread,
Apr 23, 2012, 12:27:39 PM4/23/12
to puppet...@googlegroups.com
Hi,


On Monday, 23 April 2012 16:14:59 UTC+1, Dennis Jacobfeuerborn wrote:
[...]
If I make any progress there you can expect a pull request for the changes :)
[...]

Thank you! That's very kind :) Let me know if I can help and/or we can join efforts.

KW
Reply all
Reply to author
Forward
0 new messages