[chef] Re: Converting node attributes to yaml


Chronological Thread 
  • From: Daniel DeLeo < >
  • To:
  • Subject: [chef] Re: Converting node attributes to yaml
  • Date: Tue, 4 Feb 2014 15:43:26 -0800


On Tuesday, February 4, 2014 at 3:35 PM, Curtis Stewart wrote:

I’m trying to allow a settings.yml file to be generated from node attributes.

I assumed the following would work, but I’m left with various “!ruby/hash:Chef::Node::ImmutableMash” lines in my yaml file.

YAML::dump(node[‘applications']['settings'].to_hash)

settings: !ruby/hash:Chef::Node::ImmutableMash
foo: !ruby/array:Chef::Node::ImmutableArray
- settingone
bar: !ruby/array:Chef::Node::ImmutableArray
- settingone

I’d like to be able to allow for a very flexible configuration, however, maybe this is just a bad practice and I should use a template with a smaller number of configurations?

Thanks,
Curtis
There’s a patch to make to_hash convert ImmutableMash to regular Hashes, but it doesn’t correctly handle some cases of nested structures, like an Array of Hashes. It’d be great if you could fix it up: https://tickets.opscode.com/browse/CHEF-3953

If that’s beyond the work you’re willing to do, there’s at least some monkey-patch type workarounds to be found in that and related tickets (though monkey patches are inherently brittle and can be accidentally broken in minor or possibly patch releases, so beware).

-- 
Daniel DeLeo




Archive powered by MHonArc 2.6.16.

§