On Tue, Aug 10, 2010 at 12:48 AM, David Schmitt <da...@dasz.at> wrote: > On 8/9/2010 6:23 PM, Christopher Johnston wrote: >> >> Why can't variables be reassigned with a setup like this? >> >> node /.*mydomain.com/ <http://mydomain.com/> { >> import mydomain.pp >> } >> >> node /*.yourdomain.com/ <http://yourdomain.com/> { >> import yourdomain.pp >> } >> >> In manifest mydomain.pp and yourdomain.pp I have variables that are >> specific to that site that I want to import only for that site (ie, >> dns_nameserver ldap_server). I get errors that variable cannot be >> reassigned. My reasoning for wanting to separate everything into >> separate site specific manifests is mostly because my nodes.pp is >> getting way too cluttered and difficult to manage (over 1k lines of >> code). It looks like stuff is getting imported regardless of the node >> type (case statements also show the same behavior). >> >> err: Could not retrieve catalog from remote server: Error 400 on SERVER: >> Cannot reassign variable site_id at >> /etc/puppet/manifests/nodes/mydomain.pp:5 on node host.yourdomain.com >> <http://host.yourdomain.com> > > > Because, AFAIUI, imports are not constrained by their surrounding scope. > That means that top-level variables in a file will always be added to the > ::main scope, regardless of how they're imported. > > Either put the nodes statement into the imported files too, or inline the > imported files instead, or use a facility like extlookup, or use an external > node classifier.
Ugly. If you put your variables in external nodes, you can't easily set the variable in a parent class and access it in a child class due to puppet's borked variable scoping. You can put every single variable at the node level, but having to specify, oh, say an LDAP server IP for every node in a data centre is a bit dumb. Doug. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-us...@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.