Why can''t variables be reassigned with a setup like this? node /.*mydomain.com/ { import mydomain.pp } node /*.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 -- 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.
Why not just move everything to a class in a diffierent file? Then put the variables directly in that class? On Mon, Aug 9, 2010 at 9:23 AM, Christopher Johnston <chjohnst@gmail.com>wrote:> Why can''t variables be reassigned with a setup like this? > > node /.*mydomain.com/ { > import mydomain.pp > } > > node /*.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 > > -- > 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<puppet-users%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. >-- 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.
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. Best Regards, David -- dasz.at OG Tel: +43 (0)664 2602670 Web: http://dasz.at Klosterneuburg UID: ATU64260999 FB-Nr.: FN 309285 g FB-Gericht: LG Korneuburg -- 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.
On Tue, Aug 10, 2010 at 12:48 AM, David Schmitt <david@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-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.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1> 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.there was recently a thread about what kind of variable scoping people like to have. I miss your input there... cheers pete -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkxjvkIACgkQbwltcAfKi3+sNgCgkHqVZPh0p/KKHw5nQY37mNc9 nmQAnA5o4vIxqpHcnF7YdlwuUNRmtbcv =Q0qD -----END PGP SIGNATURE----- -- 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.