title: Chef: How do I override default attributes in roles?
body: <p>I'm using the opscode <a href="https://github.com/opscode-cookbooks/nginx" rel="noreferrer">nginx cookbook</a> for configuring the nginx server on my nodes.
  The nginx cookbook has some default attributes I'd like to override in my role ("web_server").</p>
  
  <p>These are the attributes I'd like to override:</p>
  
  <pre><code>default['nginx']['version'] = "1.2.2" # in cookbooks/nginx/attributes/default.rb
  default['nginx']['source']['prefix'] = "/opt/nginx-#{node['nginx']['version']}" # in cookbooks/nginx/attributes/source.rb
  </code></pre>
  
  <p>In my roles/web_server.rb file I have something like this:</p>
  
  <pre><code>name "web_server"
  description "Setup a web server"
  run_list "role[base]", "recipe[nginx]"
  override_attributes 'nginx' =&gt; {
    'install_method' =&gt; "source",
    'version' =&gt; "1.2.3",
    'source' =&gt; { "prefix" =&gt; "/opt/nginx", "checksum" =&gt; nil }
  }
  </code></pre>
  
  <p>However, when running the chef-client the nginx recipe ignores my overrides and uses the default ones.</p>
  
  <p>What am I doing wrong here?</p>
  
  <p>Thanks!</p>