
- Chef 教程
- Chef - 首頁
- Chef - 概述
- Chef - 架構
- Chef - 版本控制系統設定
- Chef - 工作站設定
- Chef - 客戶端設定
- Chef - Test Kitchen 設定
- Chef - Knife 設定
- 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 - 環境
Chef 有助於執行特定於環境的配置。最好為開發、測試和生產分別設定獨立的環境。
Chef 支援將節點分組到不同的環境中,以支援有序的開發流程。
建立環境
可以使用 knife 實用程式動態建立環境。以下命令將開啟 Shell 的預設編輯器,以便修改環境定義。
vipin@laptop:~/chef-repo $ knife environment create book { "name": "book", "description": "", "cookbook_versions": { }, "json_class": "Chef::Environment", "chef_type": "environment", "default_attributes": { }, "override_attributes": { } } Created book
測試已建立的環境
vipin@laptop:~/chef-repo $ knife environment list _default book
列出所有環境的節點
vipin@laptop:~/chef-repo $ knife node list my_server
_default 環境
每個組織都至少從一個名為 default 的環境開始,該環境始終可用於 Chef 伺服器。預設環境無法以任何方式修改。任何更改只能在建立的自定義環境中進行。
環境屬性
可以在環境中定義屬性,然後用於覆蓋節點中的預設設定。當 Chef 客戶端執行時,這些屬性將與節點中已存在的預設屬性進行比較。當環境屬性優先於預設屬性時,Chef 客戶端將在每個節點上執行 Chef 客戶端時應用這些設定和值。
環境屬性只能是 default_attribute 或 override_attribute。它不能是普通屬性。可以使用 default_attribute 或 override_attribute 方法。
屬性型別
預設 - 預設屬性在每次 Chef 客戶端執行開始時始終重置,並且具有最低的屬性優先順序。
覆蓋 - 覆蓋屬性在每次 Chef 客戶端執行開始時始終重置,並且比預設、force_default 和普通屬性具有更高的屬性優先順序。覆蓋屬性最常在菜譜中定義,但也可以在角色或環境的屬性檔案中指定。
應用屬性的順序

廣告