Jonathon Anderson
2012-Apr-16 08:45 UTC
[Puppet Users] collecting resources for iteration in a template
I have a `sysctl::variable` defined type that creates files in `/etc/sysctl.d`. Some operating systems (*cough*SLES10*cough*) don''t read sysctl settings from `/etc/sysctl.d`, though, and expect all settings to be in a single file, `/etc/sysctl.conf`. For such operating systems, I''d like to define the content of that file with a template that references the values of the `sysctl::variable`s. In the Puppet DSL I can collect all fragments with language like `Sysctl::Variable<| |>`. How can I do something similar in a template such that I can access the variable names and values? For example: <% variables = magic(''Sysctl::Variable<||>'') variables.each do |variable| -%> <%= variable.name %> = <%= variable.value %> <% end -%> -- 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/-/BDDUjVBiAI4J. 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.
Wil Cooley
2012-Apr-17 05:46 UTC
[Puppet Users] Re: collecting resources for iteration in a template
On Apr 16, 1:45 am, Jonathon Anderson <anderbub...@gmail.com> wrote:> I have a `sysctl::variable` defined type that creates files in > `/etc/sysctl.d`. Some operating systems (*cough*SLES10*cough*) don''t read > sysctl settings from `/etc/sysctl.d`, though, and expect all settings to be > in a single file, `/etc/sysctl.conf`. For such operating systems, I''d like > to define the content of that file with a template that references the > values of the `sysctl::variable`s. > > In the Puppet DSL I can collect all fragments with language like > `Sysctl::Variable<| |>`. How can I do something similar in a template such > that I can access the variable names and values? For example:Have you considered instead using something like the "file fragment pattern"? Basically, you add ''notifiy'' to sysctl::variable resources to notify an exec that rebuilds sysctl.conf from sysctl.d (basically "cat /etc/sysctl.d/*.conf > /etc/sysctl.conf"). http://projects.puppetlabs.com/projects/puppet/wiki/Generating_a_config_file_from_fragments (I''m not sure the special concatenation script is really necessary; you can have the exec notify the service to reload if necessary and the ''for'' loop is unnecessary with shell wildcards. At least, that''s how we do it at work.) Wil -- 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 Bigum
2012-Apr-17 08:14 UTC
Re: [Puppet Users] Re: collecting resources for iteration in a template
Just in case you haven''t seen it, RIP''s original concat module: https://github.com/ripienaar/puppet-concat It hides a lot of the concatenation implementation detail in defined types and the temporary file fragments are stored under /var/lib/puppet/. On 17/04/12 06:46, Wil Cooley wrote:> On Apr 16, 1:45 am, Jonathon Anderson<anderbub...@gmail.com> wrote: >> I have a `sysctl::variable` defined type that creates files in >> `/etc/sysctl.d`. Some operating systems (*cough*SLES10*cough*) don''t read >> sysctl settings from `/etc/sysctl.d`, though, and expect all settings to be >> in a single file, `/etc/sysctl.conf`. For such operating systems, I''d like >> to define the content of that file with a template that references the >> values of the `sysctl::variable`s. >> >> In the Puppet DSL I can collect all fragments with language like >> `Sysctl::Variable<| |>`. How can I do something similar in a template such >> that I can access the variable names and values? For example: > Have you considered instead using something like the "file fragment > pattern"? Basically, you add ''notifiy'' to sysctl::variable resources > to notify an exec that rebuilds sysctl.conf from sysctl.d (basically > "cat /etc/sysctl.d/*.conf> /etc/sysctl.conf"). > > http://projects.puppetlabs.com/projects/puppet/wiki/Generating_a_config_file_from_fragments > > (I''m not sure the special concatenation script is really necessary; > you can have the exec notify the service to reload if necessary and > the ''for'' loop is unnecessary with shell wildcards. At least, that''s > how we do it at work.) > > Wil >-- 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.
Jonathon Anderson
2012-Apr-17 09:58 UTC
[Puppet Users] Re: collecting resources for iteration in a template
On Tuesday, April 17, 2012 8:46:33 AM UTC+3, Wil Cooley wrote:> > Have you considered instead using something like the "file fragment > pattern"? Basically, you add ''notifiy'' to sysctl::variable resources > to notify an exec that rebuilds sysctl.conf [...]Yeah, that''s what we''re already doing. I just dislike distributing a script to do something that, in my opinion, should be part of assembling the catalog in the first place. It''s also stateful (to the state at which the fragment is first distributed), and, thus, fragile. (A failure rebuilding once will not be repaired on subsequent runs unless the fragments or the script change.) -- 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/-/EWxjREZK9RMJ. 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.
Jonathon Anderson
2012-Apr-17 12:16 UTC
Re: [Puppet Users] Re: collecting resources for iteration in a template
On Tuesday, April 17, 2012 11:14:15 AM UTC+3, Luke Bigum wrote:> > Just in case you haven''t seen it, RIP''s original concat module: > https://github.com/ripienaar/puppet-concatI hadn''t seen it. Thank you for the pointer. Like I said, this is basically what we''re doing now; but It''s probably better to use that than to re-implement this for every fragment-concatenating module we have. If I end up not being able to find a compilation-time solution, this is probably the best avenue left. tl;dr, once again, RIP has already thought of that! ~jonathon -- 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/-/336Pr6j-eg8J. 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.