Skip to content

Instantly share code, notes, and snippets.

@cabecada
Created January 25, 2017 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cabecada/d6940042b1bb9f5ede3df4438f1e65e3 to your computer and use it in GitHub Desktop.
Save cabecada/d6940042b1bb9f5ede3df4438f1e65e3 to your computer and use it in GitHub Desktop.
Puppet erb converts int to str in yaml dump
root@master:/etc/puppet# cat /tmp/modules/foo/templates/foo
<%-
def yaml_indent(conds)
return_val = []
tmp_val = conds.to_yaml.split("\n")
tmp_val.delete('---')
tmp_val.each do |val|
return_val << " " + val
end
return_val.join("\n")
end
-%>
<%= yaml_indent(@foo) %>
root@master:/etc/puppet# cat /tmp/modules/foo/manifests/init.pp
class foo {
$foo = {"a" => 1, "b" => "he"}
file { '/tmp/foo':
content => template('foo/foo'),
owner => root,
group => root,
mode => 644,
}
}
root@master:/etc/puppet# puppet apply --modulepath /tmp/modules -e 'include foo'
Already evaluated rest at /var/lib/gems/2.0.0/gems/facter-2.4.6/lib/facter/ec2.rb:21, reevaluating anyways
Already evaluated rest at /var/lib/gems/2.0.0/gems/facter-2.4.6/lib/facter/ec2.rb:38, reevaluating anyways
Already evaluated rest at /var/lib/gems/2.0.0/gems/facter-2.4.6/lib/facter/gce.rb:4, reevaluating anyways
Notice: Compiled catalog for master.vagrant.local in environment vagrant in 0.26 seconds
Notice: Finished catalog run in 0.01 seconds
root@master:/etc/puppet# cat /tmp/foo
---
a: "1"
b: he
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment