这个厨师属性来自哪里,为什么我不能改变它?

当我更改angular色时,厨师节点的属性没有更新,旧值持续存在。

node['nagios']['custom_variables']['styleurl']属性没有更新到/urlprefix的新值, /urlprefix卡在旧值urlprefix 。 我一个多星期前就改变了angular色定义。

另一个与chef-client(这是看这个属性的nagios服务器)的节点:

 # chef-shell -z chef > nodes.show("server2.example.com")['nagios']['custom_variables']['styleurl'] => "urlprefix" 

节点和angular色定义(下面)不包括这个值,只包含/urlprefix

debug_value告诉我这是来自一个覆盖。

 chef > nodes.show("server2.example.com").debug_value("nagios", "custom_variables", "styleurl") => [["set_unless_enabled?", false], ["default", :not_present], ["env_default", :not_present], ["role_default", :not_present], ["force_default", :not_present], ["normal", :not_present], ["override", "osm"], ["role_override", :not_present], ["env_override", :not_present], ["force_override", :not_present], ["automatic", :not_present]] 

knife node show -l显示我有一个override该variables。 (见下面的输出)。

我使用这些属性来configuration我的nagios检查。 Nagiosconfiguration了厨师,显然我的nagios检查失败了。

我怎么能改变angular色的属性? 为什么override_attribute这个angular色不是, 重写属性呢? 我怎样才能改变这个属性?

节点configuration

简单的节点,一切都在angular色中完成。

 $ knife node show -Fjson server2.example.com { "name": "server2.example.com", "chef_environment": "_default", "run_list": [ "role[server2]" ], "normal": { "tags": [] } } 

angular色

只有server2.example.com具有server2angular色。 一切都在angular色中完成。 这是styleurl设置的唯一的地方。

 $ knife role show -Fjson server2 { "name": "server2", "description": "", "json_class": "Chef::Role", "default_attributes": { }, "override_attributes": { "nagios": { "custom_variables": { "styleurl": "/urlprefix" } } }, "chef_type": "role", "run_list": [ "role[ubuntu-precise-basic]", "recipe[firewall::http]", "recipe[firewall::https]" ], "env_run_lists": { } } 

食谱属性

custom_variables::styleurl没有在食谱的任何地方定义过:

 $ grep -R "custom_variables" cookbooks/ cookbooks/nagios/templates/default/hosts.cfg.erb: <% if node['nagios'] && node['nagios']['custom_variables'] %> cookbooks/nagios/templates/default/hosts.cfg.erb: <% node['nagios']['custom_variables'].each do |key, value| -%> cookbooks/nagios/templates/default/hosts.cfg.erb: <% if n['nagios'] && n['nagios']['custom_variables'] %> cookbooks/nagios/templates/default/hosts.cfg.erb: <% n['nagios']['custom_variables'].each do |key, value| -%> cookbooks/nagios/templates/default/hosts.cfg.erb: <% if n['nagios'] && n['nagios']['custom_variables'] %> cookbooks/nagios/templates/default/hosts.cfg.erb: <% n['nagios']['custom_variables'].each do |key, value| -%> $ 

knife node show

(部分编辑/编辑)

 $ knife node show -Fjson -l server2.example.com { "name": "server2.example.com", "chef_environment": "_default", "run_list": [ "role[server2]" ], "normal": { "tags": [ ] }, "override": { "nagios": { "custom_variables": { "styleurl": "osm" } } }, ... "recipes": [ "accounts", "packages::precise", "firewall::ssh", "firewall::munin", "firewall::nrpe", "munin::client", "munin-checks", "nrpe", "nagios-checks", "fail2ban", "openssh", "mycompany::apache_logrotate", "firewall::http", "firewall::https" ], "roles": [ "server2", "ubuntu-precise-basic", "mycompany-accounts" ] } } 

厨师v11.8

发布这个问题后,我试图直接在server2.example.com节点上运行chef-client 。 现在刀和另一个节点可以看到正确的节点属性,问题是固定的。

因此,“在受影响的节点上运行chef-client ”修复了这个问题。

为了进一步解释一下:节点对象包含两种数据。 像运行列表和厨师环境的“所需状态”通常由人类更新,以便他们总是查看最新的。 “当前状态”(主要是节点属性的forms)只有在成功汇集结束时才保存在Chef Server上,以logging当时机器的状态。