MultiDataCenter handling in Chef environment without changing cookbooks resources

Hi Forum,

im very new to chef , please help me in following question
Im looking for a solution how to handle multi data center property in chef , let say if we have 4 data centers or n data centers , how can I incorporate dynamically without changing in cookbooks recipes or attributes like

node[dc_1]
when environment
do this

node [dc_2]
when environment
do this
else
do this

is there any better solution to handle this if we have so many properties

Regards,
Saran

I would take a look at Policy and Policy Groups

Using Policy Groups you can set specific attributes for that policy group

Hi @jasonf thank you for reply

I’m working only on cookbooks to update recipes and attributes . Only for Properties on servers nodes this case statement needs to be added but there are many . I don’t have control on policy . I don’t want to update any thing related to data center on cookbooks .

Where this policy group set either client side or server side where in chef server policy file resides ? Can educate me regarding this

Could you please refer me any pseudo code example

Regards
Saran

I would take a look at this course on learn chef, it will explain it better than I can, https://learn.chef.io/modules/managing-nodes-with-policyfiles/#/infrastructure-automation