
- Chef 教程
- Chef - 首頁
- Chef - 概述
- Chef - 架構
- Chef - 版本控制系統設定
- Chef - 工作站設定
- Chef - 客戶端設定
- Chef - Test Kitchen 設定
- Chef - 刀具設定
- Chef - Solo 設定
- Chef - Cookbook
- Chef - Cookbook 依賴
- Chef - 角色
- Chef - 環境
- Chef - Chef-Client 作為守護程序
- Chef - Chef-Shell
- Chef - 測試 Cookbook
- Chef - Foodcritic
- Chef - ChefSpec
- 使用 Test Kitchen 測試 Cookbook
- Chef - 節點
- Chef - Chef-Client 執行
- 高階 Chef
- 動態配置菜譜
- Chef - 模板
- Chef - 使用 Chef DSL 的純 Ruby
- Chef - 使用菜譜的 Ruby Gems
- Chef - 庫
- Chef - 定義
- Chef - 環境變數
- Chef - 資料包
- Chef - 資料包指令碼
- Chef - 跨平臺 Cookbook
- Chef - 資源
- 輕量級資源提供程式
- Chef - 藍圖
- Chef - 檔案和包
- Chef - 社群 Cookbook
- Chef 有用資源
- Chef - 快速指南
- Chef - 有用資源
- Chef - 討論
Chef - 刀具設定
Knife 是 Chef 的命令列工具,用於與 Chef 伺服器互動。它用於上傳 Cookbook 和管理 Chef 的其他方面。它在本地機器上的 chefDK(Repo)和 Chef 伺服器之間提供了一個介面。它有助於管理:
- Chef 節點
- Cookbook
- 菜譜
- 環境
- 雲資源
- 雲配置
- 在 Chef 節點上安裝 Chef 客戶端
Knife 提供了一組命令來管理 Chef 基礎設施。
引導命令
- knife bootstrap [SSH_USER@]FQDN (options)
客戶端命令
- knife client bulk delete REGEX (options)
- knife client create CLIENTNAME (options)
- knife client delete CLIENT (options)
- knife client edit CLIENT (options)
- 用法:C:/opscode/chef/bin/knife (options)
- knife client key delete CLIENT KEYNAME (options)
- knife client key edit CLIENT KEYNAME (options)
- knife client key list CLIENT (options)
- knife client key show CLIENT KEYNAME (options)
- knife client list (options)
- knife client reregister CLIENT (options)
- knife client show CLIENT (options)
配置命令
- knife configure (options)
- knife configure client DIRECTORY
Cookbook 命令
- knife cookbook bulk delete REGEX (options)
- knife cookbook create COOKBOOK (options)
- knife cookbook delete COOKBOOK VERSION (options)
- knife cookbook download COOKBOOK [VERSION] (options)
- knife cookbook list (options)
- knife cookbook metadata COOKBOOK (options)
- knife cookbook metadata from FILE (options)
- knife cookbook show COOKBOOK [VERSION] [PART] [FILENAME] (options)
- knife cookbook test [COOKBOOKS...] (options)
- knife cookbook upload [COOKBOOKS...] (options)
Cookbook 站點命令
- knife cookbook site download COOKBOOK [VERSION] (options)
- knife cookbook site install COOKBOOK [VERSION] (options)
- knife cookbook site list (options)
- knife cookbook site search QUERY (options)
- knife cookbook site share COOKBOOK [CATEGORY] (options)
- knife cookbook site show COOKBOOK [VERSION] (options)
- knife cookbook site unshare COOKBOOK
資料包命令
- knife data bag create BAG [ITEM] (options)
- knife data bag delete BAG [ITEM] (options)
- knife data bag edit BAG ITEM (options)
- knife data bag from file BAG FILE|FOLDER [FILE|FOLDER..] (options)
- knife data bag list (options)
- knife data bag show BAG [ITEM] (options)
環境命令
- knife environment compare [ENVIRONMENT..] (options)
- knife environment create ENVIRONMENT (options)
- knife environment delete ENVIRONMENT (options)
- knife environment edit ENVIRONMENT (options)
- knife environment from file FILE [FILE..] (options)
- knife environment list (options)
- knife environment show ENVIRONMENT (options)
執行命令
- knife exec [SCRIPT] (options)
幫助命令
- knife help [list|TOPIC]
索引命令
- knife index rebuild (options)
節點命令
- knife node bulk delete REGEX (options)
- knife node create NODE (options)
- knife node delete NODE (options)
- knife node edit NODE (options)
- knife node environment set NODE ENVIRONMENT
- knife node from file FILE (options)
- knife node list (options)
- knife node run_list add [NODE] [ENTRY[,ENTRY]] (options)
- knife node run_list remove [NODE] [ENTRY[,ENTRY]] (options)
- knife node run_list set NODE ENTRIES (options)
- knife node show NODE (options)
OSC 命令
- knife osc_user create USER (options)
- knife osc_user delete USER (options)
- knife osc_user edit USER (options)
- knife osc_user list (options)
- knife osc_user reregister USER (options)
- knife osc_user show USER (options)
基於路徑的命令
- knife delete [PATTERN1 ... PATTERNn]
- knife deps PATTERN1 [PATTERNn]
- knife diff PATTERNS
- knife download PATTERNS
- knife edit [PATTERN1 ... PATTERNn]
- knife list [-dfR1p] [PATTERN1 ... PATTERNn]
- knife show [PATTERN1 ... PATTERNn]
- knife upload PATTERNS
- knife xargs [COMMAND]
原始命令
- knife raw REQUEST_PATH
菜譜命令
- knife recipe list [PATTERN]
角色命令
- knife role bulk delete REGEX (options)
- knife role create ROLE (options)
- knife role delete ROLE (options)
- knife role edit ROLE (options)
- knife role env_run_list add [ROLE] [ENVIRONMENT] [ENTRY[,ENTRY]] (options)
- knife role env_run_list clear [ROLE] [ENVIRONMENT]
- knife role env_run_list remove [ROLE] [ENVIRONMENT] [ENTRIES]
- knife role env_run_list replace [ROLE] [ENVIRONMENT] [OLD_ENTRY] [NEW_ENTRY]
- knife role env_run_list set [ROLE] [ENVIRONMENT] [ENTRIES]
- knife role from file FILE [FILE..] (options)
- knife role list (options)
- knife role run_list add [ROLE] [ENTRY[,ENTRY]] (options)
- knife role run_list clear [ROLE]
- knife role run_list remove [ROLE] [ENTRY]
- knife role run_list replace [ROLE] [OLD_ENTRY] [NEW_ENTRY]
- knife role run_list set [ROLE] [ENTRIES]
- knife role show ROLE (options)
服務命令
- knife serve (options)
SSH 命令
- knife ssh QUERY COMMAND (options)
SSL 命令
- knife ssl check [URL] (options)
- knife ssl fetch [URL] (options)
狀態命令
- knife status QUERY (options)
標籤命令
- knife tag create NODE TAG ...
- knife tag delete NODE TAG ...
- knife tag list NODE
使用者命令
- knife user create USERNAME DISPLAY_NAME FIRST_NAME LAST_NAME EMAIL PASSWORD (options)
- knife user delete USER (options)
- knife user edit USER (options)
- knife user key create USER (options)
- knife user key delete USER KEYNAME (options)
- knife user key edit USER KEYNAME (options)
- knife user key list USER (options)
- knife user key show USER KEYNAME (options)
- knife user list (options)
- knife user reregister USER (options)
- knife user show USER (options)
Knife 設定
為了設定 knife,需要移動到.chef目錄並在 chef repo 內建立一個knife.rb檔案,該檔案告訴 knife 配置細節。這將包含一些詳細資訊。
current_dir = File.dirname(__FILE__) log_level :info log_location STDOUT node_name 'node_name' client_key "#{current_dir}/USER.pem" validation_client_name 'ORG_NAME-validator' validation_key "#{current_dir}/ORGANIZATION-validator.pem" chef_server_url 'https://api.chef.io/organizations/ORG_NAME' cache_type 'BasicFile' cache_options( :path => "#{ENV['HOME']}/.chef/checksums" ) cookbook_path ["#{current_dir}/../cookbooks"]
在上面的程式碼中,我們使用了使用以下兩個金鑰的託管 Chef 伺服器。
validation_client_name 'ORG_NAME-validator' validation_key "#{current_dir}/ORGANIZATION-validator.pem"
這裡,knife.rb 告訴 knife 使用哪個組織以及在哪裡找到私鑰。它告訴 knife 在哪裡找到使用者的私鑰。
client_key "#{current_dir}/USER.pem"
下面的程式碼行告訴 knife 我們正在使用託管伺服器。
chef_server_url 'https://api.chef.io/organizations/ORG_NAME'
使用 knife.rb 檔案,驗證器 knife 現在可以連線到您的組織的託管 Opscode。
廣告