rp346
rp346

Reputation: 7068

chef override_attributes doesn't work

I have following attribute in chef-repo/site-cookbooks/datadog/attributes/default.rb

default['datadog']['yumrepo'] = "http://yum.datadoghq.com/rpm"

I want to override this attributes for one node, so I added following in node file on chef server

"override_attributes": {
  "datadog": {
    "yumrepo": "http://yum.datadoghq.com/rpm/x86_64/"
  }
},

then ran chef-clent, but looks like override_attributes is not in effect for that node.

any idea whats wrong here ?

Upvotes: 2

Views: 300

Answers (1)

streetsoldier
streetsoldier

Reputation: 1319

You can override the attribute by adding the attribute attribute in any of the resources as follows:

<some resource> do
    attribute %w[datadog yumrepo], "http://yum.datadoghq.com/rpm/x86_64/"
    action :<some action>
end

If the node has an attribute, this will override it with the value you provide.

Upvotes: 1

Related Questions