Hi, I''m adapting our modules to version 2.7.3. Currently I ''ve this example in a iptables module class iptables_script { file { $iptables_init: owner => "root", group => "root", mode => "0700", ................................. } class iptables_files { file { $firewall_top: owner => "root", group => "root", mode => "0700", require => Package["$iptables_init"], } } It possible to use a fully qualifed variable inside a metaparameter? class iptables_script { file { $iptables_init: owner => "root", group => "root", mode => "0700", ................................. } class iptables_files { file { $firewall_top: owner => "root", group => "root", mode => "0700", require => Package["$iptables::iptables_script::iptables_init"], } } Currently it''s not working, I receive an "undef" Can you help me¿? -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
jcbollinger
2011-Sep-08 14:23 UTC
[Puppet Users] Re: Qualified variable inside a metaparameter
On Sep 7, 9:53 am, ikkaro <isaak.gonza...@gmail.com> wrote:> Hi, > > I''m adapting our modules to version 2.7.3. > Currently I ''ve this example in a iptables module > > class iptables_script > { > file { > $iptables_init: > owner => "root", > group => "root", > mode => "0700", > ................................. > > } > > class iptables_files > { > file { > $firewall_top: > owner => "root", > group => "root", > mode => "0700", > require => Package["$iptables_init"], > > } > } > > It possible to use a fully qualifed variable inside a metaparameter? > > class iptables_script > { > file { > $iptables_init: > owner => "root", > group => "root", > mode => "0700", > ................................. > > } > > class iptables_files > { > file { > $firewall_top: > owner => "root", > group => "root", > mode => "0700", > require => > Package["$iptables::iptables_script::iptables_init"], > > } > } > > Currently it''s not working, I receive an "undef" > Can you help me¿?Perhaps. 1) In your example, the iptables_script class does not declare a variable named "iptables_init", therefore with the classes as given, it is natural that $iptables::iptables_script::iptables_init evaluates to undef. 2) Your classes are notable for lacking any ''include'' statements. Generally, if you want to refer to a class variable that is outside the current *lexical* scope then you should ''include'' its class somewhere in the lexical scope. This works only with unparameterized classes, of course. Supposing that iptables_script declared the wanted variable, you might do something like this: class iptables_files { include "iptables::iptables_script" file { $firewall_top: owner => "root", group => "root", mode => "0700", require => File["$iptables::iptables_script::iptables_init"], } } John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.