[chef] convert ruby attributes to json ?


Chronological Thread 
  • From: Vladimir Skubriev < >
  • To:
  • Subject: [chef] convert ruby attributes to json ?
  • Date: Thu, 10 Oct 2013 12:34:34 +0400

I need to define a role with knife role edit

And I cannot convert attributes from Readme.md in https://github.com/fnichol/chef-rvm/tree/master

I need to define:

  default['rvm']['user_installs'] = [
  { 'user'            => 'www-data',
    'default_ruby'    => "2.0.0p247",
    'global_gems'     => [
      { 'name'    => 'rake' },
      { 'name'    => 'bundler',},
      { 'name'    => 'json' },
      { 'name'    => 'mysql2' },
      { 'name'    => 'libxml-ruby' },
      { 'name'    => 'passenger', 'version' => "4.0.20" }
    ]
  },
  ]

In json format I create this:

"override_attributes": {
    "rvm": {
      "user_installs": {
        "user": "www-data",
        "default_ruby": "2.0.0p247",
        "global_gems": [
          {
            "name": "rake"
          },
          {
            "name": "bundler"
          },
          {
            "name": "json"
          },
          {
            "name": "mysql2"
          },t
          {
            "name": "libxml-ruby"
          },
          {
            "version": "4.0.20",
            "name": "passenger"
          }
        ]
      }
    }
  },

But I recive an error in chef-client run:

Attribute to_ary is not defined!



/var/chef/cache/cookbooks/chef-rvm/recipes/user_install.rb:

 17:  # limitations under the License.
 18:  #
 19: 
 20:  include_recipe 'rvm'
 21: 
 22:  install_pkg_prereqs
 23: 
 24>> Array(node['rvm']['user_installs']).each do |rvm_user|
 25:    version = rvm_user['version'] || node['rvm']['version']
 26:    branch  = rvm_user['branch'] || node['rvm']['branch']
 27: 
 28:    script_flags      = build_script_flags(branch, version)
 29:    upgrade_strategy  = build_upgrade_strategy(rvm_user['upgrade'])
 30:    installer_url     = rvm_user['installer_url'] || node['rvm']['installer_url']
 31:    rvm_prefix        = rvm_user['home'] ||
 32:                        "#{node['rvm']['user_home_root']}/#{rvm_user['user']}"
 33:    rvm_gem_options   = rvm_user['rvm_gem_options'] || node['rvm']['rvm_gem_options']



How to describe it?

How to describe my vars in json ?



-- 
Best regards,

CVision Lab System Administrator
Vladmir Skubriev



Archive powered by MHonArc 2.6.16.

§