Chef 简明教程

Chef - Workstation Setup

Chef 遵循客户端-服务器架构的理念,因此为了开始使用 Chef,需要在工作站上设置 Chef 并在本地开发配置。稍后可以将其上传到 Chef 服务器,使其在 Chef 节点上运行,需要对其进行配置。

Chef follows the concept of client-server architecture, hence in order to start working with Chef one needs to set up Chef on the workstation and develop the configuration locally. Later it can be uploaded to Chef server to make them working on the Chef nodes, which needs to be configured.

Opscode 提供了一个完整的打包版本,其中没有任何外部先决条件。这个完全打包的 Chef 被称为 omnibus installer

Opscode provides a fully packaged version, which does not have any external prerequisites. This fully packaged Chef is called the omnibus installer.

On Windows Machine

Step 1 − 在计算机上下载 chefDK 的安装 .msi 文件。

Step 1 − Download the setup .msi file of chefDK on the machine.

Step 2 − 按照安装步骤进行操作,并将其安装在目标位置。

Step 2 − Follow the installation steps and install it on the target location.

安装程序将如下面的屏幕截图所示。

The setup will look as shown in the following screenshot.

window setup

ChefDK Path Variable

$ echo $PATH
/c/opscode/chef/bin:/c/opscode/chefdk/bin:

On Linux Machine

为了在 Linux 计算机上进行设置,我们首先需要在计算机上使用 curl。

In order to set up on the Linux machine, we need to first get curl on the machine.

Step 1 − 一旦在计算机上安装了 curl,我们需要使用 Opscode 的 omnibus chef 安装程序在工作站上安装 Chef。

Step 1 − Once curl is installed on the machine, we need to install Chef on the workstation using Opscode’s omnibus Chef installer.

$ curl –L https://www.opscode.com/chef/install.sh | sudo bash

Step 2 − 在机器上安装 Ruby。

Step 2 − Install Ruby on the machine.

Step 3 − 将 Ruby 添加到路径变量。

Step 3 − Add Ruby to path variable.

$ echo ‘export PATH = ”/opt/chef/embedded/bin:$PATH”’ ≫ ~/.bash_profile &&
source ~/.bash_profile

Chef 总线将把 Ruby 和所有必需的 Ruby gem 安装到 /opt/chef/embedded 中,方法是在 .bash_profile 文件中添加 /opt/chef/embedded/bin 目录。

The Omnibus Chef will install Ruby and all the required Ruby gems into /opt/chef/embedded by adding /opt/chef/embedded/bin directory to the .bash_profile file.

如果已安装 Ruby,则通过运行以下命令在机器上安装 Chef Ruby gem。

If Ruby is already installed, then install the Chef Ruby gem on the machine by running the following command.

$ gem install chef