0

I'm new to Chef and AWS and I'm learning how to deploy a cluster, throw Chef, to AWS Ec2. For that I'm using chef-provisioning-aws.

I'm executing chef-client from my workstation directly to AWS, I don't have a chef-server (use chef-zero). This is how I execute:

chef-client -z -r "role[example_cluster]"

Yes, I've a role for the cluster and in the run_list I have "recipe[example::aws_setup]", "recipe[example::create_cluster]"

On the example::create_cluster recipe I use machine_batch to create the machines and call the following recipes:

recipe 'example::recipe_1' recipe 'example::recipe_2'

I also have some attributes defined and I override some of them on the Role file, but when I execute chef-client, the attributes on example::aws_setup and example::create_cluster are the ones I override on the Role file, but the ones used in example::recipe_1 and example::recipe_2 are the default ones.

Does someone have a guide or can help me with this?

Thanks in advance.

BAndrade
  • 107
  • 1
  • 8

2 Answers2

1

I think I answered you on IRC last night but just in case:

There is no relationship between the node data of the server (or in this case workstation) running the provisioning process and the newly created nodes in EC2. If you want to apply roles or other things to them, you need to do that in your provisioning recipe when you create the machines.

coderanger
  • 52,400
  • 4
  • 52
  • 75
  • Yes coderanger, you answered in IRC, I forgot to close this. Once more, Thanks again. – BAndrade Jan 06 '16 at 18:46
  • Just to give an update. I solved my problem by creating a recipe that generate the role file that is going to be used on the new instances on ec2. Basically, I define all the attributes I want on the cluster role file and then execute it and everything is working great :) – BAndrade Jan 07 '16 at 01:31
1

Chef attributes has the "Precedence" order. Please refer the answer related Chef attribute Precedence, it will help to understand, which attribute value will be considered when we run the cookbook.

You need to call the proper attribute method, while overriding the attribute value.

Community
  • 1
  • 1
Saravanan G
  • 581
  • 1
  • 9
  • 26