Open krissik opened 5 years ago
I don't see anything obvious that would cause that to fail in Puppet. Maybe it has to do with how the file name is resolved to an absolute path for include file('foo')
.
Can you share more context about how you're using Hocon in your Puppet code, and how that makes its way to the cluster_name
parameter of Profile::Haproxy
? Presumably it works when you inline the settings?
Yeah, just ran a test where the files are in a different directory. include file('foo')
resolves from your current working directory, not the directory where the including config lives. That may be what they mean by "doesn't work". Hocon also just silently ignores files it can't find and returns an empty object, so these errors can be annoying to find.
I'm not really sure of a better way to do this in Hocon. I think the Java version relies on having everything in a resource path and loads relative paths from there, but Ruby doesn't have that. I think this should be filed as a bug with Puppet (or Puppet Server) if you're trying to use it with one of Puppet's configs.
If you're using a custom function that loads Hocon, I'd suggest something like
conf = Dir.chdir('/path/to/configs') do
Hocon.load('conf')
end
The readme says that file includes are unsupported. What does that mean? I found a implementation of file include at /lib/hocon/impl/simple_includer.rb. It seems to work if I use it in a ruby script, readhocon.rb:
hocon-test-with-include.conf:
hocon-include.conf:
hocon-include.json:
Run script
But when I try to use includes with puppet it is not working. Puppet complains about missing parameters which are defined in an included file:
Can I use HOCON file includes with puppet? Are there documentation or any examples about it?
Environment