Chef - 节点



Knife preflight 显示了在将 Cookbook 上传到 Chef 服务器之前使用特定 Cookbook 的所有节点的详细信息。

入门

要开始,我们需要安装 knife-preflight gem。

步骤 1 - 在 gem 文件中定义路径。

vipin@laptop:~/chef-repo $ subl Gemfile 
source 'https://rubygems.org.cn' 
gem 'knife-preflight' 

步骤 2 - 运行 bundler 以安装 knife-preflight gem。

vipin@laptop:~/chef-repo $ bundle install 
Fetching gem metadata from https://rubygems.org.cn/ 
...TRUNCATED OUTPUT... 
Installing knife-preflight (0.1.6)

工作方法

在给定的 Cookbook 上运行 knife-preflight。

我们可以运行 preflight 命令来找出哪些节点和角色在其扩展运行列表中具有给定的 Cookbook。

vipin@laptop:~/chef-repo $ knife preflight ntp 
Searching for nodes containing ntp OR ntp::default in their 
expanded run_list... 
2 Nodes found 
www-staging.example.com 
cms-staging.example.com 
Searching for roles containing ntp OR ntp::default in their 
expanded run_list... 
3 Roles found 
your_cms_role 
your_www_role 
your_app_role 
Found 6 nodes and 3 roles using the specified search 
criteria 

Cookbook 有多种方法可以在节点上执行。

  • 您可以通过将其添加到节点的运行列表来直接将 Cookbook 分配给节点。

  • 您可以将 Cookbook 添加到角色,并将角色添加到节点的运行列表。

  • 您可以将角色添加到另一个角色的运行列表,并将另一个角色添加到节点的运行列表。

  • Cookbook 可以是另一个已用 Cookbook 的依赖项。

无论 Cookbook 如何最终出现在节点的运行列表中,knife preflight 命令都会捕获它,因为 Chef 将角色和菜谱的所有扩展列表存储在节点属性中。knife preflight 命令会精确搜索这些节点属性。

广告
© . All rights reserved.