简体   繁体   English

如何启用 Ohai 插件生成 ['etc']['passwd']?

[英]How to enable Ohai Plugin to produce ['etc']['passwd']?

I have upgraded my Chef Client from 14.0 to 15.3.14 but issue rose whenever I execute chef-client on my node(macOS Mojave).我已将我的 Chef Client 从14.0升级到15.3.14但是每当我在我的节点(macOS Mojave)上执行 Chef-client 时问题就会增加。
The client output is:客户端输出是:

-------------
undefined method `[]' for nil:NilClass

Cookbook Trace:
---------------
  /var/chef/cache/cookbooks/macos/recipes/mac_init.rb:62:in `from_file'

Relevant File Content:
----------------------
/var/chef/cache/cookbooks/macos/recipes/mac_init.rb:

 55:    action :create
 56:    owner 'administrator'
 57:    group 'localaccounts'
 58:    mode  '0775'
 59:  end
 60:
 61:  # Template for bash history
 62>>   node['etc']['passwd'].each do |user, data|
 63:
 64:    template "/Users/#{user}/.bash_profile" do
 65:      source '/default/bash_profile.erb'
 66:      owner 'administrator'
 67:      group 'staff'
 68:      ignore_failure true
 69:    end
 70:  end

It seems that node['etc']['passwd'] is no longer readable which result to have a value of nil .似乎node['etc']['passwd']不再可读,导致值为nil
I've checked another machine that was newly bootstrapped and verify it on Chef Server UI but the result is, there was no 'etc' in the attributes tab.我检查了另一台新启动的机器并在 Chef Server UI 上对其进行了验证,但结果是,属性选项卡中没有“等”。

reading the release notes of ohai it says:阅读ohai发行说明,它说:

Optional Ohai Plugins可选的 Ohai 插件

Ohai now includes the ability to mark plugins as optional, which skips those plugins by default. Ohai 现在包括将插件标记为可选的功能,默认情况下会跳过这些插件。 This allows us to ship additional plugins, which some users may find useful, but not all users would want being written to their Chef server.这允许我们发布额外的插件,一些用户可能会发现这些插件很有用,但并非所有用户都希望被写入他们的 Chef 服务器。 The change introduces two new configuration options;这一变化引入了两个新的配置选项; run_all_plugins which runs everything including optional plugins, and optional_plugins which allows you to run plugins marked as optional. run_all_plugins运行包括可选插件在内的所有内容,而optional_plugins允许您运行标记为可选的插件。

By default we will now be marking the lspci , sessions and passwd plugins as optional.默认情况下,我们现在将lspcisessionspasswd插件标记为可选。 Passwd has been particularly problematic for nodes attached LDAP or AD where it attempts to write the entire directory to the node. Passwd 对于连接 LDAP 或 AD 的节点来说尤其成问题,因为它试图将整个目录写入节点。 If you previously disabled this plugin via Ohai config, you no longer need to.如果您之前通过 Ohai 配置禁用了此插件,则不再需要。 Hurray!欢呼!

but you can always enable back the optional plugins :但您始终可以启用可选插件

Enabling Optional Plugins启用可选插件

Optional plugins can be enabled in the client.rb configuration file: ohai.optional_plugins = [ :Sessions, :Lspci ]可以在client.rb配置文件中启用可选插件: ohai.optional_plugins = [ :Sessions, :Lspci ]

in your specific case:在您的具体情况下:

ohai.optional_plugins = [
  :Passwd
]

assuming you installed ohai using bundler, then you can check that the passwd is there by executing假设您使用 bundler 安装了 ohai,那么您可以通过执行来检查passwd是否存在

$ bundle exec ohai etc

configuration配置

to have such behavor constantly, then:不断地有这样的行为,那么:

UPDATE: support for this has been introduced into chef-client cookbook:更新:对此的支持已被引入到厨师客户端食谱中:

  • node['ohai']['disabled_plugins'] - An array of ohai plugins to disable, empty by default, and must be an array if specified. node['ohai']['disabled_plugins'] - 要禁用的 ohai 插件数组,默认为空,如果指定,则必须是数组。 Ohai 6 plugins should be specified as a string (ie. "dmi"). Ohai 6 插件应指定为字符串(即“dmi”)。 Ohai 7+ plugins should be specified as a symbol within quotation marks (ie. ":Passwd"). Ohai 7+ 插件应指定为引号内的符号(即“:Passwd”)。
  • node['ohai']['optional_plugins'] - An array of optional ohai plugins to enable, empty by default, and must be an array if specified. node['ohai']['optional_plugins'] - 要启用的可选 ohai 插件数组,默认为空,如果指定则必须是数组。 Ohai 6 plugins should be specified as a string (ie. "dmi"). Ohai 6 插件应指定为字符串(即“dmi”)。 Ohai 7+ plugins should be specified as a symbol within quotation marks (ie. ":Passwd"). Ohai 7+ 插件应指定为引号内的符号(即“:Passwd”)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM