psychobyte
2012-Apr-24 20:53 UTC
[Puppet Users] ordering or chaining for generate() function
Hi, I need to run a the generate() function (server side) in order to populate a data file for one of my modules. Is there a way to ensure that the generate function is run before a config file is created (the contents of the file doesn''t come directly from generate()). Right now I''m getting around this by creating a bogus File resource and chaining that before I write a config file. =============================== file { "mp_volumes.yaml": ensure => ''present'', path => ''/tmp/cmpllnt_vol.out'', content => generate(''/usr/bin/myscript''), owner => ''root'', group => ''root'', mode => ''0644'', } # Make sure mp_volumes.yaml is up to date before we create conf file File[''mp_volumes.yaml'']->File[''conffile''] ============================== Is there a more appropriate way of doing this? Thanks, -- 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/-/5OeG7J97VsQJ. 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 Bigum
2012-Apr-25 07:49 UTC
Re: [Puppet Users] ordering or chaining for generate() function
You might be able to do something like this (untested): $blackhole_variable = generate(''/usr/bin/myscript'') file { "conffile": ... } On 24/04/12 21:53, psychobyte wrote:> Hi, > > I need to run a the generate() function (server side) in order to > populate a data file for one of my modules. Is there a way to ensure > that the generate function is > run before a config file is created (the contents of the file doesn''t > come directly from generate()). > > Right now I''m getting around this by creating a bogus File resource > and chaining that before I write a config file. > > ==============================> file { "mp_volumes.yaml": > ensure => ''present'', > path => ''/tmp/cmpllnt_vol.out'', > content => generate(''/usr/bin/myscript''), > owner => ''root'', > group => ''root'', > mode => ''0644'', > } > > # Make sure mp_volumes.yaml is up to date before we create conf file > File[''mp_volumes.yaml'']->File[''conffile''] > ==============================> > Is there a more appropriate way of doing this? > > Thanks, > > > -- > 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/-/5OeG7J97VsQJ. > 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 Bigum Information Systems Ph: +44 (0) 20 3192 2520 luke.bigum@lmax.com | http://www.lmax.com LMAX, Yellow Building, 1A Nicholas Road, London W11 4AN FX and CFDs are leveraged products that can result in losses exceeding your deposit. They are not suitable for everyone so please ensure you fully understand the risks involved. The information in this email is not directed at residents of the United States of America or any other jurisdiction where trading in CFDs and/or FX is restricted or prohibited by local laws or regulations. The information in this email and any attachment is confidential and is intended only for the named recipient(s). The email may not be disclosed or used by any person other than the addressee, nor may it be copied in any way. If you are not the intended recipient please notify the sender immediately and delete any copies of this message. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden. LMAX operates a multilateral trading facility. Authorised and regulated by the Financial Services Authority (firm registration number 509778) and is registered in England and Wales (number 06505809). Our registered address is Yellow Building, 1A Nicholas Road, London, W11 4AN. -- 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.
jcbollinger
2012-Apr-25 13:07 UTC
[Puppet Users] Re: ordering or chaining for generate() function
On Apr 24, 3:53 pm, psychobyte <psychob...@gmail.com> wrote:> I need to run a the generate() function (server side) in order to populate > a data file for one of my modules. Is there a way to ensure that the > generate function is > run before a config file is created (the contents of the file doesn''t come > directly from generate()).So the script run via generate() has some kind of side effect on the master that later generation of the config file relies on? What a terrible strategy. If you explain your problem in more detail then it is likely that we can suggest a superior alternative. John -- 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.
Krzysztof Wilczynski
2012-Apr-25 13:50 UTC
[Puppet Users] Re: ordering or chaining for generate() function
Hi, Am I right in thinking that something like that has place. On the Master: generate() -> template() and/or "static file" -> /config/file/on/the/client Then, if /config/file/on/the/client exists, you do not use generate(), yet when on the contrary, then you have to fire generate() first to generate content for said client-side configuration file? KW -- 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/-/6q9nKC6RZqIJ. 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.
psychobyte
2012-Apr-25 16:49 UTC
[Puppet Users] Re: ordering or chaining for generate() function
Essentially, yeah. we have a data file that needs updating on the server. This is done through a custom script. i want to use generate() to run that script server side before we re-create the config files via puppet. I want to guarantee that the generate function runs before any file resources. Thanks. On Wednesday, April 25, 2012 6:07:05 AM UTC-7, jcbollinger wrote:> > > > On Apr 24, 3:53 pm, psychobyte <psychob...@gmail.com> wrote: > > I need to run a the generate() function (server side) in order to > populate > > a data file for one of my modules. Is there a way to ensure that the > > generate function is > > run before a config file is created (the contents of the file doesn''t > come > > directly from generate()). > > > So the script run via generate() has some kind of side effect on the > master that later generation of the config file relies on? What a > terrible strategy. If you explain your problem in more detail then it > is likely that we can suggest a superior alternative. > > > 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/-/hSIvD25sp0gJ. 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.
psychobyte
2012-Apr-25 16:50 UTC
[Puppet Users] Re: ordering or chaining for generate() function
yes. I''m running a server side script that creates some data used to update a client-side config file. On Wednesday, April 25, 2012 6:50:52 AM UTC-7, matti wrote:> > Hi, > > Am I right in thinking that something like that has place. On the Master: > > generate() -> template() and/or "static file" -> /config/file/on/the/client > > Then, if /config/file/on/the/client exists, you do not use generate(), yet > when on the contrary, then you have to fire generate() first to generate > content for said client-side configuration file? > > KW >-- 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/-/phGZ84y3m_oJ. 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.
Krzysztof Wilczynski
2012-Apr-25 19:48 UTC
[Puppet Users] Re: ordering or chaining for generate() function
Hi, On Wednesday, April 25, 2012 5:49:03 PM UTC+1, psychobyte wrote:> > Essentially, yeah. >[...]> I want to guarantee that the generate function runs before any file > resources. >In such case, look at stages, perhaps it will help. Other than that, if you want to make sure that said configuration file is not present on the client side and only then run generate, you could have a fact (I can help writing one) that yields a boolean if the configuration file exists or not and then use this value in an if-statement where you''d run generate() function conditionally. KW -- 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/-/Y-sbYG_nwV0J. 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.
jcbollinger
2012-Apr-26 13:16 UTC
[Puppet Users] Re: ordering or chaining for generate() function
On Apr 25, 11:49 am, psychobyte <psychob...@gmail.com> wrote:> Essentially, yeah. > > we have a data file that needs updating on the server. This is done > through a custom script. i want to use generate() to run that script server > side > before we re-create the config files via puppet. I want to guarantee that > the generate function runs before any file resources.That doesn''t make sense to me. Is the data file you are trying to generate specific to the node you want to configure? If not, then why do you need to (re)generate it every time a node requests a catalog? If so, then why can''t you incorporate the data generation directly into the process of generating the target config file? Alternatively, why is it preferable to generate the node-specific data file on the server instead of on the node? If you insist on continuing with this unwise approach, then you need to understand that Puppet''s resource relationships (and thus also run stages) influence only the order in which resources are applied to the node, not the order in which related operations are performed on the master. Your best bet is Luke''s suggestion, which is basically to invoke generate() in the same class and above your declaration of File[''conffile'']. But really, think again. John -- 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.