Skip to content

用于自动化搭建WEB服务器,完全不用手工干预的快速配置WEB主机的程序。

License

Notifications You must be signed in to change notification settings

gazeldx/chef-repo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

首先让我们先搞明白这个chef-repo能做什么。

我们搭建一台Web服务器需要安装并配置Ruby, Rails, Nginx, 数据库(Postgresql), 一些软件(如imagemagcik), 项目源代码等。

这一系列的工作如果做三次,我们都不会觉得烦。因为我们认为这是应该做的。如果同样的事情要做100次呢?今天我就遇到这样的事情了。我的故事网站 开源后,很多站长用惯了php上传代码,看到DIY主机就害怕。我就说,如果你信得过我,将你的主机IP和密码告诉我,我会帮你安装、配置好服务器。我操作完成后,你改掉密码。 立刻有站长要我代劳,我不能每搭一台主机都花上两个小时啊!

所以我使用Chef技术配置服务器。Chef基于Ruby语言开发,专用于批量服务器配置。它使得开发人员通过编程的方式配置主机。

这里的源代码就是搭建WEB主机的程序。

如果你感兴趣,也可以学习一下Chef技术。用我写好的chef-repo快速搭建WEB主机。Chef不像Rails那么好学,我学了整整一个月。这一个月花得值得,因为Chef的确好用。

Overview

Every Chef installation needs a Chef Repository. This is the place where cookbooks, roles, config files and other artifacts for managing systems with Chef will live. We strongly recommend storing this repository in a version control system such as Git and treat it like source code.

While we prefer Git, and make this repository available via GitHub, you are welcome to download a tar or zip archive and use your favorite version control system to manage the code.

Repository Directories

This repository contains several directories, and each directory contains a README file that describes what it is for in greater detail, and how to use it for managing your systems with Chef.

  • certificates/ - SSL certificates generated by rake ssl_cert live here.
  • config/ - Contains the Rake configuration file, rake.rb.
  • cookbooks/ - Cookbooks you download or create.
  • data_bags/ - Store data bags and items in .json in the repository.
  • roles/ - Store roles in .rb or .json in the repository.

Rake Tasks

The repository contains a Rakefile that includes tasks that are installed with the Chef libraries. To view the tasks available with in the repository with a brief description, run rake -T.

The default task (default) is run when executing rake with no arguments. It will call the task test_cookbooks.

The following tasks are not directly replaced by knife sub-commands.

  • bundle_cookbook[cookbook] - Creates cookbook tarballs in the pkgs/ dir.
  • install - Calls update, roles and upload_cookbooks Rake tasks.
  • ssl_cert - Create self-signed SSL certificates in certificates/ dir.
  • update - Update the repository from source control server, understands git and svn.

The following tasks duplicate functionality from knife and may be removed in a future version of Chef.

  • metadata - replaced by knife cookbook metadata -a.
  • new_cookbook - replaced by knife cookbook create.
  • role[role_name] - replaced by knife role from file.
  • roles - iterates over the roles and uploads with knife role from file.
  • test_cookbooks - replaced by knife cookbook test -a.
  • test_cookbook[cookbook] - replaced by knife cookbook test COOKBOOK.
  • upload_cookbooks - replaced by knife cookbook upload -a.
  • upload_cookbook[cookbook] - replaced by knife cookbook upload COOKBOOK.

Configuration

The repository uses two configuration files.

  • config/rake.rb
  • .chef/knife.rb

The first, config/rake.rb configures the Rakefile in two sections.

  • Constants used in the ssl_cert task for creating the certificates.
  • Constants that set the directory locations used in various tasks.

If you use the ssl_cert task, change the values in the config/rake.rb file appropriately. These values were also used in the new_cookbook task, but that task is replaced by the knife cookbook create command which can be configured below.

The second config file, .chef/knife.rb is a repository specific configuration file for knife. If you're using the Opscode Platform, you can download one for your organization from the management console. If you're using the Open Source Chef Server, you can generate a new one with knife configure. For more information about configuring Knife, see the Knife documentation.

http://help.opscode.com/faqs/chefbasics/knife

Next Steps

Read the README file in each of the subdirectories for more information about what goes in those directories.

About

用于自动化搭建WEB服务器,完全不用手工干预的快速配置WEB主机的程序。

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%