[chef] How to change the name of an attribute with an attribute?


Chronological Thread 
  • From: "Van Fossan,Randy" < >
  • To: < >
  • Subject: [chef] How to change the name of an attribute with an attribute?
  • Date: Thu, 2 Feb 2012 16:08:11 -0500

Does anyone know how to change the “name of an attribute” with an attribute?  I know that sounds silly, but I want to subscribe to a set of repos based on the platform version and the environment that the server is in.

 

The attributes from the /attributes folder are:

default[:repo][:my_centos][:updates_prd_5x] = “http://repo_centos5_prod.....

default[:repo][:my_centos][:updates_prd_6x] = “http://repo_centos6_prod.....

 

default[:repo][:my_centos][:updates_dev_5x] = “http://repo_centos5_dev.....

default[:repo][:my_centos][:updates_prd_6x] = “http://repo_centos6_dev.....

 

 

In a recipe, I have tried variations of the following:

 

If server is prod….

Update_Repo = node[:repo][:my_centos][:updates_prd_{node[:platform_version].to_i}x]

 

if server is dev….

Update_Repo = node[:repo][:my_centos][:updates_dev_{node[:platform_version].to_i}x]

 

I cannot get the syntax down correctly.  Although, I suspect it may be more of how chef is handling the attributesd in the Compile Resource Collection phase of a chef run..

 

I have different repos for each of my environments (dev, test, prod, QA, stage1, personal) and different versions of centos for each of these.   Each points to a specific internal url.

 

Anyone have any ideas?




Archive powered by MHonArc 2.6.16.

§