It''s been my understanding that the order in which resources are defined having no bearing on the order of execution. This would mean that the only way to ensure one resource is declared after or before another is with the use of certain metaparameters (e.g., before/ require and notify/subscribe), which is straightforward enough. However, I''m not sure in what order statements are evaluated within a given resource. Take for example the documentation in the wiki entry on definitions in the LanguageTutorial (http://reductivelabs.com/trac/ puppet/wiki/LanguageTutorial#definitions). In the second example, there is an ''if'' statement that sets the ''require'' attribute for the ''exec { "create_repo_${name}": ... }'' resource. If the ''if'' statement is evaluated second, the ''require'' attribute will never be set, and the command might run without the assurance that the Subversion package was installed. So what determines whether or not that ''if'' statement is evaluated and executed before the ''exec'' resource is run? Does the Puppet interpreter realize that the ''if'' statement provides information the ''exec'' resource is potentially dependent on? Or does it simply evaluate non-resource statements first? If the latter is true (and this question is moot if the previous statement is incorrect), what happens if a non-resource statement depends on another non-resource statement; for example: if $foo { $baz = "quux" } $foo = "bar" I attempted to draw these conclusions by glossing through the PuppetInternals wiki page (http://reductivelabs.com/trac/puppet/wiki/ PuppetInternals), but didn''t really find what I was looking for (though it''s certainly possible I overlooked that information). I appreciate any insight! --~--~---------~--~----~------------~-------~--~----~ 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 Oct 27, 2008, at 11:29 AM, Ryan Steele wrote:> > It''s been my understanding that the order in which resources are > defined having no bearing on the order of execution. This would mean > that the only way to ensure one resource is declared after or before > another is with the use of certain metaparameters (e.g., before/ > require and notify/subscribe), which is straightforward enough. > However, I''m not sure in what order statements are evaluated within a > given resource. Take for example the documentation in the wiki entry > on definitions in the LanguageTutorial (http://reductivelabs.com/trac/ > puppet/wiki/LanguageTutorial#definitions). > > > In the second example, there is an ''if'' statement that sets the > ''require'' attribute for the ''exec { "create_repo_${name}": ... }'' > resource. If the ''if'' statement is evaluated second, the ''require'' > attribute will never be set, and the command might run without the > assurance that the Subversion package was installed. So what > determines whether or not that ''if'' statement is evaluated and > executed before the ''exec'' resource is run? Does the Puppet > interpreter realize that the ''if'' statement provides information the > ''exec'' resource is potentially dependent on? Or does it simply > evaluate non-resource statements first? If the latter is true (and > this question is moot if the previous statement is incorrect), what > happens if a non-resource statement depends on another non-resource > statement; for example: > > > if $foo { $baz = "quux" } > $foo = "bar" > > > I attempted to draw these conclusions by glossing through the > PuppetInternals wiki page (http://reductivelabs.com/trac/puppet/wiki/ > PuppetInternals), but didn''t really find what I was looking for > (though it''s certainly possible I overlooked that information). I > appreciate any insight!The entire set of manifests is evaluated on the server, producing a catalog which is evaluated on the client. Thus, you never have to worry about ordering between language constructs like ''if'' and catalog resources, because the language constructs are *always* evaluated before any resources are evaluated. -- It''s not to control, but to protect the citizens of Singapore. In our society, you can state your views, but they have to be correct. -- Ernie Hai, co-ordinator of the Singapore Government Internet Project --------------------------------------------------------------------- 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 -~----------~----~----~----~------~----~------~--~---
On Oct 27, 12:35 pm, Luke Kanies <l...@madstop.com> wrote:> The entire set of manifests is evaluated on the server, producing a > catalog which is evaluated on the client.Ok, so the puppetmaster creates a static catalog (devoid of variables and control structures) for any resources applicable to the given client so it can apply them. Which in the case of the svn_repo example in the documentation on definitions, means that by the time the client gets the catalog, it just sees an ''exec'' that either does or doesn''t have the require attribute.> Thus, you never have to worry about ordering between language > constructs like ''if'' and catalog resources, because the language > constructs are *always* evaluated before any resources are > evaluated.That answers part of my question about whether the "non- resource" (obviously more appropriately titled "language") bits of the manifests are evaluated before the resources. But I''m not sure it answered the the other question regarding the order of evaluation of the language constructs performed on the puppetmaster. So in the case of: if $foo { $baz = "quux" } $foo = "bar" ...does the puppetmaster care in which order these types of language constructs exist in the given resource? Or does it handle the assignments before any control structures are evaluated? --~--~---------~--~----~------------~-------~--~----~ 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 Oct 27, 2008, at 12:33 PM, Ryan Steele wrote:> > On Oct 27, 12:35 pm, Luke Kanies <l...@madstop.com> wrote: >> The entire set of manifests is evaluated on the server, producing a >> catalog which is evaluated on the client. > > Ok, so the puppetmaster creates a static catalog (devoid of variables > and control structures) for any resources applicable to the given > client so it can apply them. Which in the case of the svn_repo > example in the documentation on definitions, means that by the time > the client gets the catalog, it just sees an ''exec'' that either does > or doesn''t have the require attribute.Exactly.> >> Thus, you never have to worry about ordering between language >> constructs like ''if'' and catalog resources, because the language >> constructs are *always* evaluated before any resources are >> evaluated. > > That answers part of my question about whether the "non- > resource" (obviously more appropriately titled "language") bits of the > manifests are evaluated before the resources. But I''m not sure it > answered the the other question regarding the order of evaluation of > the language constructs performed on the puppetmaster. So in the case > of: > > if $foo { $baz = "quux" } > $foo = "bar" > > ...does the puppetmaster care in which order these types of language > constructs exist in the given resource? Or does it handle the > assignments before any control structures are evaluated?Older versions of Puppet (0.23.x, I think) attempted to pick an appropriate order for the different kinds of statements, but currently, all of the statements are just evaluated in file order. -- You can''t have everything. Where would you put it? -- Stephen Wright --------------------------------------------------------------------- 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 -~----------~----~----~----~------~----~------~--~---
On Oct 29, 5:40 pm, Luke Kanies <l...@madstop.com> wrote:> On Oct 27, 2008, at 12:33 PM, Ryan Steele wrote: > > That answers part of my question about whether the "non- > > resource" (obviously more appropriately titled "language") bits of the > > manifests are evaluated before the resources. But I''m not sure it > > answered the the other question regarding the order of evaluation of > > the language constructs performed on the puppetmaster. So in the case > > of: > > > if $foo { $baz = "quux" } > > $foo = "bar" > > > ...does the puppetmaster care in which order these types of language > > constructs exist in the given resource? Or does it handle the > > assignments before any control structures are evaluated? > > Older versions of Puppet (0.23.x, I think) attempted to pick an > appropriate order for the different kinds of statements, but > currently, all of the statements are just evaluated in file order.Interesting, you are right. Which means the statements are somewhat order dependent. For example, the manifest snippet above will not set $baz. But swap the order of the statements, and $baz is properly set to "quux". Thanks for wandering down this tangent with me. :) Ryan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---