Chef-Provisioning and custom attributes (AWS)

Hi All

It is possible to pass custom attributes through a chef-provisioner node, into a recipe in a role run list?

Setup is… I have a provisioner node, and the recipe to provision machines, specifies a role to add the node to.

1.upto(num_solrservers) do |i|

     machine "#{node['solr_cluster_name']}-node#{i}" do
     role** 'solr_build'**
........

[root@provisioner provision]# knife role show solr_build
chef_type: role
default_attributes:
description:
env_run_lists:
json_class: Chef::Role
name: solr_build
override_attributes:
run_list:
recipe[setup::test]
** recipe[solr]**

My custom attributes pass to the provisioning recipe fine(solr_cluster_name), but I want to pass another attribute through to a recipe in the role run list(solr)

On provisioner node is chef-client -o "recipe[provision::solr_create]" -j ~/attr.json

attr.json looks like

{
    "solr_cluster_name": "solr-test",
    "solr_number_nodes": "1",
    "CORE_NAME": "20160229_A"
}

Thanks
Mark

Resolved - Didn’t realise you can pass attribute to the machine resource.

machine_batch do

1.upto(num_solrservers) do |i|

     machine "#{node['solr_cluster_name']}-node#{i}" do
     role 'solr_build'
     ohai_hints 'ec2' => '{}'
     attribute %w[solr CORE_NAME], "#{node['CORE_NAME']}"