Good Afternoon, I''m running puppet vers. 0.24.4 and am trying to use some facts in puppet ERB templates. It appears as long as the fact is a simple type, such as a String, the fact works as expected in the ERB template. However if the fact is something more complex (like a Hash) it appears to get converted into a string. Using it directly in ruby (via Facter.value) returns the correct complex data type. Is there an elegant way to use complex facts in puppet''s erb templates? Thanks for any help you may have! Cheers, -- Greg -- 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 Fri, Apr 2, 2010 at 3:37 PM, Greg Retkowski <greg@rage.net> wrote:> Good Afternoon, > I''m running puppet vers. 0.24.4 and am trying to use some facts in puppet > ERB templates..24.4 is a pretty old version of Puppet, if its feasible I would upgrade.> It appears as long as the fact is a simple type, such as a String, the fact > works as expected in the ERB template. However if the fact is something more > complex (like a Hash) it appears to get converted into a string. > > Using it directly in ruby (via Facter.value) returns the correct complex > data type. > > Is there an elegant way to use complex facts in puppet''s erb templates? >Puppet will support hashes in the next major version (Rwolf), although I am not sure if the interaction between Puppet and Facter will support it. Until then, the best work around is to serialize the data as a string and deserialize it in the erb.> Thanks for any help you may have! > > Cheers, > > -- Greg > > > Hope this helps,-Dan> -- > 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<puppet-users%2Bunsubscribe@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.
Greg Retkowski
2010-Apr-05 21:34 UTC
Re: [Puppet Users] complex data types in puppet & facter
Hello Dan, Thanks. I''m following your suggestion and serializing anything complex that I need to get at in ERB. -- Greg Dan Bode wrote:> Hi, > > On Fri, Apr 2, 2010 at 3:37 PM, Greg Retkowski <greg@rage.net > <mailto:greg@rage.net>> wrote: > > Good Afternoon, > I''m running puppet vers. 0.24.4 and am trying to use some facts > in puppet ERB templates. > > > .24.4 is a pretty old version of Puppet, if its feasible I would upgrade. > > > It appears as long as the fact is a simple type, such as a String, > the fact works as expected in the ERB template. However if the > fact is something more complex (like a Hash) it appears to get > converted into a string. > > Using it directly in ruby (via Facter.value) returns the correct > complex data type. > > Is there an elegant way to use complex facts in puppet''s erb > templates? > > > Puppet will support hashes in the next major version (Rwolf), although > I am not sure if the interaction between Puppet and Facter will > support it. Until then, the best work around is to serialize the data > as a string and deserialize it in the erb. > > > > Thanks for any help you may have! > > Cheers, > > -- Greg > > > Hope this helps, > > -Dan > > > -- > 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 > <mailto:puppet-users@googlegroups.com>. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com > <mailto:puppet-users%2Bunsubscribe@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.-- 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.
> > Is there an elegant way to use complex facts in puppet''s erb templates? > > Puppet will support hashes in the next major version (Rwolf), although I am > not sure if the interaction between Puppet and Facter will support it.Dan, does this mean it will be possible to have a template like this 16 <% workers.each do |worker| -%> 17 worker.<%= worker %>.type=<%= worker[''type''] %> 18 worker.<%= worker %>.host=<%= worker[''host''] %> .... 24 25 <% end -%> which can be pouplated with an external node definition like this one: --- classes: - vim - users - templates_eval::testvars environment: test parameters: workers: bo-01-010101: type: ajp13 host: myhostname.net And is this already available in the current beta release? I didn''t find anything in the release notes so far (concerning ERB templates, though hashes are mentioned). Thanks! Bernd -- 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.
Bernd Adamowicz
2010-May-04 07:43 UTC
AW: [Puppet Users] Re: complex data types in puppet & facter
Ok, found the answer myself. Just installed 25.5-rc2 on client and server and tried it. But same error message when parsing the template.> > > > Is there an elegant way to use complex facts in puppet''s erb > templates? > > > > Puppet will support hashes in the next major version (Rwolf), > although I am > > not sure if the interaction between Puppet and Facter will support > it. > > Dan, > > does this mean it will be possible to have a template like this > > 16 <% workers.each do |worker| -%> > 17 worker.<%= worker %>.type=<%= worker[''type''] %> > 18 worker.<%= worker %>.host=<%= worker[''host''] %> > .... > 24 > 25 <% end -%> > > which can be pouplated with an external node definition like this one: > > --- > classes: > - vim > - users > - templates_eval::testvars > environment: test > parameters: > workers: > bo-01-010101: > type: ajp13 > host: myhostname.net > > And is this already available in the current beta release? I didn''t > find anything in the release notes so far (concerning ERB templates, > though hashes are mentioned). > > Thanks! > Bernd-- 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.
Patrick
2010-May-04 07:59 UTC
Re: AW: [Puppet Users] Re: complex data types in puppet & facter
I think that Rwolf is puppet 0.26.x. On May 4, 2010, at 12:43 AM, Bernd Adamowicz wrote:> Ok, found the answer myself. Just installed 25.5-rc2 on client and server and tried it. But same error message when parsing the template. > >> >>>> Is there an elegant way to use complex facts in puppet''s erb >> templates? >>> >>> Puppet will support hashes in the next major version (Rwolf), >> although I am >>> not sure if the interaction between Puppet and Facter will support >> it. >> >> Dan, >> >> does this mean it will be possible to have a template like this >> >> 16 <% workers.each do |worker| -%> >> 17 worker.<%= worker %>.type=<%= worker[''type''] %> >> 18 worker.<%= worker %>.host=<%= worker[''host''] %> >> .... >> 24 >> 25 <% end -%> >> >> which can be pouplated with an external node definition like this one: >> >> --- >> classes: >> - vim >> - users >> - templates_eval::testvars >> environment: test >> parameters: >> workers: >> bo-01-010101: >> type: ajp13 >> host: myhostname.net >> >> And is this already available in the current beta release? I didn''t >> find anything in the release notes so far (concerning ERB templates, >> though hashes are mentioned). >> >> Thanks! >> Bernd > > -- > 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.
James Turnbull
2010-May-04 08:43 UTC
Re: AW: [Puppet Users] Re: complex data types in puppet & facter
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 4/05/10 5:59 PM, Patrick wrote:> I think that Rwolf is puppet 0.2*6*.x. >That''s correct. Next maintenance release is 0.25.5 - currently in testing. Next feature release is Rowlff which doesn''t have a version number assigned as yet and is the final stages of being tidied up. You can see draft release notes at: http://projects.puppetlabs.com/projects/puppet/wiki/Release_Notes Regards James Turnbull - -- Author of: * Pro Linux System Administration (http://tinyurl.com/linuxadmin) * Pulling Strings with Puppet (http://tinyurl.com/pupbook) * Pro Nagios 2.0 (http://tinyurl.com/pronagios) * Hardening Linux (http://tinyurl.com/hardeninglinux) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEVAwUBS9/eNyFa/lDkFHAyAQIlzQgA5ZNXDixWh0UAH6KTSHi6kuuG5QWaRRRU NmYEgjrS8ljJ4Ja3GDnYZeaaPdvpJUlDPfYq50DGcOnxZsXBEhtZa51L2rTyq2P7 J40RYZByQIllC2uO9ouPKSoypnKdbwg+gtszdyrjAHRjdnlUVmO59nVJoJpyfQNV qcCMx4pD4BdoUczzjaCSaWCIChk4DvDVZ6ISehe7uYa5lB0XAbWganH2q7Iil3u3 qwudmRudTi5OcRc+ddr0MuNpMbYovjbraApSNppoOQgAbFnUl9CS6XtviPVy07WM tS02jC1fjdQrSYhf+AJcb9NbUfqn1sRChL3CTlR0TNj1BFDXyPdfjA==Jjt3 -----END PGP SIGNATURE----- -- 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.