Creating attributes that are tied to Environment and Roles


#1

Hey All,

I am trying to figure out a solution to a problem I got and I think its not unique but I can seem to find a clear answer on this in the wiki. So I have a cookbook that will add your current server to a ELB pool but for it to work you must pass it an attributes with the ELB name which we set as a role attribute. This would be fine but the problem is I need the name to change based on the chef environment we are using to deploy. Now I can set a environment attribute but I have different ELB’s and they need to be added based on their roles. How can I create something that is tied to both the environment and role.

Thanks
Zuhaib


#2

You can set attributes directly in environments as well as roles
starting in 0.10.0.

http://wiki.opscode.com/display/chef/Attributes#Attributes-EnvironmentAttributes

Just use the normal override_attribute syntax and you should be good to go.

-s

On Wed, Dec 21, 2011 at 9:04 PM, Zuhaib Siddique
zuhaib.siddique@leapfile.com wrote:

Hey All,

I am trying to figure out a solution to a problem I got and I think its not unique but I can seem to find a clear answer on this in the wiki. So I have a cookbook that will add your current server to a ELB pool but for it to work you must pass it an attributes with the ELB name which we set as a role attribute. This would be fine but the problem is I need the name to change based on the chef environment we are using to deploy. Now I can set a environment attribute but I have different ELB’s and they need to be added based on their roles. How can I create something that is tied to both the environment and role.

Thanks
Zuhaib


#3

S,

Yeah I was looking at that but it has a few problems, its an environment settings so it applies to all attributes. So example I have a role named Server1 that needs to be added to ELB1 and then I have Server2 that needs to be added to ELB2. I cant do that if the attribute for the env is AWS:ELB:NAME: ELB1.

Zuhaib
On Dec 21, 2011, at 9:38 PM, Sean OMeara wrote:

You can set attributes directly in environments as well as roles
starting in 0.10.0.

http://wiki.opscode.com/display/chef/Attributes#Attributes-EnvironmentAttributes

Just use the normal override_attribute syntax and you should be good to go.

-s

On Wed, Dec 21, 2011 at 9:04 PM, Zuhaib Siddique
zuhaib.siddique@leapfile.com wrote:

Hey All,

I am trying to figure out a solution to a problem I got and I think its not unique but I can seem to find a clear answer on this in the wiki. So I have a cookbook that will add your current server to a ELB pool but for it to work you must pass it an attributes with the ELB name which we set as a role attribute. This would be fine but the problem is I need the name to change based on the chef environment we are using to deploy. Now I can set a environment attribute but I have different ELB’s and they need to be added based on their roles. How can I create something that is tied to both the environment and role.

Thanks
Zuhaib