2015-07-04 92 views
1

我正在試驗廚師和測試廚房。設置測試廚房食譜食譜生成廚師服務器在流浪者

我面臨的問題如下。 我使用的是arch linux,我無法在我的機器上安裝廚師,所以我決定使用一個centos7盒來運行vm。

我的目標是讓使用測試廚房菜譜創建企業的廚師服務器,並有兩臺機器(服務器和工作VM)上依賴於其他同一網絡的一個訪問。所以是的,這是一個嵌套的設置。 如果有人有更好的主意,我願意接受不同的建議。

對於工作VM,我用這個箱子:

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

這是我的流浪文件的內容:

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' 

屬性/ 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並將其與此悲慘的失敗了:

[[email protected] 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 

[[email protected] enterprise-chef]$ 

我目前正試圖通過手動改變Vagrantfile位於.kitchen/kitchen-vagrant/kitchen-enterprise-chef-default-centos-65弄清楚這個問題:

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 

到目前爲止,我得到這個錯誤:

[[email protected] 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...無限期地去,我被迫停止它。 但是這臺機器似乎正在運轉,只有第一個流浪者不能進入。

[[email protected] 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`. 
[[email protected] kitchen-enterprise-chef-default-centos-65]$ 

我的猜測是網絡配置有些糟糕的錯誤。

我的設置任何想法或一些反饋非常受歡迎。

謝謝。

+1

在主機箱而不是虛擬廚師服務器上使用chef-zero會出現什麼問題?這就是廚師零零是爲之而建的。 –

+0

我想這是有道理的。謝謝!如果您創建答案,我可以將線程標記爲已解決。 –

回答

1

我建議你只是用廚師零供應者的foodcritic。

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

這將旋轉起來在主機箱的臨時廚師零的服務器,並使其可到foodcritic運行。這也爲您節省了運行第二臺服務器的主要開銷。我所知道的唯一的挫折是如果你碰巧需要同時測試多個節點。我不完全確定插件如何處理。要麼它會共享一個Chef-zero(可能是好的或不好的),爲每個測試套件創建一個(再次好壞取決於你實際需要的),否則它可能會崩潰。