Managing Chef Cookbooks the Berkshelf way

转载:http://cloudacademy.com/blog/berkshelf-manage-chef-cookbooks/

Managing Chef Cookbooks the Berkshelf way

July 6, 2015 by Nitheesh Poojary


Chef cookbooks can become hard to handle; let’s talk about Berkshelf management tool

Chef is a configuration management tool written in Ruby. With Chef, you can build servers quickly and reliably using cookbooks (which are basically recipes, that can perform tasks like installing webservers, updating SSL’s, or configuring HA proxy servers). Cookbooks themselves can be managed through a tool called Berkshelf. If you noticed our title on your way in, you’ll know that Berkshelf is going to be the subject of this post.

Until now, you might have been managing your servers with growing numbers of scripts, perhaps spread across multiple directories or even multiple machines. As the need to deliver products to market quickly and the sheer numbers of servers we’ll use to do that continue to grow, we need a consistent, reliable, and secure way to manage it all. More importantly: the solution we choose should be simple and intuitive.

More often than not, Chef will fit those needs. It is an infrastructure automation framework that simplifies server and application deployments to any physical, virtual, or cloud location, no matter the size of the infrastructure.

Since your infrastructure will be managed with code, it can be automated, tested, and reproduced with ease. Chef itself is built from many moving parts, including knife, Chef client, Chef server, cookbooks, and nodes. Here, we will talk about cookbooks and how they can be efficiently managed using Berkshelf.

Just what is Berkshelf?

You often won’t need to actually write your cookbooks from scratch, as the community has all kinds of them – often ready to use in your environment without modification – available from the Opscode supermarket. To use a cookbook, you’ll need to download it and save it on your Chef workstation. To download each external cookbook from inside Global cookbook, this is what you would have to run:

1

knife cookbook site download apache2

Chef Repo: before Berkshelf

As terrific as Chef is, Berkshelf can really make a difference in the way you manage your Chef cookbooks and dependencies. Berkshelf lets you treat your cookbooks the way you treat gems in a Ruby project. When external cookbooks are used, Berkshelf doesn’t require “knife cookbook site” to install community cookbooks. All we have to do is mention the dependent cookbooks with its version number. When Chef client runs on nodes, berkshelf will automatically download and install all the dependent cookbooks from the Opscode cookbook community for us.

Chef repo: after Berkshelf

Implementing Berkshelf

Berkshelf requires a bit of set up. The easy way to install Berkshelf is:

1

gem install berkshelf

But that’s it. Berkshelf is now included as part of the Chef Development Kit (ChefDK), which installs the best development tools built by the awesome Chef community into your workstation. The omnibus installer is used to set up the Chef development kit on a workstation. Here’s how:

  • Visit http://downloads.chef.io/chef-dk and select the omnibus installer for the desired platform.
  • The Chef development kit supports Mac OS X, Red Hat Enterprise Linux, Ubuntu, and Microsoft Windows.
  • When the installation finishes, open a command line terminal and enter the following:

1

chef verify

  • Ensure that the Chef-DK is added to the front of your path.

1

PATH=$HOME/.chefdk/gem/ruby/2.1.0/bin:/opt/chefdk/bin:$PATH

  • Initilize a Berksfile into your cookbook.

1

2

cd my-cookbook

berks init .

  • Specify your dependencies in a Berksfile in your cookbook’s root.

1

2

3

4

5

source "https://supermarket.chef.io"

metadata

cookbook "apache"

cookbook "mysql", "~> 5.3"

  • Once the dependencies are mentioned in a berksfile, you can install them.

1

berks install

Berkshelf stores every version of a cookbook that you have ever installed in ~/.berkshelf.

  • Once your cookbook is ready, you can upload it with all the dependent cookbooks using the following command.

1

berks upload phpapp

Bon appetit!

时间: 2024-12-25 00:32:31

Managing Chef Cookbooks the Berkshelf way的相关文章

chef学习杂记

原创文章,如有转载,请注明出处. 首先直观的看看chef是什么,怎样工作的,直观呢,就是上来就整.... 上来先到官网上下载 chefdk_0.11.2-1_amd64.deb 这个包,版本就下最新的好了.下载地址:downloads.chef.io chefdk  这个包全称是  Chef Development Kit   顾名思义chef的开发工具包. 安装过程不说了 安装好了之后执行 chef -v 查看当前安装的chef 套件清单,包含套件的版本号,chef-client,berks,

资源分享_Django.GitHub Python网页框架Django资源集合

模块相关: Channels 简介: Channels旨在增强Django的异步能力,同时让Django不仅仅局限于Request-Response模型,能够支持WebSocket,HTTP2推送和背景任务. Django-Baker 简介: Django Baker可以帮助开发者快速启动项目.只要提供app名称,Django Baker就可以根据models.py文件中的models,自动生成视图,表单,URL,admin页面以及模板. Django-Q 简介: Django Q是一个原生Dj

[原]Chef_Server and Chef_WorkStation and Chef_Client Install Guide[by haibo]

一.Prerequisite OS  :  CentOS-7.0-1406-x86_64-DVD.iso Time Server :   NTP Server SERVER NAME IP PLAN chef_server 192.168.100.10 chef_workstation 192.168.100.11 chefnode-1 192.168.100.12 IP Plan: rpm package(chef_server): autogen-libopts-5.18-5.el7.x86

[转帖]Vagrant 入门指南

Vagrant 入门指南 https://linux.cn/article-9587-1.html Vagrant 简介 Vagrant 是一个用来构建和管理虚拟机环境的工具.Vagrant 有着易于使用的工作流,并且专注于自动化,降低了开发者搭建环境的时间,提高了生产力.解决了“在我的机器上可以工作”的问题. Vagrant 是为了方便的实现虚拟化环境而设计的,使用 Ruby 开发,基于 VirtualBox 等虚拟机管理软件的接口,提供了一个可配置.轻量级的便携式虚拟开发环境.使用 Vagr

CentOS 6.3下CHEF批量部署APACHE

之前的博文我介绍了如何搭建CHEF环境以及创建编写cookbook,resipes用来批量将cookbook下发到客户端执行相应的部署操作. NOW,本篇文档我们会详细介绍如何利用CHEF独有的框架语言来批量部署安装APACHE,并加载其HTTPS模块等功能. 相信如果你看了本篇文档,利用CHEF实现一个批量自动化部署将不是什么难事. CHEF环境部署详见: http://showerlee.blog.51cto.com/2047005/1408467 操作系统:CentOS-6.3-x86-6

Centos 7安装与配置chef

背景:随着DevOps 逐渐流行起来,越来越多的工作需要自动化处理,而chef就是其中一款能实现自动化管理的工具,掌握类似chef这样的自动化工具,相信会使你在未来的竞争中更具优势. 俗话说"好记性不如烂笔头",以下记录一来为了记忆,二来希望能帮到对chef有兴趣的朋友们. 一. 简介:chef总共分成三部分,分别为chef-server.workstation和node: Server:维护一套配置脚本(cookbook),与每个被管节点(node)交互并给出配置指令. Workst

运维神器Chef简单介绍和安装笔记

首先大概解释一下Chef Chef有三个重要的概念:(如上图所示) 它们的合作关系大致是这样的, Workstation把资源或者说是一些要被运行的命令上传到Chef-Server上, Nodes自动通过Chef-Server拿到属于自己的执行任务到本地执行,这样可达到一个将军指挥千军万马的效果:smirk:. Chef Server 存放所有通过Workstation上传的资源,和用户等公共数据(用PostgreSQL). 可以干脆叫它为资源服务器,大家都可以与它通讯(用RabbitMQ ),

使用Chef管理windows集群

但凡服务器上了一定规模(百台以上),普通的ssh登录管理的模式就越来越举步维艰.试想Linux发布了一个高危漏洞的补丁,你要把手下成百上千台机器都更新该补丁,如果没有一种自动化方式,那么至少要耗上大半天时间.虽然你编写了大量的shell(或python,perl)脚本来实现各种自动化场景,但最后会发现你又陷入了脚本的汪洋大海之中,管理和维护这么多的脚本的成本也不小.你需要一款基础设施自动化工具,希望它能具有以下功能. 批量执行.这个不多说了吧,试想要为每一台机器打补丁的情形吧. 任务编排.现在稍

CentOS 6.3下CHEF环境部署

一.前言: 初识Chef,我们可以先了解一下DevOps运动 http://zh.wikipedia.org/wiki/DevOps,简单点说,就是传统的软件组织将开发.IT运营和质量保障设为各自分离的部门,而DevOps运动的出现是由于软件行业日益清晰地认识到:为了按时交付软件产品和服务,开发和运营工作必须紧密合作.所以Chef简单点说,就是DevOps运动中的一项重要工具成员,是一个同时面向开发与运维的集中管理工具. 就服务器的集中管理工具而言,知名度与Chef平分天下的是叫"Puppet&