Hi All, there is an issue in how templates are working that I''m not sure how to workaround. I setup a template for an exim config that should add/remove some directives depending on if some particular file is existing on destination server. However template processing appears to work on puppetmaster server and only after that ready config is being transferred to destination server. The issue is the check for file existing in templates is checking the file on puppetmaster, not on a target server. I tried to use facts, but this didnt'' help either. Any suggestion on how this can be performed? Thanks in advance. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I am having the same issues with Templates, here''s the deal *I think*: puppetd evaluates the templates on the puppetmaster, then passes it down... so you probably need to use the stand alone puppet executable. That worked for me. I am still leanirng my way through all this, so I could very well be wrong. On Jun 11, 8:34 pm, "Paul Johnson" <gentoo.ser...@gmail.com> wrote:> Hi All, > > there is an issue in how templates are working that I''m not sure how to > workaround. I setup a template for an exim config that should add/remove > some directives depending on if some particular file is existing on > destination server. However template processing appears to work on > puppetmaster server and only after that ready config is being transferred to > destination server. The issue is the check for file existing in templates is > checking the file on puppetmaster, not on a target server. I tried to use > facts, but this didnt'' help either. Any suggestion on how this can be > performed? > > Thanks in advance.--~--~---------~--~----~------------~-------~--~----~ 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 Jun 11, 2008, at 7:55 PM, Jeff Leggett wrote:> > I am having the same issues with Templates, here''s the deal *I > think*: puppetd evaluates the templates on the puppetmaster, then > passes it down... so you probably need to use the stand alone puppet > executable. That worked for me. > > I am still leanirng my way through all this, so I could very well be > wrong.You are correct -- templates are compiled on the server, not on the client.> > On Jun 11, 8:34 pm, "Paul Johnson" <gentoo.ser...@gmail.com> wrote: >> Hi All, >> >> there is an issue in how templates are working that I''m not sure >> how to >> workaround. I setup a template for an exim config that should add/ >> remove >> some directives depending on if some particular file is existing on >> destination server. However template processing appears to work on >> puppetmaster server and only after that ready config is being >> transferred to >> destination server. The issue is the check for file existing in >> templates is >> checking the file on puppetmaster, not on a target server. I tried >> to use >> facts, but this didnt'' help either. Any suggestion on how this can be >> performed?-- I respect faith, but doubt is what gets you an education. -- Wilson Mizner --------------------------------------------------------------------- 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 -~----------~----~----~----~------~----~------~--~---
2008/6/12 Luke Kanies <luke@madstop.com>:> > On Jun 11, 2008, at 7:55 PM, Jeff Leggett wrote: > > > > > I am having the same issues with Templates, here''s the deal *I > > think*: puppetd evaluates the templates on the puppetmaster, then > > passes it down... so you probably need to use the stand alone puppet > > executable. That worked for me. > > > > I am still leanirng my way through all this, so I could very well be > > wrong. > > You are correct -- templates are compiled on the server, not on the > client. >yeah, I thought so, thanks for the clarification. Is there any way to get info from target server before a template is compiled? In other words, what actions are done before templates compiling? Thanks --~--~---------~--~----~------------~-------~--~----~ 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 Jun 11, 2008, at 11:14 PM, Paul Johnson wrote:> > 2008/6/12 Luke Kanies <luke@madstop.com>: > > On Jun 11, 2008, at 7:55 PM, Jeff Leggett wrote: > > > > > I am having the same issues with Templates, here''s the deal *I > > think*: puppetd evaluates the templates on the puppetmaster, then > > passes it down... so you probably need to use the stand alone puppet > > executable. That worked for me. > > > > I am still leanirng my way through all this, so I could very well be > > wrong. > > You are correct -- templates are compiled on the server, not on the > client. > > yeah, I thought so, thanks for the clarification. Is there any way > to get info from target server before a template is compiled? In > other words, what actions are done before templates compiling?Facter is the only way to get information from the client to the server. Look at the AddingFacts page (I think that''s what it is) for how to add custom facts. -- I can win an argument on any topic, against any opponent. People know this, and steer clear of me at parties. Often, as a sign of their great respect, they don''t even invite me. -- Dave Barry --------------------------------------------------------------------- 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 -~----------~----~----~----~------~----~------~--~---
2008/6/12 Luke Kanies <luke@madstop.com>:> > You are correct -- templates are compiled on the server, not on the > > client. > > > > yeah, I thought so, thanks for the clarification. Is there any way > > to get info from target server before a template is compiled? In > > other words, what actions are done before templates compiling? > > Facter is the only way to get information from the client to the > server. Look at the AddingFacts page (I think that''s what it is) for > how to add custom facts. >yeah, as I mentioned in the first email I tried to use facts (already existing facts, just to test) but this didn''t work for me either. Here is the example: 1) in the manifest we have: $test = $operatingsystem ? { CentOS => "XXX", Gentoo => "GGG", } file{ ''/tmp/myconf.cfg'': ensure => file, mode => 644, content => template("templates/myconf.cfg.erb"); ''/tmp/extest'': ensure => file, content => "$test", } 2) in the template we have: TEST = <%= $test %> on the target server we see the following results: 1) tmp/myconf.cfg: TEST 2) /tmp/extest: XXX Summarizing this we see that facts work ok when using them as file content, but not in templates. Am I doing something wrong? That''s why my question was: are templates being compiled before gathering facts from target server? I tried to move the section with fact outside node definition, in the main section, while template was inside a node definition, but this didn''t work well either. So I think I need to find the part of manifest which is processed before compiling templates and get facts in that section so I''ll be able to pass them to my templates after all. Does such section exist or compiling templates is the first what is being done while processing manifest? I appreciate any attention on this matter. Thanks in advance. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
2008/6/11 Paul Johnson <gentoo.server@gmail.com>:> 2) in the template we have: > > TEST = <%= $test %> >So, puppet templates use ERB templates... which are kinda like a subset of ruby more or less. There is a good doc on the puppet wiki as well as a bunch of really good docs out there on the web, typically relating to rails, but not exclusively so. Either way, within an ERB file, you don''t use a variable prefix like "$"... just say something like: TEST = <%= test %> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
the issue solved :) Thanks to all for replies. Yes, I read the docs about erb, and initially tried to use <%= test %> expression, but it gave me the following error: err: Could not retrieve catalog: Failed to parse template /var/lib/puppet/templates/myconf.cfg.erb: wrong number of arguments at /etc/puppet/manifests/site.pp:357 on node testnode So I tried $test and it didn''t produce any error as well as didn''t work right. The real problem was I shouldn''t use ''test'' name for variable, looks like it is some sort of reserved word (didn''t read anything in docs about this though), and when I renamed the variable to ''myvalue'' and used <%myvalue %> expression it started to work as expected :) Puppet Rocks! :) I''m on the way migrating from cfengine to puppet and the main problem is there is no ability(out of the box) to edit files directly yet, but hope this functionality will be added soon. Thanks to All for the help :) 2008/6/12 RijilV <rijilv@gmail.com>:> > 2008/6/11 Paul Johnson <gentoo.server@gmail.com>: > > 2) in the template we have: > > > > TEST = <%= $test %> > > > > > So, puppet templates use ERB templates... which are kinda like a > subset of ruby more or less. There is a good doc on the puppet wiki > as well as a bunch of really good docs out there on the web, typically > relating to rails, but not exclusively so. > > > Either way, within an ERB file, you don''t use a variable prefix like > "$"... just say something like: > > TEST = <%= test %> > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi On Jun 12, 10:56 pm, "Paul Johnson" <gentoo.ser...@gmail.com> wrote:> the issue solved :) Thanks to all for replies. Yes, I read the docs about > erb, and initially tried to use <%= test %> expression, but it gave me the > following error: > > err: Could not retrieve catalog: Failed to parse template > /var/lib/puppet/templates/myconf.cfg.erb: wrong number of arguments at > /etc/puppet/manifests/site.pp:357 on node testnode > > So I tried $test and it didn''t produce any error as well as didn''t work > right. The real problem was I shouldn''t use ''test'' name for variable, looks > like it is some sort of reserved word (didn''t read anything in docs about > this though), and when I renamed the variable to ''myvalue'' and used <%> myvalue %> expression it started to work as expected :)Yup, test is a method of the Kernel class: http://www.ruby-doc.org/core/classes/Kernel.html#M001085> Puppet Rocks! :) I''m on the way migrating from cfengine to puppet and the > main problem is there is no ability(out of the box) to edit files directly > yet, but hope this functionality will be added soon.You can do some rudimentary editing (replacing lines) with this: http://reductivelabs.com/trac/puppet/wiki/Recipes/SimpleText Cheers, Mark --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
2008/6/13 Mark Drayton <mdrayton@gmail.com>:> > > You can do some rudimentary editing (replacing lines) with this: > > http://reductivelabs.com/trac/puppet/wiki/Recipes/SimpleText >yeah, thanks for the URL, I saw it a while ago and then completely forgot about it :) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---