仅限本地模式厨师的厨师 [英] Chef in local mode cookbooks only

查看:114
本文介绍了仅限本地模式厨师的厨师的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试建立一个工作流程以在本地开发Chef Cookbook。目前,我们正在使用Chef Server,并使用Chef-Client来配置节点。

I'm trying to set up a workflow to develop Chef cookbooks locally. We're currently using Chef Server with the provisioned nodes using chef-client.

作为新工作流程的一部分,我们希望能够开始使用Vagrant测试菜谱

As part of the new workflow, we want to be able to start using Vagrant to test cookbooks locally to avoid incurring in the costs of testing on a remote machine in a cloud.

我能够在本地启动和配置本地Vagrant机器,但我需要一件事我不太确定该怎么做,就是让Chef加载食谱的本地版本,但是仍然要与Chef服务器联系以获取其他所有信息(环境,角色,数据包等),所以我不必上传每次我要测试时,都要通过刀子操作食谱。这有可能吗?

I'm able to launch and provision a local Vagrant machine, but the one thing I'm not really sure how to do is to have Chef load the local version of the cookbook, but still talk to the Chef server for everything else (environments, roles, data bags, etc.), so I don't have to upload the cookbook via knife every time I make a change I want to test. Is this possible?

换句话说,我可以让厨师客户只与食谱联系本地厨师零服务器,而与其他厨师联系远程厨师服务器吗? ?还是可能产生相同效果的不同方法?我愿意接受建议。

In other words, can I make chef-client talk to the local chef-zero server only for the cookbooks but to the remote Chef server for everything else? Or maybe a different approach that would yield the same effect? I'm open to suggestions.

我认为一个例子将有助于表达我的意思。寻找。我意识到这可能并不是我真正需要的,但是我很好奇如何实现它。在这种情况下,食谱将从存储在远程Chef服务器中的数据包中读取

I think an example will help to express what I'm looking for. I'm realizing that this may not really be what I need, but I'm curious about how to achieve it anyway. In this scenario, a recipe reads from a databag stored in the remote Chef server

name             'proxy-cookbook'
version          '0.0.0'



.kitchen.yml



.kitchen.yml

---
driver:
  name: vagrant

provisioner:
  name: chef_zero

platforms:
  - name: ubuntu-12.04

suites:
  - name: default
    run_list:
      - recipe[proxy-cookbook::default]
    attributes:



食谱/default.rb



recipes/default.rb

...
key = data_bag_item("key", "main")
....

现在,我知道我可以创建一些东西了

Now, I know I can create something along the lines of:

{
  "id": "main",
  "key": "s3cr3tk3y"
}

从该数据袋中读取我的厨房测试;但这正是我要避免的。是否可以:

And have my kitchen tests read from that data bag; but that is exactly what I'm trying to avoid. Is it possible to either:


  • 指示测试厨房从厨师服务器获取实际数据包,

  • chef-zero是否已获取数据包的临时副本以进行本地测试,或者

  • 在本地快速转储远程Chef服务器的内容?

我希望这是有道理的。我可以根据需要添加一些上下文。

I hope that makes sense. I can add some context if necessary.

推荐答案

我想我已经找到了想要的东西。

I think I found what I was looking for.

您可以使用美工刀下载所需的Chef服务器对象。您可以在.kitchen.yml中进行引导,因此不必每次都手动进行操作。

You can use knife to download the Chef server objects that you need. You can bootstrap this in .kitchen.yml so you don't have to do it manually every time.

...
driver:
  name: vagrant
  pre_create_command: 'mkdir -p chef-server; knife download /data_bags /roles /environments --chef-repo-path chef-server/'
...
provisioner:
  name: chef_zero
  data_bags_path: chef-server/data_bags
  roles_path: chef-server/roles
  environments_path: chef-server/environments
  client_rb:
    environment: development
...

然后我刚刚将厨师服务器目录添加到.gitignore

And then I just added the chef-server directory to .gitignore

chef-server/

执行此操作的冗余度可能较小,但这对我现在有效,并且由于我只是想对此进行记录,所以我将其保留下来。

There might be a less redundant way of doing this, but this works for me right now, and since I just wanted to document this, I'm leaving it like that.

这篇关于仅限本地模式厨师的厨师的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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