Gonzalo Servat
2013-Feb-12 06:16 UTC
[Puppet Users] Hiera question -- accessing a hash from an erb template
Hi All, Simple question (hopefully). Say I have this: common.yaml: foo: bar: 10GB ... and in the manifest: $config = hiera(''foo'') file { ''/etc/foo.conf'': content => template(''module/foo.erb'') } ... and in foo.erb: file_size: <%= @config[''bar''] %> For some reason, the output in /etc/foo.conf will be ''10GB'' on its own line, instead of ''file_size: 10GB''. Almost as if there is a funny character in there? Any ideas? Thanks. Gonzalo -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
jcbollinger
2013-Feb-12 14:41 UTC
[Puppet Users] Re: Hiera question -- accessing a hash from an erb template
On Tuesday, February 12, 2013 12:16:00 AM UTC-6, Gonzalo wrote:> > Hi All, > > Simple question (hopefully). Say I have this: > > common.yaml: > > foo: > bar: 10GB > > ... and in the manifest: > > $config = hiera(''foo'') > > file { ''/etc/foo.conf'': > content => template(''module/foo.erb'') > } > > ... and in foo.erb: > > file_size: <%= @config[''bar''] %> > > For some reason, the output in /etc/foo.conf will be ''10GB'' on its own > line, instead of ''file_size: 10GB''. Almost as if there is a funny character > in there? > > Any ideas? >Maybe there''s a funny character in there. Seriously. Especially if you have a mixture of Windows and Unix, you might accidentally end up with carriage return characters (ASCII 0x0D) in some of your text files on the Unix side. Different Unix editors, viewers, and utilities may handle that situation differently. Examine both your template and your data file for unexpected characters. Many Unix text editors have modes in which they will display such characters to you (and thus allow you to edit them out). To just see whether there are any, you could try listing the files via ''cat --show-nonprinting'' John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Gonzalo Servat
2013-Feb-12 21:05 UTC
Re: [Puppet Users] Re: Hiera question -- accessing a hash from an erb template
On Wed, Feb 13, 2013 at 1:41 AM, jcbollinger <John.Bollinger@stjude.org>wrote:> > For some reason, the output in /etc/foo.conf will be ''10GB'' on its own >> line, instead of ''file_size: 10GB''. Almost as if there is a funny character >> in there? >> >> Any ideas? >> > > > Maybe there''s a funny character in there. Seriously. > > Especially if you have a mixture of Windows and Unix, you might > accidentally end up with carriage return characters (ASCII 0x0D) in some of > your text files on the Unix side. Different Unix editors, viewers, and > utilities may handle that situation differently. > > Examine both your template and your data file for unexpected characters. > Many Unix text editors have modes in which they will display such > characters to you (and thus allow you to edit them out). To just see > whether there are any, you could try listing the files via ''cat > --show-nonprinting'' >Thanks John for replying. Odd stuff but just before this line, I had another <%= ... %> block and replacing %> with -%> on the previous block seems to have done the trick. - Gonzalo -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.