簡體   English   中英

使用Vagrant和Chef設置Nginx

[英]Setting up Nginx with Vagrant and Chef

重新來。 :P @ crum2嘗試了apt-get更新,但是沒有運氣。 :\\盡管我和我的朋友說話,但我確實做到了,他說我使用的是一盒不是最可靠的東西。 因此,有一種保存.box的方法嗎? 那是通過廚師等供應之后嗎? 顯然需要做更多的閱讀。 因此,我更改為以下內容:

流浪文件

  # -*- mode: ruby -*-
  # vi: set ft=ruby :

Vagrant.configure("2") do |config|

  config.vm.box = "precise64"

  config.vm.box_url = "http://files.vagrantup.com/precise64.box"

  config.vm.network :public_network

  config.vm.provider :virtualbox do |vb|
    vb.customize ["modifyvm", :id, "--memory", "1024"]
  end

  config.vm.provision :chef_solo do |chef|
    chef.cookbooks_path = "cookbooks"
    chef.add_recipe "nginx"
  end

end

我已經創建了自己的食譜目錄,並根據以下網址僅下載了我認為需要的內容: http : //community.opscode.com/cookbooks/nginx

食譜

   |__build-essential
   |__nginx
   |__ohai
   |__runit

終端輸出

mac-mini:test admin$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'precise64'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Available bridged network interfaces:
1) en0: Ethernet
2) en1: Wi-Fi (AirPort)
What interface should the network bridge to? 1
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Running any VM customizations...
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] Configuring and enabling network interfaces...
[default] Mounting shared folders...
[default] -- /vagrant
[default] -- /tmp/vagrant-chef-1/chef-solo-1/cookbooks
[default] Running provisioner: VagrantPlugins::Chef::Provisioner::ChefSolo...
Generating chef JSON and uploading...
Running chef-solo...
stdin: is not a tty
[2013-04-15T23:42:59+00:00] INFO: *** Chef 10.14.2 ***
[2013-04-15T23:42:59+00:00] INFO: Setting the run_list to ["recipe[nginx]"] from JSON
[2013-04-15T23:42:59+00:00] INFO: Run List is [recipe[nginx]]
[2013-04-15T23:42:59+00:00] INFO: Run List expands to [nginx]
[2013-04-15T23:42:59+00:00] INFO: Starting Chef Run for precise64
[2013-04-15T23:42:59+00:00] INFO: Running start handlers
[2013-04-15T23:42:59+00:00] INFO: Start handlers complete.
[2013-04-15T23:43:00+00:00] INFO: ohai plugins will be at: /etc/chef/ohai_plugins
[2013-04-15T23:43:00+00:00] INFO: Processing remote_directory[/etc/chef/ohai_plugins] action create (ohai::default line 30)
[2013-04-15T23:43:00+00:00] INFO: Processing directory[/etc/chef/ohai_plugins] action create (dynamically defined)
[2013-04-15T23:43:00+00:00] INFO: directory[/etc/chef/ohai_plugins] created directory /etc/chef/ohai_plugins
[2013-04-15T23:43:00+00:00] INFO: directory[/etc/chef/ohai_plugins] mode changed to 755
[2013-04-15T23:43:00+00:00] INFO: Processing cookbook_file[/etc/chef/ohai_plugins/README] action create (dynamically defined)
[2013-04-15T23:43:00+00:00] INFO: cookbook_file[/etc/chef/ohai_plugins/README] mode changed to 644
[2013-04-15T23:43:00+00:00] INFO: cookbook_file[/etc/chef/ohai_plugins/README] created file /etc/chef/ohai_plugins/README
[2013-04-15T23:43:00+00:00] INFO: remote_directory[/etc/chef/ohai_plugins] created directory /etc/chef/ohai_plugins
[2013-04-15T23:43:00+00:00] INFO: remote_directory[/etc/chef/ohai_plugins] mode changed to 755
[2013-04-15T23:43:00+00:00] INFO: Processing ohai[custom_plugins] action reload (ohai::default line 44)
[2013-04-15T23:43:00+00:00] INFO: ohai[custom_plugins] reloaded
[2013-04-15T23:43:00+00:00] INFO: Processing ohai[reload_nginx] action nothing (nginx::ohai_plugin line 22)
[2013-04-15T23:43:00+00:00] INFO: Processing template[/etc/chef/ohai_plugins/nginx.rb] action create (nginx::ohai_plugin line 27)
[2013-04-15T23:43:00+00:00] INFO: template[/etc/chef/ohai_plugins/nginx.rb] updated content
[2013-04-15T23:43:00+00:00] INFO: template[/etc/chef/ohai_plugins/nginx.rb] owner changed to 0
[2013-04-15T23:43:00+00:00] INFO: template[/etc/chef/ohai_plugins/nginx.rb] group changed to 0
[2013-04-15T23:43:00+00:00] INFO: template[/etc/chef/ohai_plugins/nginx.rb] mode changed to 755
[2013-04-15T23:43:00+00:00] INFO: template[/etc/chef/ohai_plugins/nginx.rb] sending reload action to ohai[reload_nginx] (immediate)
[2013-04-15T23:43:00+00:00] INFO: Processing ohai[reload_nginx] action reload (nginx::ohai_plugin line 22)
[2013-04-15T23:43:00+00:00] INFO: ohai[reload_nginx] reloaded
[2013-04-15T23:43:00+00:00] INFO: Processing remote_directory[/etc/chef/ohai_plugins] action nothing (ohai::default line 30)
[2013-04-15T23:43:00+00:00] INFO: Processing ohai[custom_plugins] action nothing (ohai::default line 44)
[2013-04-15T23:43:00+00:00] INFO: Processing package[nginx] action install (nginx::default line 35)

================================================================================
Error executing action `install` on resource 'package[nginx]'
================================================================================

Chef::Exceptions::Exec
----------------------
apt-get -q -y install nginx=1.1.19-1 returned 100, expected 0

Resource Declaration:
---------------------
# In /tmp/vagrant-chef-1/chef-solo-1/cookbooks/nginx/recipes/default.rb

 34:   end
 35:   package node['nginx']['package_name']
 36:   service 'nginx' do

Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/nginx/recipes/default.rb:35:in `from_file'

package("nginx") do
  retry_delay 2
  retries 0
  recipe_name "default"
  action :install
  cookbook_name :nginx
  package_name "nginx"
end

[2013-04-15T23:43:04+00:00] ERROR: Running exception handlers
[2013-04-15T23:43:04+00:00] ERROR: Exception handlers complete
[2013-04-15T23:43:04+00:00] FATAL: Stacktrace dumped to /tmp/vagrant-chef-1/chef-stacktrace.out
[2013-04-15T23:43:04+00:00] FATAL: Chef::Exceptions::Exec: package[nginx] (nginx::default line 35) had an error: Chef::Exceptions::Exec: apt-get -q -y install nginx=1.1.19-1 returned 100, expected 0
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

廚師Stacktrace

Generated at Mon Apr 15 23:43:04 +0000 2013
Chef::Exceptions::Exec: package[nginx] (nginx::default line 35) had an error: Chef::Exceptions::Exec: apt-get -q -y install nginx=1.1.19-1 returned 100, expected 0
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/command.rb:128:in `handle_command_failures'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/command.rb:75:in `run_command'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/command.rb:143:in `run_command_with_systems_locale'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/provider/package/apt.rb:97:in `install_package'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/provider/package.rb:81:in `action_install'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/why_run.rb:63:in `call'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/why_run.rb:63:in `converge!'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/why_run.rb:61:in `each'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/mixin/why_run.rb:61:in `converge!'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/provider.rb:136:in `converge'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/provider.rb:125:in `run_action'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/resource.rb:593:in `run_action'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/runner.rb:49:in `run_action'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/runner.rb:81:in `converge'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/runner.rb:81:in `each'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/runner.rb:81:in `converge'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/resource_collection.rb:94:in `execute_each_resource'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/resource_collection.rb:92:in `execute_each_resource'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/runner.rb:80:in `converge'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/client.rb:378:in `converge'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/client.rb:420:in `do_run'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/client.rb:176:in `run'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application/solo.rb:230:in `run_application'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application/solo.rb:218:in `loop'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application/solo.rb:218:in `run_application'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/../lib/chef/application.rb:70:in `run'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-10.14.2/bin/chef-solo:25
/opt/vagrant_ruby/bin/chef-solo:19:in `load'
/opt/vagrant_ruby/bin/chef-solo:19

那我在這里想念什么呢? 隨時向我推薦優質的閱讀材料。

APT無法以某種方式在版本1.1.19-1中安裝Nginx軟件包-您是否手動指定了該版本? 也許在框中運行apt-get update來刷新軟件包索引,然后重試(也許由於更新,舊的nginx軟件包不可用)。

所以事實證明,添加apt后,所有問題都解決了,這個家伙現在似乎已經知道了。 這有助於: ubuntu 12.04上的Chef build-essential cookbook錯誤 刪除或保留它。 :P

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM