On Jan 6, 9:10 pm, bel <[email protected]> wrote:
> I am working on this module:
>
> https://github.com/belminf/puppet-iptables
>
> I have this defined resource:
>
> define iptables::hole ($proto='tcp', $port, $source=undef) {
> firewall { "100 input: $name":
> chain => 'INPUT',
> proto => $proto,
> dport => $port,
> source => $source,
> action => 'accept',
> }
>
> }
>
> I want it to notify an `exec`. However, the only way I could make this work
> is if I make the `exec` in the global scope (i.e., importing in site.pp).
> Otherwise, if I define the `exec` resource and do `require =>
> Exec['persist-iptables']`, when the `iptables::hole` resource is defined,
> it cannot find the `exec` resource.
>
> Can someone help me re-factor this so it doesn't require an import? You are
> more than welcomed to modify the code on github.
ALL Puppet resources have global scope. Very likely either your
target exec is not in a class, or you do not ensure that its class is
included before you try to reference it. Here is one way that will
work:
iptables/persist.pp:
---------------------------
class iptables::persistance {
exec { 'persist-iptables':
# ...
}
}
iptables/hole.pp:
------------------------
define iptables::hole ($proto='tcp', $port, $source=undef) {
include 'iptables::persistance'
firewall { "100 input: $name":
# ...
notify => Exec[''persist-iptables']
}
}
John
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.