2013-11-28 56 views
3

我正在與廚師和流浪者合作,以更好地自動化一些機器構建過程,並遇到了一個我似乎無法弄清楚的問題。問題是,無論我們做什麼,只要我們包含我們的PHP服務器食譜,它就會以某種方式將apache2彈出到運行列表的頂部。對於mysql也是一樣。我們希望使用remi repos而不是被PHP 5.3.3卡住,但我不能像Apache和mysql一樣首先安裝。 IE,預期的安裝順序是這樣的:Chef-solo安裝MySql和Apache2故障

  1. 運行yum /公寓更新並安裝基線包(該
  2. 基線的Linux服務器食譜)安裝的Apache2/PHP的安裝mysql
  3. 服務器

但我看到:

  1. 安裝的Apache2
  2. 安裝mysql服務器
  3. 開始按預期的順序安裝所有東西 - 包括再次查看php/apache2/mysql服務器。

在vagrantfile運行列表的樣子:

chef.add_recipe "company-baseline-linux-server::enterprise-linux" 
chef.add_recipe "company-baseline-linux-server" 
chef.add_recipe "company-php-server" 
chef.add_recipe "company-mysql-server" 
chef.add_recipe "company-php-server::setup-website" 
chef.add_recipe "company-wordpress-app" 
chef.add_recipe "company-wordpress-app::copy-assets" 
chef.add_recipe "company-wordpress-app::load-wordpress-db" 

公司的PHP ::默認食譜是:

#set apache ports 
node.default['apache']['listen_ports'] = node['listen_ports'] 

#setup apache default modules 
node.default['apache']['default_modules'] = %w(status alias rewrite headers deflate dir env mod_proxy mod_proxy_http mime negotiation setenvif authz_default authz_host log_config logio) 
include_recipe "apache2" 
include_recipe "apache2::mod_ssl" 

#set apache to autostart 
execute "auto start apache" do 
    command "chkconfig httpd on" 
end 

#add php 
include_recipe "php" 
include_recipe "apache2::mod_php5" 
include_recipe "php::module_mysql" 

#disable iptables for now 
include_recipe "iptables::disabled" 

#kill default site 
apache_site "default" do 
    enable false 
end 

公司MySQL的默認::食譜:

node.default["mysql"]["remove_anonymous_users"] = true 

include_recipe "mysql::server" 

#setup remote database user 
include_recipe "database" 
include_recipe "database::mysql" 

mysql_connection_info = { 
    :host  => node['dbserver'], 
    :username => 'root', 
    :port  => node['mysql']['port'], 
    :password => node['mysql']['server_root_password'] 
} 

dbuser = node['remote_root_user'] 
dbpassword = node['remote_root_password'] 

mysql_database_user dbuser do 
    connection mysql_connection_info 
    password  dbpassword 
    host   '%' 
    grant_option true 
    action  :grant 
    only_if { node['remote_root_user'] } 
end 

mysql_database_user dbuser do 
    connection mysql_connection_info 
    password  dbpassword 
    host   'localhost' 
    grant_option true 
    action  :grant 
    only_if { node['remote_root_user'] } 
end 

當我運行所有這一切,我得到以下輸出,其中一個可以看到httpd的安裝,然後再mysql的,然後基線Linux的食譜,它與EPEL開始安裝:

[2013-11-29T00:53:48+00:00] INFO: Forking chef instance to converge... 
[2013-11-29T00:53:48+00:00] INFO: *** Chef 11.6.0 *** 
[2013-11-29T00:53:48+00:00] INFO: Setting the run_list to ["recipe[company-baseline-linux-server::enterprise-linux]", "recipe[company-baseline-linux-server]", "recipe[company-php-server]", "recipe[company-mysql-server]", "recipe[company-php-server::setup-website]", "recipe[company-wordpress-app]", "recipe[company-wordpress-app::copy-assets]", "recipe[company-wordpress-app::load-wordpress-db]"] from JSON 
[2013-11-29T00:53:48+00:00] INFO: Run List is [recipe[company-baseline-linux-server::enterprise-linux], recipe[company-baseline-linux-server], recipe[company-php-server], recipe[company-mysql-server], recipe[company-php-server::setup-website], recipe[company-wordpress-app], recipe[company-wordpress-app::copy-assets], recipe[company-wordpress-app::load-wordpress-db]] 
[2013-11-29T00:53:48+00:00] INFO: Run List expands to [company-baseline-linux-server::enterprise-linux, company-baseline-linux-server, company-php-server, company-mysql-server, company-php-server::setup-website, company-wordpress-app, company-wordpress-app::copy-assets, company-wordpress-app::load-wordpress-db] 
[2013-11-29T00:53:48+00:00] INFO: Starting Chef Run for localhost 
[2013-11-29T00:53:48+00:00] INFO: Running start handlers 
[2013-11-29T00:53:48+00:00] INFO: Start handlers complete. 
[2013-11-29T00:53:49+00:00] WARN: Cloning resource attributes for service[apache2] from prior resource (CHEF-3694) 
[2013-11-29T00:53:49+00:00] WARN: Previous service[apache2]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/apache2/recipes/default.rb:24:in `from_file' 
[2013-11-29T00:53:49+00:00] WARN: Current service[apache2]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/apache2/recipes/default.rb:210:in `from_file' 
[2013-11-29T00:53:49+00:00] WARN: Cloning resource attributes for file[/etc/httpd/conf.d/ssl.conf] from prior resource (CHEF-3694) 
[2013-11-29T00:53:49+00:00] WARN: Previous file[/etc/httpd/conf.d/ssl.conf]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/apache2/recipes/default.rb:84:in `block in from_file' 
[2013-11-29T00:53:49+00:00] WARN: Current file[/etc/httpd/conf.d/ssl.conf]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/apache2/recipes/mod_ssl.rb:28:in `from_file' 
[2013-11-29T00:53:49+00:00] WARN: Cloning resource attributes for template[/etc/httpd/ports.conf] from prior resource (CHEF-3694) 
[2013-11-29T00:53:49+00:00] WARN: Previous template[/etc/httpd/ports.conf]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/apache2/recipes/default.rb:185:in `from_file' 
[2013-11-29T00:53:49+00:00] WARN: Current template[/etc/httpd/ports.conf]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/apache2/recipes/mod_ssl.rb:34:in `from_file' 
[2013-11-29T00:53:49+00:00] WARN: Cloning resource attributes for execute[a2dissite default] from prior resource (CHEF-3694) 
[2013-11-29T00:53:49+00:00] WARN: Previous execute[a2dissite default]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/apache2/definitions/apache_site.rb:34:in `block in from_file' 
[2013-11-29T00:53:49+00:00] WARN: Current execute[a2dissite default]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/apache2/definitions/apache_site.rb:34:in `block in from_file' 
[2013-11-29T00:53:49+00:00] WARN: Cloning resource attributes for directory[/var/lib/mysql] from prior resource (CHEF-3694) 
[2013-11-29T00:53:49+00:00] WARN: Previous directory[/var/lib/mysql]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/mysql/recipes/server.rb:117:in `block in from_file' 
[2013-11-29T00:53:49+00:00] WARN: Current directory[/var/lib/mysql]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/mysql/recipes/server.rb:117:in `block in from_file' 
[2013-11-29T00:53:49+00:00] WARN: Cloning resource attributes for template[/etc/my.cnf] from prior resource (CHEF-3694) 
[2013-11-29T00:53:49+00:00] WARN: Previous template[/etc/my.cnf]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/mysql/recipes/server.rb:134:in `from_file' 
[2013-11-29T00:53:49+00:00] WARN: Current template[/etc/my.cnf]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/mysql/recipes/server.rb:194:in `from_file' 
[2013-11-29T00:53:49+00:00] INFO: Could not find previously defined grants.sql resource 
[2013-11-29T00:54:36+00:00] INFO: package[mysql] installing mysql-5.1.69-1.el6_4 from updates repository 
[2013-11-29T00:54:47+00:00] INFO: package[mysql-devel] installing mysql-devel-5.1.69-1.el6_4 from updates repository 
[2013-11-29T00:55:18+00:00] WARN: Cloning resource attributes for mysql_database_user[wordpress-dba] from prior resource (CHEF-3694) 
[2013-11-29T00:55:18+00:00] WARN: Previous mysql_database_user[wordpress-dba]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/company-mysql-server/recipes/default.rb:27:in `from_file' 
[2013-11-29T00:55:18+00:00] WARN: Current mysql_database_user[wordpress-dba]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/company-mysql-server/recipes/default.rb:36:in `from_file' 
[2013-11-29T00:55:18+00:00] WARN: Cloning resource attributes for link[/etc/httpd/sites-enabled/cabletechtalk] from prior resource (CHEF-3694) 
[2013-11-29T00:55:18+00:00] WARN: Previous link[/etc/httpd/sites-enabled/cabletechtalk]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/company-php-server/recipes/setup-website.rb:14:in `from_file' 
[2013-11-29T00:55:18+00:00] WARN: Current link[/etc/httpd/sites-enabled/cabletechtalk]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/company-php-server/recipes/setup-website.rb:19:in `from_file' 
[2013-11-29T00:55:18+00:00] WARN: Cloning resource attributes for link[/srv/websites/cabletechtalk/webroot/wp-config.php] from prior resource (CHEF-3694) 
[2013-11-29T00:55:18+00:00] WARN: Previous link[/srv/websites/cabletechtalk/webroot/wp-config.php]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/company-wordpress-app/recipes/default.rb:13:in `from_file' 
[2013-11-29T00:55:18+00:00] WARN: Current link[/srv/websites/cabletechtalk/webroot/wp-config.php]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/company-wordpress-app/recipes/default.rb:18:in `from_file' 
[2013-11-29T00:55:18+00:00] WARN: Cloning resource attributes for service[httpd] from prior resource (CHEF-3694) 
[2013-11-29T00:55:18+00:00] WARN: Previous service[httpd]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/company-php-server/recipes/setup-website.rb:23:in `from_file' 
[2013-11-29T00:55:18+00:00] WARN: Current service[httpd]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/company-wordpress-app/recipes/default.rb:22:in `from_file' 
[2013-11-29T00:55:18+00:00] INFO: Adding RPM-GPG-KEY-EPEL-6 GPG key to /etc/pki/rpm-gpg/ 
[2013-11-29T00:55:18+00:00] INFO: remote_file[/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6] created file /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 
[2013-11-29T00:55:23+00:00] INFO: remote_file[/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6] updated file contents /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 
[2013-11-29T00:55:23+00:00] INFO: remote_file[/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6] mode changed to 644 
[2013-11-29T00:55:23+00:00] INFO: remote_file[/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6] sending run action to execute[import-rpm-gpg-key-RPM-GPG-KEY-EPEL-6] (immediate) 
[2013-11-29T00:55:24+00:00] INFO: execute[import-rpm-gpg-key-RPM-GPG-KEY-EPEL-6] ran successfully 
[2013-11-29T00:55:24+00:00] INFO: Adding epel repository to /etc/yum.repos.d/epel.repo 
[2013-11-29T00:55:24+00:00] INFO: template[/etc/yum.repos.d/epel.repo] created file /etc/yum.repos.d/epel.repo 
[2013-11-29T00:55:24+00:00] INFO: template[/etc/yum.repos.d/epel.repo] updated file contents /etc/yum.repos.d/epel.repo 
[2013-11-29T00:55:24+00:00] INFO: template[/etc/yum.repos.d/epel.repo] mode changed to 644 
[2013-11-29T00:55:24+00:00] INFO: template[/etc/yum.repos.d/epel.repo] sending run action to execute[yum-makecache-epel] (immediate) 

我已經試過最明顯的技巧,如推到這個呼叫直接到我們wordpress-的應用程序配方,並將運行列表聲明爲run_list而不是一堆包含。我懷疑這是簡單而愚蠢的,但我似乎無法得出答案。

+0

你提供的「php」配方是「company-php-server」,不是嗎? Apache是​​在php之前安裝的,因爲你之前包含了它:'include_recipe「apache2」'在'include_recipe「php之前。不太清楚實際的問題是什麼。 –

+0

@DracoAter - 感謝您的反饋,我已經編輯了一些問題來澄清問題。問題在於apache和php在上面列出的食譜之前就開始了,所以在進入之前我不能做類似選擇的回購。 –

+0

可能是「company-baseline-linux-server」食譜還包括apache?否則,不知道,對不起。 –

回答

3

我已經有限制(閱讀:沒有)接觸廚師,所以我看不到你的問題。不過,我想提出一些建議,如果你還沒有嘗試過:

  • 尋找可能會導致古怪任何overrideforce-override屬性類型。

  • metadata.rb文件的任何一個文件中查找depends apache2

  • 就像人們編寫代碼一樣,逐漸構建您的Vagrantfile並查看導致問題的第一件事,以嘗試本地化您的問題。

祝你好運!

+0

這是最接近正確的,所以我要給它的賞金。一天結束時,問題依賴於依賴關係 - 數據庫菜譜強制mysql-ruby安裝前臺,這迫使mysql客戶端安裝在前臺,導致依賴問題。 –

+0

恭喜您發現問題。 – Vidya

1

沒有足夠的聲望去寫評論,儘管這樣會更合適。認爲人是對的。以下是您可以嘗試的方法:

只需在之外啓動「include_recipe」調用食譜,並將其作爲「chef.add_recipe」包含在Vagrant文​​件中。或許,這將是這個樣子:

chef.add_recipe "company-baseline-linux-server::enterprise-linux" 
chef.add_recipe "company-baseline-linux-server" 
chef.add_recipe "company-php-server_PART1" 
#following kicked out of company-php-server::default recipe # 
chef.add_recipe "apache2"         # 
chef.add_recipe "apache2::mod_ssl"       # 
#---------------------------------------------------------- # 
chef.add_recipe "company-php-server_PART2" 
#following kicked out of company-php-server::default recipe # 
chef.add_recipe "php"          # 
chef.add_recipe "apache2::mod_php5"       # 
#---------------------------------------------------------- # 
chef.add_recipe "php::module_mysql" 
chef.add_recipe "iptables::disabled" 
chef.add_recipe "company-php-server_PART3" 
# one line recipe that sets 'remove_anonymous_users' attribute 
chef.add_recipe "mysql-remove_anonymous_users_set_true" 
#following kicked out of company-mysql-server::default recipe # 
chef.add_recipe "mysql::server"        # 
chef.add_recipe "database"         # 
chef.add_recipe "database::mysql"        # 
#------------------------------------------------------------ # 
chef.add_recipe "company-mysql-server" 
chef.add_recipe "company-php-server::setup-website" 
chef.add_recipe "company-wordpress-app" 
chef.add_recipe "company-wordpress-app::copy-assets" 
chef.add_recipe "company-wordpress-app::load-wordpress-db" 

不要忘記刪除/評論「include_recipe」從你的食譜線;)

如果這個調用我寫的是不是你想要的順序,那麼有問題。我剛把你的電話解壓到Vagrantfile。按你的意願重新組織它,你就會解決問題。你肯定包含了這些(Apache等)食譜 - 我們的盒子上有非常相似的結構,它工作得很好。

PS。如果你們之間有清教徒,請不要判斷這個流浪文件重組。我只是把它作爲我的意思的一個例子。

+0

謝謝,我們嘗試了類似這種方法的方法,但我們真的不喜歡它,因爲它打亂了我們的封裝,我們試圖避免這種情況。也沒有完全解決問題。 –