Closed PierreR closed 9 years ago
There are two ways to do it : either write it in ruby, or in Haskell. If the ruby yaml library is more or less guaranteed to exist on the host running language-puppet, I believe this would be the right thing to do. Do you know if it's ruby's "base" ?
I don't know ruby
that much but my understanding is that it is in ruby "base":
http://ruby-doc.org/stdlib-2.0.0/libdoc/yaml/rdoc/YAML.html
Without installing more than ruby:
arch-docker ~ > irb
irb(main):001:0> to_yaml
NameError: undefined local variable or method `to_yaml' for main:Object
from (irb):1
from /usr/bin/irb:11:in `<main>'
irb(main):002:0> require 'yaml'
=> true
irb(main):003:0> to_yaml
=> "--- !ruby/object {}\n"
irb(main):004:0>
That was easy : 0ac8b70c945b8590fe5747bd711b2a2fd37e961e
Thanks !
Trying it, I actually get this error
./check_role puppetserver_testing
ERROR: (puppetserver_testing) uninitialized constant Encoding::ASCII_8BIT
/usr/lib/ruby/2.2.0/psych/visitors/yaml_tree.rb:435:in `binary?'
/usr/lib/ruby/2.2.0/psych/visitors/yaml_tree.rb:306:in `visit_String'
/usr/lib/ruby/2.2.0/psych/visitors/yaml_tree.rb:152:in `accept'
/usr/lib/ruby/2.2.0/psych/visitors/yaml_tree.rb:376:in `block in visit_Hash'
/usr/lib/ruby/2.2.0/psych/visitors/yaml_tree.rb:375:in `each'
/usr/lib/ruby/2.2.0/psych/visitors/yaml_tree.rb:375:in `visit_Hash'
/usr/lib/ruby/2.2.0/psych/visitors/yaml_tree.rb:152:in `accept'
/usr/lib/ruby/2.2.0/psych/visitors/yaml_tree.rb:116:in `push'
/usr/lib/ruby/2.2.0/psych.rb:409:in `dump'
/usr/lib/ruby/2.2.0/psych/core_ext.rb:14:in `psych_to_yaml'
(erb):3:in `get_binding'
/usr/lib/ruby/2.2.0/erb.rb:863:in `eval'
/usr/lib/ruby/2.2.0/erb.rb:863:in `result'
/usr/local/bin/hrubyerb.rb:107:in `runFromContent'
/usr/local/bin/hrubyerb.rb:102:in `runFromFile'
in ./modules/puppetdb/templates/routes.yaml.erb at # "./modules/puppetdb/manifests/master/routes.pp" (line 38, column 1
Any idea ?
No idea :) Perhaps try to juggle with your locales to see if this changes something ?
I have a failry standard locale setting:
@arch-docker ~ > locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
If I tried:
irb(main):018:0> puts [['hello', 'world']].to_yaml
---
- - hello
- world
=> nil
but if I do it in a elb file
<%= [['hello', 'world']].to_yaml %>
Then I have got the Encoding error. Is it working on your box ?
I will give a shot on another distro to be sure it not related.
Yeah I tried this before pushing :
$lala = [1,2,3,4,5]
file { '/tmp/x':
content => inline_template('lalalal <%= @lala.to_yaml %>');
}
Well this works for me too but this does not:
$lala = ['hello', 'world']
file { '/tmp/x':
content => inline_template('lalalal <%= @lala.to_yaml %>');
}
I just pushed a "fix" (d25ff3d). This seems to work, but I am pretty sure this breaks things. Encoding::* should be available all the time, as it's built in into ruby ...
Yep it does fix the problem but what a terrible fix indeed ;-)
Not sure if you want to close the issue, do you ?
I got it, it's a bug in the ruby interpreter initialization. I just uploaded a new hruby
, I am checking language-puppet.
This time it should work without the terrible fix !
Works nicely. Thx !
Hi,
Would it be possible to implement to_yaml in erb file ?
Cheers,