# /opt/puppetlabs/puppet/bin/ruby -ryaml -e "puts YAML.load_file('out.yaml')" |
Traceback (most recent call last): |
43: from -e:1:in `<main>' |
42: from /opt/puppetlabs/puppet/lib/ruby/2.5.0/psych.rb:497:in `load_file' |
<snip> |
1: from /opt/puppetlabs/puppet/lib/ruby/2.5.0/psych/class_loader.rb:54:in `resolve' |
/opt/puppetlabs/puppet/lib/ruby/2.5.0/psych/class_loader.rb:54:in `path2class': undefined class/module Puppet:: (ArgumentError)
|
However this works:
# /opt/puppetlabs/puppet/bin/ruby -ryaml -rpuppet -e "puts YAML.load_file('out.yaml')" |
{"mysql_database"=>{"PERCONA_SCHEMA"=>{"ensure"=>"present", "charset"=>"utf8", "collate"=>"utf8_general_ci"}}}
|
As does this code to strip the tags:
require 'yaml' |
|
data = YAML::parse_file(ARGV[0]) |
data.root.each do |o| |
if o.respond_to?(:tag=) && o.tag != nil && o.tag.start_with?("!ruby") |
o.tag = nil |
end |
end |
puts data.to_ruby
|
# /opt/puppetlabs/puppet/bin/ruby reader.rb out.yaml |
{"mysql_database"=>{"PERCONA_SCHEMA"=>{"ensure"=>"present", "charset"=>"utf8", "collate"=>"utf8_general_ci"}}}
|
The mysql module should call .to_s on the process output, and puppet pops serialization should not emit ProcessOutput objects. |