Chef 简明教程
Chef - Version Control System Setup
使用版本控制系统是基础设施自动化的基本部分。有多种版本的控制系统,例如 SVN、CVS 和 GIT。由于 GIT 在 Chef 社区中的流行,我们将使用 GIT 设置。
Using Version Control system is a fundamental part of infrastructure automation. There are multiple kinds of version control system such as SVN, CVS, and GIT. Due to the popularity of GIT among the Chef community, we will use the GIT setup.
Note − 不要不使用版本控制系统构建基础设施即代码。
Note − Don’t think of building an infrastructure as a code without a version control system.
On Windows
Step 1 − 从 www.git-scm.org 下载 Windows 安装程序,然后按照安装步骤进行操作。
Step 1 − Download the Windows installer from www.git-scm.org and follow the installation steps.
Step 2 − 在 GitHub 上注册一个中心仓库。
Step 2 − Sign up for a central repository on GitHub.
Step 3 − 将 SSH 密钥上传到 GitHub 账户,以便可以轻松地与其交互。有关 SSH 密钥的详细信息,请访问以下链接 https://help.github.com/articles/generatingssh-keys 。
Step 3 − Upload the ssh key to the GitHub account, so that one can interact with it easily. For details on ssh key visit the following link https://help.github.com/articles/generatingssh-keys.
Step 4 − 最后,使用 chef-repo 的名称访问 https://github.com/new ,在 github 账户上创建一个 repo。
Step 4 − Finally create a repo on the github account by visiting https://github.com/new with the name of chef-repo.
在实际开始编写食谱之前,可以在开发机上设置一个初始的 GIT 仓库,并克隆 Opscode 提供的空仓库。
Before actually starting to write a cookbook, one can set up an initial GIT repository on the development box and clone the empty repository provided by Opscode.
Step 1 − 下载 Opscode Chef 仓库的空结构。
Step 1 − Download Opscode Chef repository empty structure.
$ wget https://github.com/opscode/chef-repo/tarball/master
Step 2 − 提取 tar 包。
Step 2 − Extract the tar ball.
$ tar –xvf master
Step 3 − 重命名目录。
Step 3 − Rename the directory.
$ mv opscode-chef-repo-2c42c6a/ chef-repo
Step 4 − 将当前工作目录更改为 chef repo。
Step 4 − Change the current working directory to chef repo.
$ cd chef-repo
Step 5 − 初始化一个新的 get repo。
Step 5 − Initialize a fresh get repo.
$ git init.
Step 6 − 连接到 git hub 上的 repo。
Step 6 − Connect to your repo on the git hub.
$ git remote add origin git@github.com:vipin022/chef-
Step 7 − 将本地 repo 推送到 github。
Step 7 − Push the local repo to github.
$ git add.
$ git commit –m “empty repo structure added”
$ git push –u origin maste
通过使用上述过程,您将获得一个空的 chef repo。然后,您可以开始开发配方和食谱。完成后,可以将更改推送到 GitHub。
By using the above procedure, you will get an empty chef repo in place. You can then start working on developing the recipes and cookbooks. Once done, you can push the changes to the GitHub.