需要澄清有关 Chef 中节点和角色的管理

need clarification regarding the management of nodes, roles within Chef

我已经阅读了很多关于厨师的文档,从它的食谱到角色以及它的刀具的使用。我对 运行 食谱感到满意,并将它们与使用角色的节点相关联。我不满意的方面是 UI 和节点、角色等的内部管理。请注意,我来自 Ansible,其中每个配置都可以在 git 等回购中进行版本控制例如。

由于我对Chef's不熟悉UI,我会尽量简单地回答你的第二个问题

您有两个选择:

  1. 如果您想坚持角色,可以关注Policyfile model/pattern。
  2. 你可以放弃角色。您可以切换到包装器食谱模式,将食谱视为角色。例如,您可以创建元(包装器)食谱 web_server 而不是 web_server 角色,您只需在其中包含其他食谱或设置属性。您可以像任何其他食谱一样对包装器食谱进行版本控制。对于节点,您只分配包装器说明书,或者每个节点类型只有一个包装器说明书。

让我试着澄清一下...

  • how do keep track of changes in nodes, etc. in the UI - is there an audit tool to allow us to see what was changed over time? I searched online for a demo but found little info.

有很多方法可以收敛一个节点(运行宁你的食谱),一旦收敛完成,节点属性就会被存储。它们的存储位置取决于您如何收敛节点:

  • server\client架构:节点属性将存储在Chef服务器上
  • zero\local-mode架构:节点属性将存储在本地json文件中

如果您配置了 knife correctly (see client.rb), you'd be able to use knife to retrieve the node attribute. for instance:

$ knife search "name:node.example.com" --long
  • Is it possible to sync-up chef server and a say git repository, so changes in the node, roles etc. definition can be at least seen in there? In ansible I could maintain my expectations in a configuration file and have the tool import it. Is there any way to do sth similar? I read about "infrastructure as code" but isn't it defeating the purpose here that this code cannot easily be version-controlled?

当然可以。只需将所有食谱置于源代码控制管理之下。 如果您使用 server\client 架构,那么一旦您完成了您的 cookbook 开发和测试,upload your cookbooks to chef-server 然后 运行 chef-client 在感兴趣的节点上。