Gajillion
2009-Mar-19 18:20 UTC
[Puppet Users] imports from default node called when default node not used?
All, My understanding was that the default node was only used when a node did not match any other way. This appears to be correct for anything included via "include", however, it appears that anything included via "import" is pulled in regardless of whether the default node is matched or not. An example: site.pp: node ''buildtest'' { # include wget } node default { # Include everything for the default node import "test/*.pp" include active_directory include backup } Inside the test directory is a single class called module_test which does nothing but include a test module called my_test_module: $ cat module_test.pp include my_test_module class module_test { } $ And my_test_module just insures the presence of a file in /tmp: $ cat init.pp # Module to test imports class my_test_module { file { "/tmp/should_not_be_here": mode => 0644, ensure => present } } With this configuration, when I run puppetd on my box, buildtest, it matches with its node definition. I''ve tested this by enabling and disabling the "include wget" line which gets executed appropriately. Munging the name ''buildtest'' in the node definition causes the default node to instantiate, and "include active_directory" and "include backup" modify their files appropriately. However, the class "my_test_module" ALWAYS gets executed and the file "/tmp/ should_no_be_here" is there after every run regardless of their being a match for ''buildtest'' or not. Why is this the case? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Rob McBroom
2009-Mar-19 20:11 UTC
[Puppet Users] Re: imports from default node called when default node not used?
On 2009-Mar-19, at 2:20 PM, Gajillion wrote:> My understanding was that the default node was only used when a node > did not match any other way. This appears to be correct for anything > included via "include", however, it appears that anything included via > "import" is pulled in regardless of whether the default node is > matched or not.I experienced something similar when attempting to use "import" inside a "case" statement. I thought it would be more efficient if the puppetmaster didn''t have to evaluate sections that weren''t going to get used. (Maybe that''s completely wrong.) Anyway, it seems that all "import" lines in your manifests are executed unconditionally. I''ve taken to just importing absolutely everything at the beginning and then using include to actually load the classes I want. (Most files that get imported contain classes now.) I would also like to hear the official answer on how this is supposed to work. The [documentation][1] says "Code in those external manifests should always be stored in a class or definition or it will be imported into the main scope and applied to all nodes". When I read that, I think "Well, obviously, but only if a particular import statement gets triggered", but maybe it''s attempting to warn us that import statements are executed unconditionally? If so, the doc needs to be clarified, IMO. [1]: http://www.reductivelabs.com/trac/puppet/wiki/LanguageTutorial#importing-manifests -- Rob McBroom <http://www.skurfer.com/> Because it screws up the order in which people normally read text. Original message:> Why is it bad to top-post your reply?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Luke Kanies
2009-Mar-19 22:31 UTC
[Puppet Users] Re: imports from default node called when default node not used?
On Mar 19, 2009, at 3:11 PM, Rob McBroom wrote:> > On 2009-Mar-19, at 2:20 PM, Gajillion wrote: > >> My understanding was that the default node was only used when a node >> did not match any other way. This appears to be correct for anything >> included via "include", however, it appears that anything included >> via >> "import" is pulled in regardless of whether the default node is >> matched or not. > > I experienced something similar when attempting to use "import" inside > a "case" statement. I thought it would be more efficient if the > puppetmaster didn''t have to evaluate sections that weren''t going to > get used. (Maybe that''s completely wrong.) Anyway, it seems that all > "import" lines in your manifests are executed unconditionally. I''ve > taken to just importing absolutely everything at the beginning and > then using include to actually load the classes I want. (Most files > that get imported contain classes now.) > > I would also like to hear the official answer on how this is supposed > to work. > > The [documentation][1] says "Code in those external manifests should > always be stored in a class or definition or it will be imported into > the main scope and applied to all nodes". When I read that, I think > "Well, obviously, but only if a particular import statement gets > triggered", but maybe it''s attempting to warn us that import > statements are executed unconditionally? If so, the doc needs to be > clarified, IMO.Imports are parse-time, not compile time. As Puppet reads the files, it evaluates every import immediately. Please update the documentation to make this clear to your satisfaction. -- ''Tis better to be silent and be thought a fool, than to speak and remove all doubt. --Abraham Lincoln --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.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 -~----------~----~----~----~------~----~------~--~---