设置测试厨房食谱食谱,以产生流浪汉内的厨师服务器

时间:2015-07-04 20:25:26

标签: vagrant chef vagrantfile chef-solo test-kitchen

我正在尝试厨师和测试厨房。

我面临的问题如下。 我正在使用arch linux,我无法在我的机器上安装厨师,因此我决定使用centos7盒子来运行vm。

我的目标是通过测试厨房使用食谱创建企业厨师服务器,并且可以在同一网络上访问两台机器(服务器和工作虚拟机),具体取决于另一台。所以是的,这是一个嵌套的设置。 如果有人有更好的想法,我会接受不同的建议。

对于工作的vm,我使用了这个框:

https://github.com/holms/vagrant-centos7-box/releases/download/7.1.1503.001/CentOS-7.1.1503-x86_64-netboot.box

以下是我的Vagrant文​​件的内容:

Vagrant.configure(2) do |config|
  config.vm.box = "chef-repo"

  config.vm.network "public_network"

end

非常基本的东西......

我成功地在那台机器上安装了厨师和测试厨房,生活很美好。

现在的问题是使用测试厨房从这里安装厨师服务器:

https://downloads.chef.io/chef-server/

我用测试厨房创建了一个非常简单的配置,类似于以下内容: 的食谱/ default.rb

package_url = node['enterprise-chef']['url']
package_name = ::File.basename(package_url)
package_local_path = "#{Chef::Config[:file_cache_path]}/#{package_name}"

# omnibus_package is remote (i.e., a URL) let's download it
remote_file package_local_path do
  source package_url
end

package package_local_path

# reconfigure the installation
execute 'private-chef-ctl reconfigure'

attributes / default.rb

default['enterprise-chef']['url'] = 'https://web-dl.packagecloud.io/chef/stable/packages/el/7/chef-server-core-12.1.0-1.el7.x86_64.rpm'

之后我运行$ kitchen converge并且它失败了:

[vagrant@localhost enterprise-chef]$ kitchen converge
-----> Starting Kitchen (v1.4.0)
-----> Creating <default-centos-65>...
       Bringing machine 'default' up with 'virtualbox' provider...
       ==> default: Importing base box 'opscode-centos-6.5'...
==> default: Matching MAC address for NAT networking...
       ==> default: Setting the name of the VM: kitchen-enterprise-chef-default-centos-65_default_1436040993946_29931
       ==> default: Clearing any previously set network interfaces...
       ==> default: Available bridged network interfaces:
       1) eth0
       2) eth1
       ==> default: When choosing an interface, it is usually the one that is
       ==> default: being used to connect to the internet.
       Vagrant is attempting to interface with the UI in a way that requires
       a TTY. Most actions in Vagrant that require a TTY have configuration
       switches to disable this requirement. Please do that or run Vagrant
       with TTY.
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: Failed to complete #create action: [Expected process to exit with [0], but received '1'
---- Begin output of vagrant up --no-provision --provider virtualbox ----
STDOUT: Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'opscode-centos-6.5'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: kitchen-enterprise-chef-default-centos-65_default_1436040993946_29931
==> default: Clearing any previously set network interfaces...
==> default: Available bridged network interfaces:
1) eth0
2) eth1
==> default: When choosing an interface, it is usually the one that is
==> default: being used to connect to the internet.
STDERR: Vagrant is attempting to interface with the UI in a way that requires
a TTY. Most actions in Vagrant that require a TTY have configuration
switches to disable this requirement. Please do that or run Vagrant
with TTY.
---- End output of vagrant up --no-provision --provider virtualbox ----
Ran vagrant up --no-provision --provider virtualbox returned 1]
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

[vagrant@localhost enterprise-chef]$ 

我目前正试图通过手动更改.kitchen/kitchen-vagrant/kitchen-enterprise-chef-default-centos-65中的 Vagrantfile 来解决问题:

Vagrant.configure("2") do |c|
  c.berkshelf.enabled = false if Vagrant.has_plugin?("vagrant-berkshelf")
  c.vm.box = "opscode-centos-6.5"
  c.vm.box_url = "https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.5_chef-provisionerless.box"

  c.vm.network :public_network

  c.vm.synced_folder ".", "/vagrant", disabled: true
  c.vm.provider :virtualbox do |p|
  end
end
到目前为止,我收到了这个错误:

[vagrant@localhost kitchen-enterprise-chef-default-centos-65]$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Available bridged network interfaces:
1) eth0
2) eth1
==> default: When choosing an interface, it is usually the one that is
==> default: being used to connect to the internet.
    default: Which interface should the network bridge to? 1
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: bridged
==> default: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
^C==> default: Waiting for cleanup before exiting...
Vagrant exited after cleanup due to external interrupt.
$

default: Warning: Connection timeout. Retrying...无限期地进行,我被迫停止它。 但机器似乎正在运行,只有第一个流浪者实例无法访问。

[vagrant@localhost kitchen-enterprise-chef-default-centos-65]$ vagrant status
Current machine states:

default                   running (virtualbox)

The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.
[vagrant@localhost kitchen-enterprise-chef-default-centos-65]$ 

我的猜测是网络配置出了问题。

非常欢迎任何关于我的设置的想法或反馈。

谢谢。

2 个答案:

答案 0 :(得分:1)

厨师服务器食谱已经设置为运行测试厨房:

git clone https://github.com/chef-cookbooks/chef-server.git
cd chef-server
kitchen converge default-centos-71

利用vagrant为主厨服务器设置local IP address。如果这在您的虚拟机(嵌套虚拟化)中有效,那将会很有趣。

另一种方法是利用云厨房文件在Digital ocean上运行测试虚拟机:

答案 1 :(得分:1)

我建议你只使用厨师零配置器来进行食物干预。

provisioner:
  name: chef_zero
  data_bags_path: /some/path
  ...

这将在主机盒上启动一个临时的厨师零服务器,并使其可用于foodcritic运行。这也可以节省第二台服务器运行的主要开销。我所知道的唯一挫折是,如果您碰巧需要同时测试多个节点。我不完全确定插件会如何处理。它要么共享一个Chef-zero(可能是好的也可能是坏的),每个测试套件创建一个(再次,好或坏,取决于你真正想要的东西),或者它可能只是崩溃。