English 中文(简体)
Chef - Nodes
  • 时间:2024-09-17

Chef - Nodes


Previous Page Next Page  

Knife prefpght shows details about all the nodes which uses a certain cookbook before uploading it to Chef server.

Getting Started

In order to get started, we need to have knife-prefpght gem installed.

Step 1 − Define the path in the gem file.

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

Step 2 − Run bundler to install knife-prefpght gem.

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

Working Method

Run knife-prefpght on the given cookbook.

We can run the prefpght command to find out which nodes and roles have the given cookbook in their expanded run psts.

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

There are multiple ways for a cookbook to get executed on the node.

    You can assign the cookbook directly to a node by adding it to the node s run pst.

    You can add a cookbook to the role and add the role to the node s run pst.

    You can add the role to the run pst of another role and add that other role to the node s run pst.

    A cookbook can be a dependency of another used cookbook.

No matter how a cookbook ends up in a node s run pst, the knife prefpght command will catch it as Chef stores all expanded psts of roles and recipes in node attributes. The knife prefpght command issues a search for exactly those node attributes.

Advertisements