2014-10-29 60 views
2

我是Chef的新手,並試圖通過使用Vagrant的Chef腳本禁用Apache中的默認站點。我嘗試以下操作:在主廚中禁用默認站點

include_recipe 'apache2' 

# disable default site 
apache_site '000-default' do 
    enable false 
end 

當我運行 「流浪向上」 我收到以下錯誤信息:

==> default: [2014-10-29T14:16:54+00:00] ERROR: Cookbook apache2 not found. If you're loading apache2 from another cookbook, make sure you configure the dependency in your metadata

==> default: [2014-10-29T14:16:54+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

回答

2

我不得不

depends   'apache2','2.0.0' 

添加到metadata.rb文件

或者我發現您可以將以下腳本添加到您的配方

#disable the default site if it is active 
execute "a2dissite default" do 
    only_if do 
    File.symlink?("/etc/apache2/sites-enabled/000-default") 
    end 
    notifies :restart, "service[apache2]" 
end 

service "apache2" do 
    action [ :restart ] 
end