如何在Chef-repo和berkshelf cookbook中管理冗余

时间:2014-07-28 05:36:48

标签: chef redundancy cookbook berkshelf

我正在使用Chef进行自动化。我有一份厨师回购食谱,里面有定制食谱以及来自opscode网站的食谱。

由于很少有烹饪书依赖于其他烹饪书,我使用berks实用程序安装了这些依赖项。

现在我的问题是如何管理烹饪书及其冗余。

1 个答案:

答案 0 :(得分:1)

Here is the detailed answer, You can mention your wrapper cookbooks and its dependencies in same berksfile. Cookbook source in "Beksfile", can be from "Chef Supermarket", GIT source, and system local path. Consider cookbook "mysql_wrapper" is the cookbook developed by you and it uses "mysql" community cookbook. Also consider the wrapper is located in system local path. Here is sample berksfile content for above scenario. source "https://supermarket.chef.io" cookbook 'mysql' cookbook 'mysql_wrapper', path: '/system/local/path/to/wrapper-cookbooks/mysql_wrapper' How it works? When you run "berks install" or "berks upload", Berkshelf resolves the cookbooks mentioned in berksfile. Dependent community cookbook will be downloaded from "Supermarket", because we referenced it in first line. While the wrapper cookbook will be referenced by local path. Setting up a project for managing cookbooks, roles and data_bags Create a project repository with your cookbooks and other stuff. Project repo is nothing but, a directory contains other directories for 1. Roles, 2. Databags, 3. Cookbooks and 4. Environments. According to your requirement create repository. Place your cookbooks inside cookbooks directory. Create a directory as "roles". Add roles as ".json" files. In case of data_bag/data_bag_item, create a directory as data_bags. Create a directory for each data_bag and add items as ".json" files. Create the bersfile inside the repo Manage Chef server In case, if you want to upload the content, follow the steps below, Create a directory ".chef" inside the project repo Copy your Chef server knife/pem files into .chef Run the command "berks upload" from inside the project repo. Your cookbooks will be uploaded to Chef server. Run knife upload data_bags and knife upload roles, to upload your databags and roles from the repo.