gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 01:36:11 29 4
gpt4 key购买 nike

我已经从 14.0 升级了我的 Chef Client至 15.3.14但是每当我在我的节点(macOS Mojave)上执行厨师客户端时,问题就会增加。
客户端输出是:

-------------
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

看来 node['etc']['passwd']不再可读,结果为 nil .
我检查了另一台新启动的机器并在 Chef Server UI 上对其进行了验证,但结果是,属性选项卡中没有“等”。

最佳答案

阅读 release notes of ohai它说:

Optional Ohai Plugins

Ohai now includes the ability to mark plugins as optional, which skips those plugins by default. 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. 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.

By default we will now be marking the lspci, sessions and passwd plugins as optional. Passwd has been particularly problematic for nodes attached LDAP or AD where it attempts to write the entire directory to the node. If you previously disabled this plugin via Ohai config, you no longer need to. Hurray!



但你总是可以 enable back the optional plugins :

Enabling Optional Plugins

Optional plugins can be enabled in the client.rb configuration file: ohai.optional_plugins = [
:Sessions,
:Lspci
]



在您的具体情况下:

ohai.optional_plugins = [
:Passwd
]

假设您使用 bundler 安装了 ohai,那么您可以检查 passwd是否通过执行
$ bundle exec ohai etc

配置

不断地有这样的行为,那么:
  • 如果 chef-zero在调用 chef-client 时使用, client.rb 可以使用,可以存储在存储库中。
  • 使用 ohai resource .就像是:

    ohai 'reload_passwd' do
    action :reload
    plugin 'etc'
    end
  • 投稿 chef-client cookbook , 免费支持 node['ohai']['disabled_plugins']

  • 更新:
    对此的支持已被引入到厨师客户端食谱中:

    • node['ohai']['disabled_plugins'] - An array of ohai plugins to disable, empty by default, and must be an array if specified. Ohai 6 plugins should be specified as a string (ie. "dmi"). Ohai 7+ plugins should be specified as a symbol within quotation marks (ie. ":Passwd").
    • node['ohai']['optional_plugins'] - An array of optional ohai plugins to enable, empty by default, and must be an array if specified. Ohai 6 plugins should be specified as a string (ie. "dmi"). Ohai 7+ plugins should be specified as a symbol within quotation marks (ie. ":Passwd").

    关于chef-infra - 如何启用 Ohai 插件生成 ['etc' ] ['passwd' ]?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57952305/

    29 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com