Apply a role's attributes by name?


#1

Is there any way to apply any role’s attributes during a chef run? The
reason I need to do this is because I am adding a role to the run_list
during a chef run and I’d like that role’s attributes to take effect
during the current chef run. I know this is not idempotent and I
shouldn’t be doing things this way, but let’s not get into that
discussion today. :slight_smile:

This is what I’m hoping I can do:

node[‘run_list’] << "role[roleA]"
role.apply(“roleA”) # now the attributes in roleA will be available
for the rest of the chef run.

Thanks in advance.
John


#2

On Thursday, August 2, 2012 at 3:03 PM, John Alberts wrote:

Is there any way to apply any role’s attributes during a chef run? The
reason I need to do this is because I am adding a role to the run_list
during a chef run and I’d like that role’s attributes to take effect
during the current chef run. I know this is not idempotent and I
shouldn’t be doing things this way, but let’s not get into that
discussion today. :slight_smile:

This is what I’m hoping I can do:

node[‘run_list’] << "role[roleA]"
role.apply(“roleA”) # now the attributes in roleA will be available
for the rest of the chef run.

Thanks in advance.
John

I think node.expand! after adding the role should do the trick.


Dan DeLeo


#3

Thanks, but unfortunately, that doesn’t seem to work. I don’t get any
kind of error, but the remaining chef code doesn’t seem to pick up the
new attributes in the new role that was added. Any other ideas? :slight_smile:

John

On Thu, Aug 2, 2012 at 5:12 PM, Daniel DeLeo dan@kallistec.com wrote:

On Thursday, August 2, 2012 at 3:03 PM, John Alberts wrote:

Is there any way to apply any role’s attributes during a chef run? The
reason I need to do this is because I am adding a role to the run_list
during a chef run and I’d like that role’s attributes to take effect
during the current chef run. I know this is not idempotent and I
shouldn’t be doing things this way, but let’s not get into that
discussion today. :slight_smile:

This is what I’m hoping I can do:

node[‘run_list’] << "role[roleA]"
role.apply(“roleA”) # now the attributes in roleA will be available
for the rest of the chef run.

Thanks in advance.
John

I think node.expand! after adding the role should do the trick.


Dan DeLeo


John Alberts