
- Chef 教程
- Chef - 首頁
- Chef - 概述
- Chef - 架構
- Chef - 版本控制系統設定
- Chef - 工作站設定
- Chef - 客戶端設定
- Chef - 測試廚房設定
- Chef - Knife 設定
- Chef - Solo 設定
- Chef - Cookbook
- Chef - Cookbook 依賴關係
- Chef - 角色
- Chef - 環境
- Chef - Chef-Client 作為守護程序
- Chef - Chef-Shell
- Chef - 測試 Cookbook
- Chef - Foodcritic
- Chef - ChefSpec
- 使用測試廚房測試 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 管理這些元件有多種方式。Chef 支援處理檔案和軟體包也有多種方式。
從第三方倉庫安裝軟體包
步驟 1 - 編輯 Cookbook 的預設菜譜。
vipin@laptop:~/chef-repo $ subl cookbooks/test_cookbook/recipes/default.rb include_recipe "apt" apt_repository "s3tools" do uri "http://s3tools.org/repo/deb-all" components ["stable/"] key "http://s3tools.org/repo/deb-all/stable/s3tools.key" action :add end package "s3cmd"
步驟 2 - 編輯元資料以新增對 apt Cookbook 的依賴關係。
vipin@laptop:~/chef-repo $ subl cookbooks/my_cookbook/metadata.rb ... depends "apt"
步驟 3 - 將修改後的 Cookbook 上傳到 Chef 伺服器。
步驟 4 - 驗證您嘗試安裝的軟體包是否尚未安裝。
步驟 5 - 驗證預設倉庫。
步驟 6 - 在節點上執行 Chef-Client。
步驟 7 - 驗證所需的軟體包是否已安裝。
從原始碼安裝軟體
如果需要安裝某個平臺上沒有作為軟體包提供的軟體,則需要自行編譯。在 Chef 中,我們可以使用 script 資源來實現。
步驟 1 - 編輯預設菜譜。
vipin@laptop:~/chef-repo $ subl cookbooks/my_cookbook/recipes/ default.rb version = "1.3.9" bash "install_nginx_from_source" do cwd Chef::Config['file_cache_path'] code ≪-EOH wget http://nginx.org/download/nginx-#{version}.tar.gz tar zxf nginx-#{version}.tar.gz && cd nginx-#{version} && ./configure && make && make install EOH
步驟 2 - 將修改後的 Cookbook 上傳到 Chef 伺服器。
步驟 3 - 在節點上執行 Chef-Client。
步驟 4 - 驗證 nginx 是否已安裝。
廣告