在不注册节点的情况下用厨师服务器和无业游民供应开发人员环境 [英] Provision developer environment with chef server and vagrant without registering node

查看:67
本文介绍了在不注册节点的情况下用厨师服务器和无业游民供应开发人员环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望创建一个基于Web的应用程序的开发人员环境,该环境将使用vagrant在VM上安装应用程序服务器和数据库服务器。我正在使用 chef_client 预配器使用开源厨师服务器和无业游民。但是,每次设置开发者节点时, chef_client 设置者都会在Chef服务器上创建一个客户端节点。这是不理想的,因为许多开发人员都会使用此设置。这样的节点可能会多次创建和销毁。因此,不需要在Chef服务器上维护此类节点的列表。



chef_solo 是另一种选择,但它需要系统中存在的食谱。我们还将厨师服务器用作食谱的存储库。因此,开发人员无需在其系统中拥有特定的食谱。我也看过berkshelf,可以在其中配置 chef_api 到厨师服务器的路径。但这也需要一个节点。以下是我的流浪者文件:

  VAGRANTFILE_API_VERSION = 2 

Vagrant.configure(VAGRANTFILE_API_VERSION)可以| config |
config.vm.box = precise64-chef
config.vm.network:private_network,ip: 33.33.33.10
config.omnibus.chef_version = '11 .8.2'
config.vm.provision chef_client做| chef |
Chef.log_level =:调试
Chef.environment =开发
Chef.delete_node =真
Chef.delete_client =真
Chef.node_name = sample_app
Chef.chef_server_url = https:// chef-server-url
Chef.validation_key_path = chef-validator.pem
Chef.add_role基础
厨师。 add_role pg_client
Chef.add_role application_server
Chef.add_role db_server
Chef.add_recipe deploy_application
结束
结束

我不希望在Chef服务器上创建 sample_app 节点。否则,这符合我的目的。欢迎使用其他使用Chef服务器配置开发人员环境的其他策略。

解决方案

立即解决方案



Butcher插件



想到的直接答案是使用流浪屠夫插件。这将自动删除厨师服务器上的开发人员客户端和节点条目。



长期解决方案



'了解Berkshelf chef_api指令我将假设您具有典型的企业场景,其中有多个开发人员正在共享



这就是我在做厨师的事情。



厨师食谱库模式



将Chef服务器的实例保留为食谱的存储库。每个发行的食谱版本都被推送到此处,并且可供厨师的所有内部用户使用。



要维护存储库食谱,请使用Jenkins对食谱执行CI流程。 Jenkins的工作来自本地GIT存储库或社区食谱网站。这种方法的优点是可以使用 chef spec 自动进行测试,并且可以使用诸如食品评论家。通过这种方式,构建失败有助于提高组织内部使用的食谱的整体质量。



我认为这种存储库模式是我们将要做的更多工作当Berkshelf伙计们最终启动 Berkshelf 3.0 (另请参见 berkshelf-api )。



使用Berkshelf加载食谱



Berkshelf用于控制将食谱加载到所有厨师服务器(dev或prod)中。以下是演示 Berksfile:

  chef_api https://cookbook.repo.myorg.com/\",node_name : dev1,client_key: /path/to/dev1/private/key/key.pem 

食谱 apache2
食谱 mysql
...

chef_api指令告诉berkshelf从本地厨师食谱库中加载所有食谱,而不是默认从社区资源库加载。



这使得创建主厨师服务器的类似于生产的副本变得很简单。它还使berkshelf的更神奇的方面之一。系统中的每个食谱都可以拥有自己的简单Berksfile:

  chef_api https://cookbook.repo.myorg.com/  ..... 

元数据

元数据语句告诉Berkshelf可以将列为依赖项的食谱加载到食谱的元数据文件中。太好了,一个简单的 berks上传,我需要的所有食谱都会自动加载到我的开发厨师服务器中。



使用Spiceweasel加载厨师服务器



非常有用的工具。集成Berkshelf并生成用于从厨师存储库加载厨师服务器的所有其他刀具命令。。 p>

https://github.com/mattray/spiceweasel



发展:零厨师和流浪汉



一旦食谱受到控制(使用Berkshelf),我的建议是采用厨师零。每个开发人员然后都可以拥有自己的本地管理的厨师服务器实例。



以下是我经常安装的流浪汉插件,以支持厨师食谱的开发:





一旦准备好食谱,它将被提交并推送。然后,詹金斯(Jenkins)将选择新修订并自动将其加载到菜谱库中。


I wish to create a developer environment of a web based application which will have an application server and database server installed on a VM using vagrant. I am using open source chef server and vagrant with chef_client provisioner. However each time a developer node is provisioned, chef_client provisioner creates a client node on chef server. This is not desirable because this setup will be used by a lot of developers. Such nodes might get created and destroyed several times. So maintaining the list of such nodes on chef server is not required.

chef_solo is another option but it requires the cookbook to be present in the system. We are using chef server as a repository for cookbooks as well. So a developer need not have the specific cookbook in his/her system. I have looked at berkshelf as well where I can configure chef_api path to the chef server. But that too requires a node. Following is my vagrant file:

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "precise64-chef"
  config.vm.network :private_network, ip: "33.33.33.10"
  config.omnibus.chef_version = '11.8.2'
  config.vm.provision "chef_client" do |chef|
    chef.log_level = :debug
    chef.environment = "development"
    chef.delete_node = true
    chef.delete_client = true
    chef.node_name = "sample_app"
    chef.chef_server_url = "https://chef-server-url"
    chef.validation_key_path = "chef-validator.pem"
    chef.add_role "base"
    chef.add_role "pg_client"
    chef.add_role "application_server"
    chef.add_role "db_server"
    chef.add_recipe "deploy_application"
  end
end

I wish to not create sample_app node on chef server. Otherwise this serves my purpose. Any other strategies to provision developer environment using chef server are welcome.

解决方案

Immediate solution

Butcher plugin

The immediate answer that springs to mind is use the vagrant butcher plugin. This will automtically delete your developer client and node entries on the chef server.

Longer term solution

Since you're aware of the Berkshelf "chef_api" directive I will assume you have the typical Enterprise scenario where several developers are sharing locally developed cookbooks.

Here's what I'm doing with chef....

Chef cookbook repository pattern

Reserve an instance of chef server as a repository of cookbooks. Each released cookbook version is pushed here and made available for consumption by all internal users of chef.

To maintain the repository cookbooks, use Jenkins to implement a CI process for cookbooks. Jenkins jobs pull from local GIT repositories, or from the community cookbook site. The advantage of this approach is that tests can be automated using chef spec and QA rules can be implemented using tools like foodcritic. In this manner build failures help improve the overall quality of the cookbooks in use within the organisation.

I reckon this repository pattern is something we're going to a lot more of when the Berkshelf guys finally launch Berkshelf 3.0 (See also berkshelf-api).

Use Berkshelf to load cookbooks

Berkshelf is used to control the loading of cookbooks into all chef servers (dev or prod). The following is a demo "Berksfile":

chef_api "https://cookbook.repo.myorg.com/", node_name: "dev1", client_key: "/path/to/dev1/private/key/key.pem"

cookbook "apache2"
cookbook "mysql"
...

The "chef_api" directive tells berkshelf to load all cookbooks from the local chef cookbook repository, instead of defaulting to loading from the community repository.

This makes it trivial to create "production-like" copies of your main chef server. It also enables one of the more magical aspects of berkshelf. Each cookbook in your system can have it's own simple Berksfile:

chef_api "https://cookbook.repo.myorg.com/".....

metadata

The "metadata" statement tells Berkshelf to load the cookbooks listed as dependencies in the cookbook's metadata file. This is wonderful, a simple "berks upload" and all the cookbooks I need get automatically loaded into my development chef server.

Use Spiceweasel for loading chef server

Very useful tool. Integrates Berkshelf and generates all the other knife commands for loading a chef server from a chef repository.

https://github.com/mattray/spiceweasel

Development: Chef Zero and Vagrant

Once cookbooks are under control (using Berkshelf) my advise is to adopt Chef zero. Each developer can then have their own locally managed chef server instance.

Here are the vagrant plugins I routinely install to support chef cookbook development:

Once a cookbook is ready, it gets committed and pushed. Jenkins will then pick up the new revision and automatically loads it into the cookbook repository.

这篇关于在不注册节点的情况下用厨师服务器和无业游民供应开发人员环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆