Hello, I use a parameterized class and declare it as a resource. How can I pass the parameters from outside any declaration or manifest, during runtime? For example, can I pass the parameters during a call of "puppet kick" ? Thank you. Best regards Michael -- 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.
Have a look here. I am assuming you are running puppet 3 but the syntax is the same in 2.6 and 2.7. http://docs.puppetlabs.com/puppet/3/reference/lang_classes.html#using-resource-like-declarations On 20 December 2012 07:45, Michael Hüttermann <michael@huettermann.net>wrote:> Hello, > > I use a parameterized class and declare it as a resource. How can I pass > the parameters from outside any declaration or manifest, during runtime? > For example, can I pass the parameters during a call of "puppet kick" ? > > > Thank you. > > > Best regards > Michael > > -- > 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. > >-- 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 Wednesday, December 19, 2012 3:45:39 PM UTC-6, Michael Hüttermann wrote:> > > I use a parameterized class and declare it as a resource. How can I pass > the parameters from outside any declaration or manifest, during runtime? >To the best of my knowledge, it is not possible to do such a thing, at least not directly (but see below). Puppet always operates by compiling a manifest set into a catalog containing a digested version of all the resources, parameters, properties, and relationships to apply, and then applying the compiled catalog without considering further input. Those two steps often occur on different systems (master / agent) but they can be done all in one process ("puppet apply"). Class parameter values are determined strictly during manifest compilation. What you are asking for seems directed toward using Puppet as a script engine, and that''s very much counter to Puppet''s architecture and intended problem space. Puppet''s objective is to establish and maintain known configurations on target nodes, so it really doesn''t make sense to have it determine the appropriate parameters on a per-run basis. If that''s what you want then I''d recommend you write an ordinary script. Nevertheless, if you insist on doing as you say, then here''s a way to accomplish it: 1. Set environment-based node facts for the desired parameter values, as described here: http://docs.puppetlabs.com/guides/faq.html#can-i-access-environment-variables-with-facter 2. In the appropriate manifest, set the class parameters according to those node facts. You can do that conditionally, if you prefer. 3. Run the agent normally. If you wish, you can use the --tag option to limit the resources to be applied. For example, can I pass the parameters during a call of "puppet kick" ?> >"puppet kick" just triggers the agent (if it''s listening) to perform an ordinary catalog run. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/m1dmI-VGYEMJ. 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.
Hello, I don''t get that example working. Looks like the variable is not set although "facter" lists it. In my manifest, I can access all Facter variables, but not the one I''ve defined the way described in your post and in the FAQ. It''s empty. I''m on Puppet 2.7. What can be the reason? Thanks. Michael On Thursday, December 20, 2012 3:32:48 PM UTC+1, jcbollinger wrote:> > Nevertheless, if you insist on doing as you say, then here''s a way to > accomplish it: > > 1. Set environment-based node facts for the desired parameter values, > as described here: > http://docs.puppetlabs.com/guides/faq.html#can-i-access-environment-variables-with-facter > 2. In the appropriate manifest, set the class parameters according to > those node facts. You can do that conditionally, if you prefer. > 3. Run the agent normally. If you wish, you can use the --tag option > to limit the resources to be applied. > > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/bj_QMoWMYTkJ. 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 Tuesday, January 8, 2013 4:15:02 AM UTC-6, Michael Hüttermann wrote:> > Hello, > I don''t get that example working. Looks like the variable is not set > although "facter" lists it. In my manifest, I can access all Facter > variables, but not the one I''ve defined the way described in your post and > in the FAQ. It''s empty. I''m on Puppet 2.7. What can be the reason? > >It''s hard to say without looking at your code and command(s), but my first guess would be that the variables in question are *not* set in the environment in which the Puppet agent is running. This is a function of how the agent is started. In particular, do not assume that the agent will have the environment of a login shell unless you start it from one. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/dNXQgBHmFmsJ. 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.