On Tue, Nov 15, 2011 at 01:42:24PM -0800, Justin Lloyd wrote: > I tried the following (names changed to protect the innocent and guilty): > > class myclass ( $param ) { > > ��� $myvar = [ "foo", "bar" ] > > ��� if $param == "special" { > ������� $myvar += [ "blah" ] > ��� } > > } > > and got the message "...Cannot append, variable myvar is defined in this > scope...". According to the docs, [1]variables cannot be modified in the > same scope because of the declarative nature of Puppet. > > However, if I change the plus-signment statment to > > $myclass::myvar += [ "blah" ] > > it works fine. Can someone explain this aspect of scoping? (Or is this > possibly a bug...?) > > Justin
Simpler example, but I get "bar\n" in both files: $ cat /tmp/scope1.pp class myclass { $myvar = [ "foo\n", "bar\n" ] file { "/tmp/a1": content => $myvar } $myclass::myvar += [ "blah" ] file { "/tmp/a2": content => $myclass::myvar, } } class { myclass: } $ puppet apply /tmp/scope1.pp notice: /Stage[main]/Myclass/File[/tmp/a2]/ensure: defined content as '{md5}d3b07384d113edec49eaa6238ad5ff00' notice: /Stage[main]/Myclass/File[/tmp/a1]/ensure: defined content as '{md5}d3b07384d113edec49eaa6238ad5ff00' $ cat /tmp/a1 bar $ cat /tmp/a2 bar Maybe it's not emitting an error, but I can't get $myclass::myvar with a different value. Not that I know so much about what's going on. > -- > 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+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > > References > > Visible links > 1. http://docs.puppetlabs.com/guides/language_guide.html -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.