设置测试厨房食谱食谱以在 vagrant 中生成厨师服务器
Set up a test kitchen cookbook recipe to generate chef server inside vagrant
我正在尝试厨师和测试厨房。
我面临的问题如下。
我正在使用 arch linux,但我无法在我的机器上安装 chef,所以我决定使用 centos7 box 作为工作虚拟机。
我的目标是通过测试厨房使用食谱创建企业厨师服务器,并让两台机器(服务器和工作虚拟机)在同一网络上访问,一个依赖于另一个。是的,这是一个嵌套设置。
如果有人有更好的主意,我愿意接受不同的建议。
对于工作虚拟机,我使用了这个盒子:
这是我的 Vagrant 文件的内容:
Vagrant.configure(2) do |config|
config.vm.box = "chef-repo"
config.vm.network "public_network"
end
非常基础的东西...
我在那台机器上成功安装了 chef 和 test kitchen,生活很美好。
现在的问题是使用测试厨房从这里安装 Chef 服务器:
https://downloads.chef.io/chef-server/
我用测试厨房创建了一个非常简单的配置,类似于以下内容:
recipes/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...
无限期地运行,我不得不停止它。
但是机器似乎是 运行ning,只有第一个 vagrant 实例无法访问。
[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]$
我的猜测是网络配置出现严重错误。
非常欢迎关于我的设置的任何想法或反馈。
谢谢。
厨师服务器食谱已设置为 运行 测试厨房:
git clone https://github.com/chef-cookbooks/chef-server.git
cd chef-server
kitchen converge default-centos-71
它利用 vagrant 为厨师服务器设置一个 local IP address 到 运行。如果这适用于您的虚拟机(嵌套虚拟化),将会很有趣。
另一种方法是 运行 您在 Digital ocean 上的测试虚拟机利用云厨房文件:
我建议你只为 foodcritic 使用 chef-zero provisioner。
provisioner:
name: chef_zero
data_bags_path: /some/path
...
这将在主机箱上启动一个临时零厨师服务器,并使其可供美食评论家使用 运行。这也为您节省了第二台服务器的主要开销 运行ning。我所知道的唯一挫折是,如果您碰巧需要同时测试多个节点。我不完全确定插件将如何处理。要么它会共享一个 Chef-zero(可能好也可能坏),为每个测试套件创建一个(同样,好或坏,取决于您的实际需要),或者它可能会崩溃。
我正在尝试厨师和测试厨房。
我面临的问题如下。 我正在使用 arch linux,但我无法在我的机器上安装 chef,所以我决定使用 centos7 box 作为工作虚拟机。
我的目标是通过测试厨房使用食谱创建企业厨师服务器,并让两台机器(服务器和工作虚拟机)在同一网络上访问,一个依赖于另一个。是的,这是一个嵌套设置。 如果有人有更好的主意,我愿意接受不同的建议。
对于工作虚拟机,我使用了这个盒子:
这是我的 Vagrant 文件的内容:
Vagrant.configure(2) do |config|
config.vm.box = "chef-repo"
config.vm.network "public_network"
end
非常基础的东西...
我在那台机器上成功安装了 chef 和 test kitchen,生活很美好。
现在的问题是使用测试厨房从这里安装 Chef 服务器:
https://downloads.chef.io/chef-server/
我用测试厨房创建了一个非常简单的配置,类似于以下内容:
recipes/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...
无限期地运行,我不得不停止它。
但是机器似乎是 运行ning,只有第一个 vagrant 实例无法访问。
[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]$
我的猜测是网络配置出现严重错误。
非常欢迎关于我的设置的任何想法或反馈。
谢谢。
厨师服务器食谱已设置为 运行 测试厨房:
git clone https://github.com/chef-cookbooks/chef-server.git
cd chef-server
kitchen converge default-centos-71
它利用 vagrant 为厨师服务器设置一个 local IP address 到 运行。如果这适用于您的虚拟机(嵌套虚拟化),将会很有趣。
另一种方法是 运行 您在 Digital ocean 上的测试虚拟机利用云厨房文件:
我建议你只为 foodcritic 使用 chef-zero provisioner。
provisioner:
name: chef_zero
data_bags_path: /some/path
...
这将在主机箱上启动一个临时零厨师服务器,并使其可供美食评论家使用 运行。这也为您节省了第二台服务器的主要开销 运行ning。我所知道的唯一挫折是,如果您碰巧需要同时测试多个节点。我不完全确定插件将如何处理。要么它会共享一个 Chef-zero(可能好也可能坏),为每个测试套件创建一个(同样,好或坏,取决于您的实际需要),或者它可能会崩溃。